One voter, two browser tabs, and the follow ups that turn a simple counter into a system design problem.
Maya votes for A, changes her mind, and votes for B. Her connection drops, so her phone sends the second request again.
If your system now counts four votes from three people, adding more servers is going to make the wrong answer arrive faster.
This is why I like this question. You can understand the product in 10 seconds, yet a perfectly respectable looking architecture can lose track of what one person actually chose.
The prompt is to design a 5-minute poll for millions of concurrent voters. People can change their choices, and everyone sees results that refresh every second. It appears in an Amazon-tagged interview report. This walkthrough is my proposed design, with illustrative numbers and follow ups, not a claim about Amazon’s production architecture or an interview I attended.
Let’s start with three people, because the first mistake fits comfortably on a napkin.
Maya changes her mind, and the total must stay three
Initially, Maya and Leo choose A while Nia chooses B. The totals are A = 2 and B = 1.
When Maya switches to B, the correct result becomes A = 1 and B = 2. We have changed a choice, not created another voter.
That gives us a rule worth writing above the diagram. Each eligible account contributes at most one current choice per poll. For this exercise, an account is our voter identity; preventing one person from creating several accounts is a separate abuse problem.
Store the current choice under the pair of poll ID and voter ID. Keep a version alongside it. A change needs to update that record, subtract from the previous option, and add to the new option as one indivisible operation.
Three independent writes are not enough. If the process stops after subtracting from A, Maya can disappear from the tally. If two requests both read her old choice, they can both subtract it.
For the starting design, put the voter record and affected counters in a transactional datastore. Enforce the old version as a condition of the transaction, so a change based on stale state cannot quietly succeed.
Try the Amazon-tagged live-voting question before reading further. Sketch what happens when Maya opens two tabs and submits a different choice from each. Mark the exact operation that prevents both tabs from spending the same old version.
Her second tab makes the easy answer uncomfortable
Suppose Maya currently has choice A at version 7. One tab asks to change to B using version 7. Another asks to change to C using version 7.
Whichever transaction commits first advances the voter record to version 8. The other must fail its version condition. Its counter changes must fail with it.
Now we have an important product decision. The losing tab should fetch the current choice and tell Maya that her selection changed elsewhere. It shouldn’t automatically resubmit an old intention against the new version and undo the winning request.
For this proposal, latest means the latest successfully committed change. We are not pretending to know which click Maya intended last across two devices. If the product wants a different ordering rule, agree on that rule before implementing it; client timestamps alone don’t establish a trustworthy global order.
AWS documents all-or-nothing transactional writes in DynamoDB. That is one possible building block. Capacity, transaction conflicts, key design, and the scope of those guarantees still matter.
A retry is not a fresh change of mind
Let’s return to the dropped connection. Maya’s move to B committed, but the response never reached her phone.
Give every intended change a stable request ID, scoped to the poll and authenticated voter. Derive voter identity from the authenticated session rather than trusting an arbitrary ID in the request. Persist its outcome with the successful vote mutation in the same transaction. A retry with that ID returns the recorded outcome rather than moving another vote.
Include the original request parameters in that record, or a fingerprint of them, so reusing the same ID for different content is rejected. Keep these records for the full retry window the API promises.
The request ID and voter version solve different problems. One identifies an operation we may have already completed. The other checks whether a new operation is still based on the current state.
An old, previously successful request can therefore return its historical success without overwriting Maya’s newer choice. Return its resulting version too, so the interface can recognize an older response and refresh current state when needed.
For a new request that selects the existing choice, keep the counters unchanged. You can still advance the version and record the result consistently. I think the important part is that a repeated selection doesn’t invent a new voter.
And you know honestly, this little sequence tells me more about the design than a page full of infrastructure logos.
Millions of viewers create a different bottleneck
Now give the napkin some traffic. Assume, just for sizing, three million accounts each submit one change over 300 seconds. That averages 10,000 mutations per second. Additional changes and a final-second rush make the peak higher.
If those same 3Mn million viewers request results once a second, that’s three million result requests per second. Reads and writes have very different shapes, so they shouldn’t all land on the same storage path.
A single counter for A can become a contention point even when voter records are distributed nicely. Split the counters into buckets and assign each voter to a stable bucket using a hash of poll ID and voter ID.
Maya’s current choice and her changes always use the same bucket during the poll. The transaction adjusts that bucket’s counters, and an aggregator adds the bucket totals together. Keep the mapping fixed for the poll; changing it midstream needs a migration protocol.
As an illustration, 100 evenly loaded buckets would average about 100 mutations per second each under our initial workload. That is arithmetic, not a capacity guarantee. Transaction costs, skew, bursts, and the storage engine determine whether that arrangement actually works.
Publish a small result snapshot once a second and deliver it through a cache and a scalable delivery tier. Polling through shared caches or pushing through connection gateways are both candidates. Neither makes the bandwidth or fan-out disappear.
Each snapshot should carry its generation time and version. During voting, we can agree that the display is a slightly delayed provisional view. An aggregate assembled from independently advancing buckets is not automatically an exact global snapshot.
Maya’s own confirmed choice can appear immediately in her interface while the public totals catch up. That’s a much nicer experience than making her guess whether the button worked.
The poll ends, but the last screen isn’t automatically the answer
At five minutes, the tempting shortcut is to freeze whatever the cache currently shows.
Please don’t make a potentially stale display decide the winner.
First define the cutoff.
In this proposal, eligibility depends on admission by the server before its enforced deadline, not when someone tapped a button on their phone.
Admission needs an authoritative policy for time and clock error; unrelated machines independently trusting their local clocks is not a complete closing protocol.
Then close admission and establish a barrier across the write path. Every request admitted before the cutoff must reach a terminal outcome, and no later request may sneak in.
Closing a webpage timer does none of that.
After the barrier is complete, recount the durable current choice records using a consistent view. Count each eligible voter once, compare with the maintained counters, and publish a versioned final result. If admitted work or a storage partition is unresolved, show that the result is being finalized rather than declaring the current cache exact.
That means the window for voting can end before the final result is ready. Agree on that delay as part of the product requirement. An immediate exact result during arbitrary failures is a much stronger promise.
Keep the receipt even if the scoreboard disappears
A success response must follow the durable commit of the vote and request outcome under the storage system’s stated failure guarantees. A fast write to a disposable cache is not enough.
In this design, the live cache is replaceable. If it disappears, rebuild snapshots from durable state. For an audit trail, an append-only change record can be written in the same transaction as the vote mutation. Don’t acknowledge a vote and hope a separate history write succeeds afterward.
During a partial outage, healthy partitions may continue accepting changes where the durability and deadline rules can still be enforced. If a partition cannot meet those rules, return a clear retryable failure instead of promising that an unprotected vote was accepted.
We can aim for high availability without claiming that every possible failure leaves every guarantee intact.
For practice, walk through the five cases in that table with a friend. After each one, say what the voter sees, what is durably recorded, and whether the displayed total is provisional or final.
That’s the progression I want from an interview answer.
Begin with a choice one person makes,
protect it through a retry and a race,
then scale the parts that actually need scaling.
If you can explain why Maya still counts exactly once after changing her mind twice, your architecture has something solid underneath all those boxes.
~ Emily





