Does anyone know how to implement heart beat when using Nginx for load balancing between web servers?
AFAIK heartbeat is just to make sure a daemon is running (and acting
upon the reply), but i’m often wrong.
Ideally I would like it to work, so that it checks the content for a web page and if that is not correct then the server is dropped out from the load balancer.
So it’s kind of like making sure all servers are up to date on their
contents and cache? I don’t know about nginx proper, but you could use
cron, wget, some (perl?) scripting… especially if you can target
specific (worker) processes. Otherwise i’m not sure how could you tell
nginx (or other daemons) what “correct content” is.
Yeah for sure wget call would do it, but communicate the result from wget to Nginx in order to drop the misbehaving worker out?
I don’t know about one single worker, but you can HUP nginx, it’ll
create new workers. See . Of course if the bad worker is just
frozen or dead, i guess you’d have to kill it first, then HUP nginx
I think nginx will wait until workers are free before replacing them,
hence the need to maybe kill the lazy worker.