Design CanvasOpen the canvas

Design a Class Poll

A teacher shows a question on the screen and students vote on their phones. Everyone sees the question, casts a vote and sees the running tally. Most of the time the poll is idle. When the teacher opens a new question, the whole class votes within a few seconds, so many votes arrive at the same moment. Every vote must be counted: two students voting at the same instant must both be recorded, and no vote may overwrite another.

Constraints

  • A page must load within 300 ms in a quiet lesson
  • About 200 requests per second in a quiet lesson, and about 7 in 10 of them record a vote
  • When a question opens, traffic can reach about 6 times that for a few seconds
  • Two votes at the same moment must both be counted
  • Keep infrastructure under $1,900 a month

Scenarios to survive

Quiet lesson

A few students vote now and then.

Interviewer asks: Follow one vote from a student's phone to the database. Which step changes the stored tally, and who else might be changing it?

A question opens (6x)

The teacher opens a question and the class votes within seconds.

Interviewer asks: Many students vote in the same second. What stops two of them overwriting each other's vote, and what does that protection cost you?

What a good design must do

  • Pages load within the latency target in a quiet lesson
  • When a question opens, the poll keeps up and every vote is counted correctly
  • Total monthly cost stays within $1,900
  • A server records each vote in a database
  • The design explains how two votes at the same moment are both counted