When 2 Million Users Reconnect at Once @ Irfan Irshad | Thursday, Oct 1, 2026 | 7 minutes read | Update at Thursday, Oct 1, 2026

A chat service holds 2 million WebSockets just fine. Then a deploy drops them, everyone reconnects at once, and the servers fall over. Why?

Cover: wildebeest during the Great Migration, photo by Bjørn Christian Tørrissen, CC BY-SA 3.0.

The question

Evan King, co-founder of Hello Interview and one of my favourite people explaining system design online, posted this as his practical system design question of the day:

You’re building something like Slack. Your chat service maintains WebSocket connections with 2 million online users. Under normal traffic, the system handles that load without a problem.

Then you deploy a new version of the service and the existing connections are dropped. Almost immediately, a huge percentage of clients try to reconnect.

The new servers get overwhelmed, even though they’re sized to handle 2 million active connections.

What’s causing the reconnect storm, and what would you change?

This is what I answered:

Great question! WSS connection establishments are way more expensive than an established socket - Idle sockets are even cheaper (epoll_wait() from kernel can handle 10000s of sockets w/ a single thread because bounded queues!). I have seen where a server that could maintain 100K socket connections crumble under 30k concurrent TLS handshakes (socket admissions) simply because its expensive.

It’s a classic case of reconnecting storm. Possible ways to deescalate would vary on levels but not limited to randomized/jittered retries, Ops fixes (deployments) or some sort of socket admission control system etc as others pointed out.

Evan’s question and my answer on LinkedIn

And Evan’s reply:

Evan King: “Great explanation of the problem, kudos!”

A LinkedIn comment is short by design. This post is the long version.

Holding a connection is cheap. Opening one is not.

The trap in the question is the phrase sized to handle 2 million active connections. That sizing is for the steady state, and the steady state is the cheap part.

An idle WebSocket costs almost nothing. Once it’s open, it’s a file descriptor, a few kilobytes of kernel buffers and whatever per-user state the app keeps. The server doesn’t poll each socket asking “anything new?”. It hands them all to the kernel with epoll and waits. The kernel keeps a ready list, and epoll_wait() returns only the sockets that actually have data. Its cost depends on how many sockets are active, not how many are open. That’s why one thread can watch tens of thousands of quiet connections.

Opening a connection is expensive. Every new WebSocket over TLS goes through:

  1. A TCP handshake. A round trip, plus a slot in the kernel’s accept queue.
  2. A TLS handshake. This is the big one. The server does public-key cryptography for every new client, costing real CPU time per connection, orders of magnitude more than moving a small chat message.
  3. The HTTP upgrade to WebSocket.
  4. The application’s own welcome: check the user’s token, load their workspaces and channels, subscribe them to the right topics, mark them online (which tells everyone else they’re back), and send them whatever they missed while disconnected.

Step 4 is easy to forget, and it often hits the database, not just the chat servers. One reconnect can mean several reads, a presence update fanned out to everyone in your channels, and a “catch me up” query.

So a server that comfortably holds 100,000 connections can fall over when 30,000 of them try to open at the same moment. That’s what I’d seen before, and it’s what happens here, times twenty.

Why it turns into a storm

A deploy that drops every connection turns 2 million independent users into one synchronised crowd.

  • Everyone notices at the same time. The old servers go away together, so every client’s onclose fires within the same second or two.
  • Everyone retries on the same schedule. A naive client does “wait 1 second, try again”. Two million clients that all failed together now retry together, in waves.
  • Failed attempts make it worse. A handshake that times out still burned CPU. The client retries, adds to the next wave, and the server spends its time on half-finished handshakes that never become working connections.
  • The new servers aren’t warm. Fresh instances have cold caches, empty connection pools and autoscaling that reacts in minutes, while the storm arrives in seconds.

