Design an Online Voting Service
Design APIs and storage for creating bounded elections, accepting one eligible vote per voter, and publishing trustworthy results.
Problem statement
For this exercise, assume a trusted organizer creates an election with a fixed candidate list, an eligibility roster, and opening and closing times. Eligible authenticated voters use an API to cast one secret ballot, may retry safely after a timeout, and can see the final aggregate after the election closes.
An accepted voter ballot is immutable, each voter may contribute at most one ballot, and neither live partial totals nor individual choices are exposed. Design the API contracts and the supporting system; identity-provider internals and political-election certification are out of scope.
What to build
- A trusted organizer can create and publish a time-bounded election with fixed choices and an eligibility roster.
- An eligible authenticated voter can cast one immutable ballot and receive the same durable outcome when retrying the request.
- Clients can read election metadata and whether voting is not open, open, or closed without learning another voter's choice.
- After close, clients can read an aggregate whose counted total is reconcilable to accepted ballots while individual choices remain private.
At scale
- For this exercise, assume up to 10 million eligible voters in one election and a burst of 100,000 ballot attempts per second near closing time.
- For this exercise, target a ballot decision within 500 milliseconds at p95 in a healthy region, while correctness takes priority over availability for conflicting votes.
- For this exercise, an acknowledged ballot and the final aggregate must survive a process or availability-zone failure with no double counting.
- For this exercise, publish final results within five minutes after close and retain aggregate and audit metadata for one year without exposing individual ballot choices.