Difference between using Message Queue vs Plain Cron Jobs with PHP

蓝咒 提交于 2019-12-04 09:34:44

问题


We have a large web application built on PHP. This application allows scheduling tweets and wall posts and there are scheduled emails that go out from the server.

By 'scheduled', I mean that these are PHP scripts scheduled to run at particular time using cron. There are about 7 PHP files that do the above jobs.

I have been hearing about Message Queues. Can anyone explain if Message Queues are the best fit in this scenario? Do Message Queues execute PHP scripts? or do we need to configure this entirely differently? What are the advantages / disadvantages?


回答1:


Using Crontab to make asynchronous tasks (asynchronous from your PHP code) is a basic approach where using a job/task queue manager is an elaborate one and give you more control, power and scalability/elasticity.

Crontab are very easy to deal with but does not offer a lot of functionalities. It is best for scheduled jobs rather than for asynchronous tasks.

On the other hand, deploying a Task queue (and its message broker) require more time. You have to choose the right tools first then learn how to implement them in your PHP code. But this is the way to go in 2011.

Thank God, I don't do PHP but have played around with Celery (coupled with RabbitMQ) on Python projects ; I am sure you can find something similar in the PHP world.



来源:https://stackoverflow.com/questions/8599664/difference-between-using-message-queue-vs-plain-cron-jobs-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!