The interview problem

Practice prompt

Upgrade a fleet of WebSocket gateways without abruptly dropping every active client or waiting forever for connections that never close.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Assume clients support reconnect and durable application cursors. Mark a gateway draining so it stops new admission, notify clients with randomized reconnect guidance, and allow current work a bounded completion period. Fence old connection ownership when clients reconnect elsewhere. Preserve logical session state outside the disposable gateway; send delivery acknowledgments only according to the durable application protocol.

2. Trace the design or derivation

Stop new admissions
  → notify clients
  → spread reconnects
  → finish or expire connections
  → terminate

A deployment controller should pause the next wave if reconnect errors or authentication load exceed a threshold. Clients need exponential backoff with jitter and resumable application state. Keeping old connections alive forever avoids some disruption but prevents bounded rollout completion; define a maximum drain deadline and user-visible retry behavior.

3. Calculate the example

A fleet has 100 gateways with 10,000 connections each. Draining ten gateways creates up to 100,000 reconnects. Spreading them uniformly over 200 seconds targets 500 reconnects/s, before failures and retries. Draining all gateways simultaneously removes the destination capacity needed to absorb those clients.

4. Failure cases and trade-offs

Load balancers may keep routing new connections to a draining endpoint until health propagation completes. A client can briefly have two sockets; deduplicate application effects and use ownership epochs. An infinite grace period blocks upgrades; a finite deadline requires a tested recovery path.

5. Validation, follow-ups and self-review

Test slow clients, interrupted reconnects, duplicate sockets and expired cursors. Measure reconnect spikes and lost/duplicated application messages. Follow-up: how do you handle clients that ignore drain notices? Reward admission control, bounded grace and cursor-based recovery rather than claiming zero TCP disconnects.

Sources and related practice

Technical reference: www.envoyproxy.io — Connection draining during service lifecycle changes.

Source publication/update: Not established. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Design resumable browser event streams; Bound retries across a service call chain.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.