The interview problem

Practice prompt

Design live order-status updates for a dashboard with 200,000 concurrent browser connections. Clients disconnect, sleep and reconnect. Deliver updates within two seconds under normal conditions, support a 30-minute replay window and recover older clients from a snapshot. Explain how to avoid a gap between replay and live delivery.

Original system-design practice, not a reported interview. Hypothetical workload. This guide concerns structured browser events, not live video. Primary standard retrieved September 27, 2026.

1. Define the delivery contract

Assume updates flow mainly from server to browser; commands use a separate authenticated request API. Server-sent events are a reasonable transport. WebSockets become attractive for frequent bidirectional traffic, but neither transport automatically supplies durable replay or application-level exactly-once processing.

Specify ordering per account stream, not a global order across unrelated customers. Each event has a stream identity, epoch and monotonically ordered position. The payload includes entity identity and entity version. Replays may repeat events, so clients apply state updates idempotently and ignore already-applied or older entity versions.

The two-second objective is measured from durable event acceptance to an active client's receipt under the stated operating conditions. A sleeping browser is excluded from that latency target but included in recovery tests. Distinguish server write completion, browser receipt and successful application processing.

2. Separate durable history from connection ownership

Business transactions record their state change and an outbox entry atomically. A publisher transfers entries to an ordered durable stream, with duplicate identity preserved across publisher retries. Partition by account or another documented ordering key. Gateways hold browser connections and subscribe only to streams needed by their connected customers.

A gateway failure loses sockets, not event history. A replacement gateway authenticates a reconnect, validates its cursor and reads retained events. Keep authorization tied to the requested stream; a cursor is a position, not a credential. Reject cursors from another tenant or an incompatible stream epoch.

Use a snapshot service backed by a materialized view that tracks the exact stream position applied to that view. Connection gateways should not query the transactional database for every update or rebuild the complete customer history on each reconnect.

3. Make replay and live one continuous sequence

A naive gateway first queries history and then subscribes to a pub/sub channel. An event committed between those steps can disappear from that client's view. Prefer a durable reader that starts after the client's position and continues tailing the same log. Live delivery is then simply reading near the end of history.

If separate replay and live mechanisms are unavoidable, establish the live subscription and bounded buffer first, capture a high-water position H, replay through H, then drain buffered events strictly after H. Deduplicate overlap by stable positions. This only works if subscription establishment and the chosen boundary have a defined ordering relationship; a timestamp guessed on the gateway is insufficient.

For example, the client last applied 40 and H is 45. Replay 41–45, then deliver buffered 46 onward. Buffered copies of 44 and 45 are discarded. If the buffer overflows or retention advances past needed events, abandon this attempt and restart from a valid recovery path instead of skipping silently.

4. Recover expired cursors consistently

When a cursor is older than retained history, return an explicit resynchronization instruction. Fetch a snapshot with a version boundary S and then consume events after S. The snapshot contents and S must describe the same logical state, for example through a transactional read of a materialized view and its applied offset.

Reading today's database rows and independently taking the stream's latest position can lose updates: the rows might reflect position 100 while the returned cursor is 105. Starting after 105 skips five changes. Conversely, a snapshot containing later changes with an older cursor can replay duplicates; version-aware state application may tolerate those, but the contract should not depend on accidental behavior.

Retain the required tail long enough for snapshot download and connection establishment, or verify that S remains replayable before completing recovery. If a huge account cannot download within that window, provide a pinned recovery session or a different snapshot delivery strategy with explicit resource limits.

5. Do not mistake a transport cursor for a committed action

The EventSource protocol carries event IDs and uses the last event ID on reconnect. That mechanism supports resumption at the transport level; it does not establish that the application's handler committed its work successfully. An event handler can fail after an event was dispatched.

For a dashboard, periodic versioned snapshots and idempotent state replacement may be enough. If the client performs durable processing, maintain an application checkpoint advanced only after the relevant state commit, and use an application-controlled resume mechanism. A newly created EventSource can receive a non-secret checkpoint via the request URL under an explicit API contract. Specify cursor precedence: for application-committed recovery, close the old source and recreate it from the saved application checkpoint rather than trusting its automatic transport-level resume position.

Do not make a browser notification trigger an irreversible business action without a separate idempotent command protocol. Refreshing a tab, running two tabs or replaying history should not create a second shipment. Event delivery and business execution have different correctness boundaries.

6. Calculate fan-out and recovery load

Assume each of 200,000 connections receives two 400-byte events per second. Application payload egress is 200,000 × 2 × 400 = 160 MB/s, or 1.28 Gbit/s, before framing, encryption and retransmission. If each connection consumes 32 KB of server memory, connection state alone is 6.4 GB across the fleet.

Assume the upstream log contains 10,000 distinct events/s at 400 bytes each. Thirty minutes of raw history requires 10,000 × 400 × 1,800 = 7.2 GB; three copies require 21.6 GB before indexes and overhead. This is distinct from fan-out volume: one event can reach many connections.

If 20% of clients reconnect after a gateway failure, that is 40,000 connection attempts. Spreading them over 60 seconds averages about 667 handshakes/s; it is not a peak bound. Capacity-test authentication, TLS setup and replay reads together. Warm gateways, admission control and randomized reconnect scheduling should protect the shared services during recovery.

7. Bound slow-client work

Give each connection a byte and age limit for queued data. A browser that cannot keep up must not consume unbounded memory. Coalesce replaceable state updates only when the product needs the latest state rather than every transition. Never silently coalesce audit events that consumers are entitled to observe individually.

On overflow, disconnect with a documented recovery signal or request resynchronization. Replaying faster than a client can consume forever is not recovery. Apply fair per-tenant budgets so a large dashboard cannot starve smaller customers. Refresh authorization during long-lived connections and define how quickly revocation reaches gateways.

Test disconnects at every position, duplicate publication, gateway replacement, expired history, authorization revocation and snapshot/log mismatches. Track oldest queued event age, replay volume, resynchronization frequency and client-observed version gaps. An open socket alone is not a healthy user experience.

Foundation: choose SSE versus WebSockets. Senior: prove replay-to-live continuity. Staff: recover expired cursors and preserve authorization through gateway failures.

Score 0–2 each for delivery semantics, sequence handoff, snapshot consistency, capacity and backpressure. Continue with durable queues and change-data capture.

Sources and next steps

The durable-log, snapshot and application-checkpoint architecture is an original design; these guarantees are not supplied by the transport standard alone.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.