Case 5
Ballots, Tallies, and Audits
Append ballots to an immutable log; aggregate counts in stream processors or materialized views.
Step-by-step walkthrough
Write path — cast ballot
- ① POST + Idempotency-Key — Voter submits once; retries return the same ballot ID, not a duplicate vote.
- ② INSERT ballot — Append-only row in ballot log; ballots are never UPDATEd in place.
- ③ ballot.cast event — Stream aggregator notified asynchronously to update live totals.
Read path — live totals
- ④ INCR choice_count — Aggregator increments precomputed counts in Redis on each ballot event.
- ⑤ GET /results — Results page reads materialized totals from cache — O(1) per choice, not a table scan.
Why these technologies?
ballottallyKafkaidempotencymaterialized viewRedispeak QPS