Posts

Showing posts from June, 2026

Scalable Websocket Systems: What to know?

Scalable Websocket Systems: What to know? How connections are established. Why sticky sessions matter. How room membership is tracked. How message ordering is handled. What happens when a WebSocket server dies. Presence (online/offline users). Persistence vs Pub/Sub. Why Redis Pub/Sub may fail at scale. Why NATS worked better. Fan-out optimization techniques. Backpressure handling. Monitoring and metrics. Multi-region challenges. Let's rebuild the entire story from the beginning as if we are designing WhatsApp ourselves. Chapter 1: User Opens WhatsApp Suppose User A opens WhatsApp. Immediately: User A | | Internet | Load Balancer | WebSocket Server The client requests: GET /socket Upgrade: websocket Server accepts. Now connection becomes: User A <=================> Server and stays alive. Chapter 2: Why Not HTTP? With HTTP: User A | Request | Server If User B sends a message: Server cannot push because HTTP request ended. Server must wait. WebSocket solves thi...