Soumo Gorai
Soumo Gorai

Reputation: 143

PHP Advance Job Queue

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 ?

Upvotes: 2

Views: 8802

Answers (4)

David Goodwin
David Goodwin

Reputation: 4318

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)

Upvotes: 1

Nick
Nick

Reputation: 6965

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.

Upvotes: 2

infinite
infinite

Reputation: 7

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.

Upvotes: -1

Abhinav Singh
Abhinav Singh

Reputation: 2651

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

Upvotes: 4

Related Questions