Bull: How to check for worker health.

Created on 2 May 2018  路  6Comments  路  Source: OptimalBits/bull

Question: Worker HealthCheck

I have a simple implementation where API create jobs, and multiple workers just subscribe and process jobs.

I would like to scale the workers and monitor their health. Worker is just a simple script file and doesn't have any rest endpoint.
What would be the best way to get the health of the worker. Ideally worker will be running in a separate container which has no knowledge of the main API.

Is Bull provide such functionality, if not is it prefer if I just open another queue for healthcheck (sound like a hack) 馃

Thanks.

BETTER DOC question

Most helpful comment

You can use the "getWorkers" api to get all the current online workers that are connected to the redis instance.

All 6 comments

There is no health check built in. What we have is a getter that returns all the workers for a given queue https://github.com/OptimalBits/bull/blob/master/lib/worker.js#L18
I am afraid is not yet documented.

It would be great if there was a way to have health check built in. My use case is that I run sandboxed workers on AWS Fargate, which after some hours seem like zombies (they seem to be up & running but they do not consume tasks). Why this happens is beyond the scope of this thread (perhaps a memory leak, a terrible bug etc) but if there was a health check functionality I could easily spot zombies and kill the corresponding tasks (and spawn new ones).

@hymloth I will think about it. Although I cannot figure out an easy way to do it, maybe we could put the worker ID on every processed job and by examining the last N jobs we can see if there are workers that have not been processing any jobs and be reported as candidates for being Zombies or something like that.

Would be great to have a method to check if the queue still has an open connection to the database.

I am wanting the same as @fmoessle above. Just a bull method that returns the existing Redis.status. My use case is checking all my services are up. I can set a new connection to redis of course that tells me Redis is running, but doesn't necessarily tell me if Bull is still connected or not.

You can use the "getWorkers" api to get all the current online workers that are connected to the redis instance.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joe-at-startupmedia picture joe-at-startupmedia  路  3Comments

PhillippOhlandt picture PhillippOhlandt  路  4Comments

weeco picture weeco  路  3Comments

alolis picture alolis  路  4Comments

JSRossiter picture JSRossiter  路  3Comments