work with AWS ELB to keep websocket connections during server restarting?

cn flag

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:

  1. take off A from the ALB/NLB
  2. new connections from the clients will only forwards to B
  3. ALB/NLB migrates the existing connections with A to B
  4. A finished upgrading, put A onto the ALB/NLB
  5. new connections from the clients forwards to A again
  6. 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?

fi flag

Unfortunately, no LB offered by AWS has this ability of migrating live connections from an upstream to another. You need to have a high time of draining and roll connections slowly.

I sit in a Tesla and translated this thread with Ai:


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.