Design a Live A-or-B Survey
Design a high-traffic live survey where viewers cast one A-or-B vote, see fresh results, and the host receives an accurate final tally.
Problem statement
For this exercise, assume a host opens one A-or-B survey during a major live broadcast. An authenticated viewer may cast one vote and may change it until the host closes voting; the viewer immediately sees a current result and whether that result is still updating. The host can open, close, and obtain a final result.
A vote is accepted only while the survey is open, and the final tally must equal the latest durably accepted choice for every eligible viewer. Retries, reconnects, duplicate delivery, and a close racing with votes are expected.
Live results may be slightly stale, but finalization must expose pending or uncertain state rather than declare an inaccurate winner.
For this exercise, eligibility is provided by an external identity service, detailed anti-fraud modeling and broadcast-video delivery are out of scope, and vote events are retained for seven days for reconciliation.
What to build
- An authorized host can open and close a survey and read its lifecycle state.
- An eligible viewer can cast or change one A-or-B choice while the survey is open with idempotent retry semantics.
- Viewers can read current totals with a freshness or degraded-data indicator.
- The host can obtain an immutable final tally that includes every vote durably accepted before the close boundary exactly once.
At scale
- Up to 10 million viewers join one survey, with 2 million concurrent voting sessions and a peak of 500,000 vote changes per second during the final minute.
- Vote acceptance should complete within 500 ms at p95, and live totals should normally reflect accepted changes within 2 seconds.
- Finalization should complete within 30 seconds after closing or report pending partitions explicitly; it must never publish a knowingly incomplete final result.
- Vote events are retained for 7 days, while the final tally and its reconciliation metadata are retained durably.