最近耳濡目染的了解了swoole、rabbitmq,redis以前用这还算熟悉。公司是做O2O项目,我是后台组(PHP),负责为移动APP端提供数据接口,现在用户数呈指数增加,再有项目很快就无法承受高迸发访问,所以想重构。
初步的想法是:
用rabbitmq作service,处理一些耗时工作,比如:图片上传,邮件发送,日志等。
用redis作数据缓存。
swoole不知道怎么用,看了官方的一些介绍好像很适合处理高迸发项目,但是不知道怎么实用起来。
现有以下几点疑问:
1、rabbitmq怎么传递任务,比如用户上传图片,表单提交一个图片过来,怎么将这个任务加入到队列?消息应该怎么传?传送邮件如果失败了(邮件地址不正确)怎么通知前端应用?
2、三者如何组合,用什么作为接口入口?
3、或者有其他比较好的架构?
For example, the form passes two names: name and img, then generate a new file name for img and save the image, store the name and image file name into the database, and pass the image file name to the message queue (you can consider the image path issue ). What follows is another task to process these queues and transfer the pictures to the picture server.
but! Instead of using a message queue to upload images, it is better to use a dedicated image server to handle them directly. As for the failure to send the email, if it takes a long time to wait for the email server to respond, you can use other methods such as in-site message notification.
2. Of course, swoole should be used as the entrance in combination.