简体   繁体   中英

Difference between using Message Queue vs Plain Cron Jobs with PHP

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM