使用 Gearman 进行后台处理的 PHP 工作池的属性
我读了一些关于 Gearman 的文章,我想知道它是否可以用作后台处理的工作池。我对具有以下属性的 PHP 工作池感兴趣:
A. 工作人员应该能够同时运行
也就是说,我应该能够拥有一个工作人员池,并且我希望 gearman 在单独的线程中分派多个工作人员。我可能需要一个工作池管理器来管理等待传入作业的工作人员数量。
gearman可以提供这个吗?我是不是错过了重点?
任何帮助表示赞赏。
I did some reading about Gearman and i am wondering if it can be used as a worker pool for background processing. I am interested in a PHP worker pool with the following properties:
A. Workers should be able to run concurrently
That is, i should be able to have a worker pool and i am expecting gearman to dispatch multiple workers in separate threads. I might need a worker pool manager that manages the number of workers waiting for an incoming job.
Can gearman provide this? Have i missed the point?
any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,这听起来像是 gearman 的理想用例。
本质上,您可以拥有 1 个或多个 gearman 服务器,将作业发送到其中,然后您可以拥有 1 个或多个工作人员。工作人员将连接到 gearman 服务器并请求工作。工作人员可以与服务器在同一台机器上,也可以在完全不同的机器上。您可以轻松地让 20 个工作人员同时运行,每个工作人员处理从 gearman 服务器获取的不同作业。
我建议从本演示文稿开始,以便更好地了解 gearman 可以做什么:
http://assets.en.oreilly.com/1/event/27/Gearman_%20Build%20Your%20Own%20Distributed%20Platform %20in%203%20Hours%20Presentation.pdf
This sounds like an ideal use case for gearman, actually.
Essentially you can have 1 or more gearman servers where jobs are sent to, and then you can have 1 or more workers. The workers will connect to the gearman server(s) and ask for jobs. The workers can be on the same machines as the servers or on completely different machines. You could easily have 20 workers all running at the same time, each working on different jobs fetched from gearman servers.
I recommend starting with this presentation to get a good idea of what you can do with gearman:
http://assets.en.oreilly.com/1/event/27/Gearman_%20Build%20Your%20Own%20Distributed%20Platform%20in%203%20Hours%20Presentation.pdf
如果您警告使用纯 php,您可以查看 https://github.com/qxsch/WorkerPool/
In Case you warnt to use pure php you could have a Look at https://github.com/qxsch/WorkerPool/