-
When I front NodeJS with say NGINX I can specify a server pool and add/remove servers from that pool simply by saying whether it's down or not. Once removed, connections drain organically over time and when a server (NodeJS instance) has none I can restart it thus allowing me to do rolling code updates which for some purposes is an ok to do thing imo. My question is, how could I go about doing the same thing internally to a NodeJS Cluster? My understanding is the master cluster worker load balances connections between workers using 1 of 2 methods but what if I wanted to take a worker out of the "pool", wait until existing connections drop off over time and when zero just kill the worker and re-fork a new one thus adopting any new code I may have added/changed. Maybe there is already some code out there that allows me to do this? I guess what I am asking for is a way to tell the master worker that a new connection should not be connected to a specified worker. I guess I could set a flag in the child worker and it could redirect the incoming request and in a round robin environment that might work, but least busy might not and we get a race situation. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If I understand correctly, it sounds like you may want to look into |
Beta Was this translation helpful? Give feedback.
If I understand correctly, it sounds like you may want to look into
worker.disconnect()
. Take a look at the code sample for that method as well. You'll likely need to write some custom code or look for something on npm as well.