开发者

PHP - Activating Multiple Instances of a Process

开发者 https://www.devze.com 2022-12-19 11:52 出处:网络
I\'m building a system that watches a queue and activates a set of tasks on a regular interval. I\'m interested in running multiple instances of my processing \"bots\" based on how many items are in

I'm building a system that watches a queue and activates a set of tasks on a regular interval.

I'm interested in running multiple instances of my processing "bots" based on how many items are in the queue. So if there are 5 items I'll run two bots and if their are 10 I'll run four.

I know how to开发者_如何学运维 run multiple instances from CLI (manually), but how would I do this as a function of my application? And how would I properly track the creation and destruction of these bots?


It seems like cron (*nix) or task scheduler (windows) would be what you need. http://en.wikipedia.org/wiki/Cron http://msdn.microsoft.com/en-us/library/aa383614%28VS.85%29.aspx

These can run a PHP script that determine how many "bots" need run, calculations, etc. Anything PHP is capable of.

Also, for running the multiple bots in the background (after the main controller script has finished executing) you may want to look at PHP process forking.


You might also want to look at gearman ( http://gearman.org/ )

0

精彩评论

暂无评论...
验证码 换一张
取 消