Real Time Updates easy
Why is scaling a WebSocket server generally harder than scaling a standard REST API server?
- A WebSockets are stateful; the server must maintain an active memory footprint for every connected user (Open TCP connections).
- B WebSockets use more bandwidth per message.
- C Load Balancers cannot handle WebSockets.
- D REST APIs don't use TCP.
Answer: A. WebSockets are stateful; the server must maintain an active memory footprint for every connected user (Open TCP connections).
A REST server forgets the user after the response is sent (Stateless). A WebSocket server is 'married' to the client. If you have 1 million users, you need 1 million open sockets in RAM.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- When a mobile app is closed/backgrounded, it cannot keep a WebSocket open. How does it receive real-time alerts (like 'New Message')?
- For a human user, what is generally considered the maximum acceptable latency for an interaction to feel 'Real-Time' (e.g., typing in a Google Doc)?
- If you want to update a news feed on a website every time a new article is published, what is the simplest (but least efficient) 'Real-Time' technique?
- In a persistent real-time connection, what is the purpose of a 'Heartbeat' or 'Ping/Pong' message?
- Why is Short Polling considered 'Chatty'?
- Server-Sent Events (SSE) are ideal for which type of real-time application?