Traffic Moved to the New WAS but Sockets Remain: When Do You Shut Down the Old Server?

Pointing the load balancer at Green does not move WebSockets already attached to Blue. The shutdown criterion for the old application server is not a single timeout. It is what the remaining users see on their next screen when the deadline arrives. Draining, a missed-notification test, and reconnect backoff.

John Baek
John Baek
Founder, CollabOps
2 min read

10 p.m. We switched the real-time notification service to the new WAS. Every newly connected browser shows the new version. But the old server still has 37 open connections. Three minutes later, eight remain. Is it safe to shut it down?

It depends on what those eight are doing. Once the load balancer starts sending new connections to Green, a WebSocket already talking to Blue doesn't hop over to another server. Waiting for existing connections to finish their work is called draining. The outcome also depends on the device. On F5 BIG-IP, for example, a Disabled member can still accept connections that match an existing persistence record, while Forced Offline can be set to only let already-active connections finish (F5 K13310). (Server names and connection counts are illustrative.)

Switching traffic only changes where new connections go. It does not move WebSocket connections already attached to the old server.

User situationRight after cutoverWhat to check before shutting down the old WAS
(Blue) Notification panel open before cutoverKeeps receiving on Blue over the existing socketAfter shutdown, does it reconnect to Green and receive what it missed?
(Green) First connection after cutoverThe new connection should land on GreenDid any connection bounce back to Blue because of persistence rules?

The user's screen says more than the connection count

Say the browser receives notification #418 and then loses its connection to Blue. While it reconnects to Green, #419 is published. The connection indicator turns green again, but the user's list goes from 418 straight to 420. Operational metrics say "reconnect succeeded." The user experiences "one notification missing."

How do you test a shutdown without losing notifications?

For this service's shutdown test, open a browser before cutover. Keep sending notifications while you close the existing socket, then check which server the new connection landed on and whether any notification is missing or shown twice. Also check that the client can re-read from its last received sequence number. If many clients can drop at once, test the reconnect interval too. The WebSocket standard recommends a random delay before the first reconnect after an abnormal closure, and backing off further on repeated failures (RFC 6455 §7.2.3).

What should decide when the old WAS goes down?

Decide based on what the remaining users will see after they're disconnected. So the answer differs by service. For a notification service, the trigger might be the point at which you can tell remaining connections you're closing and resend anything they missed. For business terminals that can't reconnect, you may need to wait until in-flight transactions finish or an operator approves a forced shutdown.

The value that goes into the runbook isn't a single wait time. It should state what the remaining users will see on their next screen when the deadline hits. The full sequence for running Blue and Green on VMs is in can you do blue-green on existing VMs and WAS without Kubernetes?.

  • #legacy-deploy
  • #websocket
  • #connection-draining
  • #was
  • #blue-green
  • #load-balancer