So we have a server application which communicates with clients through websocket and we need to regularly upgrade our server app binary. We may have multiple server instances, I know that I can offline the instance I'm upgrading but you know since websocket is long-lived tcp connections so the instance still holds some existing connections with the client, we don't want these existing connections disconnect.
I have known that I can do some work in our server application implementation to delegate the existing connections to a sub-process. But I'm wondering now if I could use AWS ELB to mitigate this issue.
I'm not quite sure how ALB/NLB works exactly, but I'm thinking since ALB/NLB is hiding servers from clients, it's the ALB/NLB holds the connections with clients. Then during server upgrades, could ALB/NLB migrate the existing connections related to the upgrading instance to the ones that has already finished upgrading?
Say we have two server instances A and B, the procedure would looks like:
- take off A from the ALB/NLB
- new connections from the clients will only forwards to B
- ALB/NLB migrates the existing connections with A to B
- A finished upgrading, put A onto the ALB/NLB
- new connections from the clients forwards to A again
- repeat the procedure on B
During the whole process, the client is unaware what happens on the cloud.
Does ALB/NLB support the stuff like this?