Real Time Updates hard
You are load testing your WebSocket server. You launch 60,000 clients from a single test machine. The tests start failing with `EADDRNOTAVAIL`. Why?
- A You ran out of outgoing ephemeral ports. A TCP connection is identified by a 4-tuple. Since Source IP, Dest IP, and Dest Port are constant, you only have ~65k Source Ports available per client IP.
- B The server ran out of RAM.
- C The server's backlog queue is full.
- D The load balancer rejected the connections.
Answer: A. You ran out of outgoing ephemeral ports. A TCP connection is identified by a 4-tuple. Since Source IP, Dest IP, and Dest Port are constant, you only have ~65k Source Ports available per client IP.
This is a client-side limit in testing (or forward proxies). To fix this, you need to add more IP addresses (Virtual IPs) to the test machine, creating more unique 4-tuples.
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?