在PHP中使用Message Queue与Plain Cron Jobs之间的区别 [英] Difference between using Message Queue vs Plain Cron Jobs with PHP

查看:78
本文介绍了在PHP中使用Message Queue与Plain Cron Jobs之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个基于PHP的大型Web应用程序.此应用程序允许安排推文和留言墙,并且有从服务器发送的计划电子邮件.

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.

通过预定",我的意思是这些是预定在特定时间使用cron运行的PHP脚本.大约有7个PHP文件可以完成上述工作.

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.

我一直在听到有关消息队列的信息.任何人都可以解释在这种情况下,Message Queues是否最合适吗?消息队列是否执行PHP脚本?还是我们需要完全不同地配置它?优点/缺点是什么?

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?

推荐答案

使用 Crontab 进行异步任务(与PHP代码异步)是一种基本方法, 作业/任务队列管理器是一种精心设计的工具,可为您提供更多的控制,功能和可伸缩性/弹性.

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非常易于处理,但是没有提供很多功能.最好是计划作业,而不是异步任务.

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.

另一方面,部署任务队列(及其消息代理)需要更多时间.您必须首先选择正确的工具,然后学习如何在PHP代码中实现它们.但这是2011年的发展方向.

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.

感谢上帝,我不使用PHP,但是在 Celery (与RabbitMQ结合)上玩了 Python 项目;我相信您可以在PHP世界中找到类似的东西.

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.

这篇关于在PHP中使用Message Queue与Plain Cron Jobs之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