PHP Advance Job Queue

断了今生、忘了曾经 提交于 2019-12-10 10:42:40

问题


I am making a script with 2000 jobs in a day using cron (means that is server side and automatically do all jobs.)

but the job require to run simultaneously 10 (or specified no. of jobs ) jobs .

like if u see IDM(internet download manager ) there is a queue function it run multiple jobs at a time and if any complete it start another . i want something like this ..

how can i do this ?


回答1:


You can either go ahead and write your own custom job queue handler. Spawn a separate process per job, and keep collecting the response in the parent process. Restart new jobs when previous one's have finished.

Or alternately you can dig into using Gearman (specially if you have multiple boxes running jobs in parallel). Also do view solutions proposed here on asynchronous-processing-with-php-one-worker-per-job




回答2:


I disagree with making your own job queue handler. You're going to run into problems down the line that you didn't anticipate and that existing projects have already met and dealt with.

I'd go with something like beanstalkd, build a generic script to handle the jobs in the queue, then spawn $x child processes to go through and process them.




回答3:


There's also the wordpress job queue - see http://code.trac.wordpress.org/wiki/JobsDocs (I've not used it, so can't vouch for it)




回答4:


You would be well off writing your own job queue handler.
You could make php ignore_user_abort and make it a daemon process too...

But make sure you have some control over it before you do that.



来源:https://stackoverflow.com/questions/5672545/php-advance-job-queue

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