Search code examples
mysqlsymfonygearman

Gearman and lost workers


I want to use gearman as a queue-system for a webproject. Therefor I tried gearman and gearmanManager which works great. But know, I ask myself what happen if a worker, job or server has gone (for example php error or whatever the reason might be).

  • What happens if I run an synchron job where the client (browser) waits for a callback and the worker/server crashed?
  • What happens if there is an asynchronus job which chrashed while it is in work? Will gearman try it again (cause it is stored as a queue in mysql) or will gearman ignore it? And what happen to it if it will not be ignored and the worker crash over and over again?

I would like to found out if the system ist scalabel (for example by NFS). Do you have examples for me or experiences on which I can get forward?

Thank you all and have a very nice weekend...

Phil


Solution

    1. If the server has crashed, your client won't have anything to connect to. How you handle that is up to your application. If the worker has crashed, and you're attempting to run a synchronous task, the client will wait until a worker becomes available, unless you've provided a timeout value.

    2. If the async task is performed and the worker, gearman will requeue the task at hand. If it crashes each worker that grabs it, you might be left without any active workers. The C-version / gearmand has an option to tweak this behavior:

      -j [ --job-retries ] arg (=0) Number of attempts to run the job before the job server removes it. This is helpful to ensure a bad job does not crash all available workers. Default is no limit.

    If you deploy broken or fragile code you will have issues, regardless of which system you're using. Bad code breaks applications. :-)

    A Gearman setup is scalable, but remember that if you use the persistent queue support, each server needs to have it own backend. You can't share the same database and tables across server instances, since the persistent queue is only maintained as a backup in case gearmand dies and has to be restarted. It might be more useful to allow your application to easily queue tasks again if needed.