Some rough arithmetic shows the scale. If 2 million clients reconnect within about 10 seconds, that’s around 200,000 TLS handshakes a second, plus 200,000 rounds of “who are you, what did you miss”. That’s a completely different workload from “keep 2 million quiet sockets open”, and nothing was sized for it.

This is a metastable failure: the system is fine in its normal state, but once it’s knocked out of it, the retries keep it down even after the original cause (the deploy) is long over.

How to calm it down

As I said in my comment, the fixes come at different levels. You want several of them, because each one covers what the others miss.

1. Clients: back off, with jitter

The cheapest fix lives in the client. Instead of retrying on a fixed timer, wait exponentially longer after each failure, and add randomness so clients spread out instead of moving in waves:

function reconnectDelay(attempt) {
  const base = 500;          // ms
  const cap = 30_000;        // never wait more than 30 s
  const max = Math.min(cap, base * 2 ** attempt);
  return Math.random() * max; // "full jitter": anywhere from 0 to max
}

The randomness is the important part. Exponential backoff alone still has 2 million clients retrying at 0.5 s, 1 s, 2 s, 4 s… in lockstep. Jitter turns those spikes into a smooth ramp.

2. Servers: say “not now” cheaply

When a server is at capacity, the worst thing it can do is accept a connection and then choke on it. Better to refuse early and cheaply:

  • Admission control. Limit how many new handshakes are allowed per second (a token bucket works well) and reject the rest straight away.
  • Tell the client when to come back. With an HTTP 503 and a Retry-After header, or WebSocket close code 1013 (“Try Again Later”) plus a suggested delay, the server controls the pace instead of the clients.
  • Make handshakes cheaper. TLS session resumption lets a returning client skip most of the expensive crypto. Terminating TLS at a load balancer or edge tier moves the cost off the chat servers.

3. Deploys: don’t drop everyone at once

The storm was triggered by an operational choice, so change the operation:

  • Drain gradually. Instead of killing an old server and its 100,000 connections in one go, close them in small batches over several minutes, each with a slightly different delay.
  • Roll out slowly. Replace servers a few at a time, so only a small slice of users is ever reconnecting.
  • Separate holding sockets from running logic. Put a thin connection layer (a gateway) in front of the chat logic. The gateway rarely changes and holds the sockets. The chat service behind it can be deployed ten times a day without a single user noticing.

4. The welcome: make reconnecting light

Look at everything a reconnect triggers, and defer what can wait:

  • Send the client what it missed lazily, or let it ask with a “since message X” cursor, instead of rebuilding its whole state up front.
  • Batch presence updates, so 2 million “I’m back” events don’t each fan out to every channel member.
  • Protect the database behind the chat service with its own limits, so a storm at the front door doesn’t become an outage at the back.

What to watch

You can see a reconnect storm coming if you watch the right numbers:

  • New connections per second, not just total connections.
  • Handshake failures and timeouts.
  • The kernel’s accept queue (are connections waiting to be picked up?).
  • CPU spent in TLS.
  • Reconnect attempts per client (are the same users failing over and over?).

The short version

The question’s trap is the word sized. Servers sized for 2 million connections are sized for holding them, and holding is cheap. Opening them is expensive, and a deploy that drops everyone makes 2 million people open at once.

The fixes:

  • Clients back off with jitter.
  • Servers refuse early and say when to come back.
  • Deploys drain slowly.
  • Reconnects do as little as possible.

Thanks to Evan for the question, and for the kudos. If you’re preparing for system design interviews, his work at Hello Interview is worth your time.

© 2020 - 2026 System Design Talks

Powered by Hugo

The End?

avatar
About me

I’m Irfan Irshad, a software engineer at Infor in Hyderabad.

I enjoy software and electronics in general, and specifically systems engineering, AI, robotics and cyber security. This blog is where I write about them.

The views expressed on this site are my own and do not reflect those of my employer.

Experience

I work at Infor in Hyderabad as a software engineer.

Alumnus of IIIT Allahabad
Jhalwa gang

Social Links