Real Time Updates medium
User A is connected to Server 1. User B is connected to Server 2. User A sends a chat message to User B. Without a 'Backplane' (like Redis Pub/Sub), what happens?
- A Server 1 cannot deliver the message because it has no direct TCP connection to User B.
- B The Load Balancer automatically routes the internal traffic to Server 2.
- C The browser automatically resends the message to Server 2.
- D Server 1 broadcasts the message to all its own connected users.
Answer: A. Server 1 cannot deliver the message because it has no direct TCP connection to User B.
WebSocket connections are stateful and local to a specific server memory. Server 1 doesn't know User B exists on Server 2. A Pub/Sub mechanism is required to bridge the servers, broadcasting the message from Server 1 to Server 2 so Server 2 can push it to User B.
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?