EasyStarter

Poll & Survey Tool

DatabasesAPI DesignCaching

Problem Statement

QuickPoll lets anyone create a poll in seconds and share it via a link. Features:

- Create polls - add a question with 2-10 options. Polls can be single-choice or multiple-choice. Optionally set a closing date.Vote - anyone with the link can vote. No account required - use browser fingerprinting or optional login to prevent double-voting.Real-time results - after voting, see a live bar chart of results that updates as votes come in.Embed - polls can be embedded on external websites via an iframe.Creator dashboard - view all your polls, total votes, and export results as CSV.

Targeting 20,000 polls per day with 1 million votes per day.

What You'll Learn

Design a simple polling/survey tool where users create polls, share them, and see real-time results. Build this architecture under realistic production constraints, then validate tradeoffs in the design lab simulation.

DatabasesAPI DesignCaching

Constraints

Polls created/day~20,000
Votes per day~1,000,000
Vote recording latency< 200 ms
Results updateReal-time (< 2 seconds)
Max options per poll10
Availability target99.5%
ApproachClick to expand

Interview-Ready Approach

1) Clarify Scope and SLOs

  • Problem statement: Design a simple polling/survey tool where users create polls, share them, and see real-time results.
  • Design for a peak load target around 100 RPS (including burst headroom).
  • Polls created/day: ~20,000
  • Votes per day: ~1,000,000
  • Vote recording latency: < 200 ms
  • Results update: Real-time (< 2 seconds)
  • Max options per poll: 10

2) Capacity Planning Method

  • Convert traffic and growth constraints into request rate, storage growth, and concurrency budgets.
  • Keep at least 2-3x safety margin per tier (ingress, compute, storage, async workers).
  • Reserve explicit latency budgets per hop so p95 can be defended in review.

3) Architecture Decisions

  • Databases: Define a clear system-of-record and design read/write paths separately before adding optimizations.
  • API Design: Standardize API boundaries, idempotency keys, pagination, and error contracts first.
  • Caching: Put cache on hot read paths first and pick cache-aside or write-through explicitly.

4) Reliability and Failure Strategy

  • Use strong write constraints (transactions or conditional writes) and explicit backup/restore strategy.
  • Apply strict input validation and backward-compatible versioning.
  • Bound staleness with TTL + invalidation hooks for critical entities.

5) Validation Plan

  • Run one peak-load test, one dependency-degradation test, and one failover test.
  • Verify idempotency for all retried writes and async consumers.
  • Track user-facing SLOs first: p95 latency, error rate, and successful throughput.

6) Trade-offs to Call Out in Interviews

  • Databases: SQL gives stronger transactional guarantees; NoSQL often gives better write scaling and flexibility.
  • API Design: Rich APIs improve developer speed but can create long-term compatibility burden.
  • Caching: Higher hit rate cuts latency/cost, but stale data and invalidation bugs become primary risks.

Practical Notes

  • Increment vote counts atomically in the database (UPDATE polls SET count = count + 1).
  • For real-time results, use Server-Sent Events (SSE) - simpler than WebSockets for this one-way data flow.
  • Cache poll results in Redis with a short TTL to avoid hammering the database.

Learn the Concept

Practice Next

Reference SolutionClick to reveal

Why This Solution Works

Request path: The solution keeps ingress, service logic, and stateful dependencies separated so each layer can scale independently.

Reference flow: Web Clients -> API Gateway -> API Service -> Primary SQL DB -> Redis Cache

Design strengths

  • Cache sits on the read path to absorb repeated queries and keep DB pressure stable.

Interview defense

  • This design makes bottlenecks explicit (ingress, core compute, persistence, async workers).
  • It supports progressive scaling without re-architecting the core request path.
  • It keeps correctness-sensitive state changes in durable systems while offloading background work asynchronously.