Nyxynyx
Nyxynyx

Reputation: 63647

Multiple gearman workers on the same server (PHP)

I am considering using Gearman for processing jobs off a MySQL table jobs_queue and marking their state as locked in a way that a job does not gets taken twice (which is happening right now).

Question: In the above scenario, a job can take 10 seconds to be completed, and I want a new job to start processing every 2 seconds (to achieve some form of rate-limiting). Currently, the server that retrieves the jobs from the table is also the same machine that is processing the job.

Is gearman suitable for doing job queueing as described? The client will be creating jobs that will be done by itself (multiple workers on the same machine).

Upvotes: 1

Views: 2173

Answers (1)

Simon Bennett
Simon Bennett

Reputation: 355

Yes it is but instead of having a MySQL list of jobs you could directly send the jobs to the Gearman job server. This means you will not have to 'lock' jobs.

You can have multi workers running the same job.

If you do it the way I have said your workers that create more work will need to use gearmam do background, otherwise it will end up in a dead loop. http://www.php.net/manual/en/gearmanclient.dobackground.php

Upvotes: 2

Related Questions