How we rebuilt our real-time messaging layer for 10x scale
When DESIRIY launched, our messaging infrastructure was built for hundreds of concurrent connections. Within the first week we had tens of thousands. This is the story of how we rebuilt it without taking the service down.
The original architecture used a single stateful WebSocket server behind a load balancer. This worked at small scale but had a critical flaw: connections were sticky. If a server went down, all connections on that server dropped simultaneously — creating thundering herd reconnection storms.
We migrated to a fan-out architecture built on Redis Pub/Sub with a stateless WebSocket tier. Each WebSocket server subscribes to a shared channel per user. Messages are published once and fan out to all connected devices for that user, regardless of which server holds the connection.
The migration happened in three phases over six weeks:
1. We deployed the new stateless tier alongside the old one and gradually shifted traffic.
2. We migrated session state from in-process memory to Redis with a TTL.
3. We retired the old sticky-session load balancer configuration.
Result: zero-downtime migration, 10x connection capacity, and reconnection storms reduced by 94%. Detailed write-up and open-source components coming to our developer blog next week.