You need to design a system that supports 1 million concurrent WebSocket connections for a chat application. Which architecture component is essential to handle this scale efficiently?
Think about how to distribute connections and maintain session consistency.
Multiple WebSocket servers behind a load balancer with sticky sessions allow distributing connections while ensuring messages reach the correct server maintaining session state.
What is the main purpose of the WebSocket handshake between client and server?
Consider what changes from HTTP to WebSocket during connection setup.
The handshake upgrades the HTTP connection to a persistent, full-duplex WebSocket connection allowing real-time communication.
You want to broadcast messages from one client to all other connected clients in a distributed WebSocket server environment. Which approach ensures efficient and consistent message delivery?
Think about how to synchronize messages across multiple servers.
A centralized message broker like Redis Pub/Sub allows all WebSocket servers to receive and forward broadcast messages to their clients, ensuring consistency.
For a real-time dashboard showing live data updates, which tradeoff is true when choosing WebSocket over HTTP/2 server push?
Consider communication direction and server complexity.
WebSocket supports full-duplex communication allowing both client and server to send messages anytime, but managing many connections is more complex than HTTP/2 streams.
You plan to support 500,000 concurrent WebSocket connections. Each connection uses 50 KB of memory on the server. How much total memory (in GB) is required just for maintaining these connections?
Multiply connections by memory per connection and convert bytes to gigabytes.
500,000 connections * 50 KB = 25,000,000 KB = 25,000 MB = 25 GB.