Plateau, Nigeria
Architecture

Keeping every player on the same clock with Django Channels

LiveQuiz runs multiplayer quiz rooms in real time. The design choice that makes it fair: the server, not the browser, owns the timer.

August 30, 2026 1 min read Admin

A quiz played together has one hard requirement: everyone sees the same question and the same time remaining. If each browser runs its own countdown, players drift apart within a few questions, and a leaderboard fetched by polling is always a step behind.

LiveQuiz is built on Django Channels. Each quiz room is a WebSocket group, served by the Daphne ASGI server with Redis as the channel layer. When a host opens a room, the server draws the questions at random for the chosen education level, field of study, subject and topic, and holds the room's state: its questions, the scores so far and who has answered.

The countdown runs on the server. Each tick, each new question, each score update and the final leaderboard are sent to the whole group at once with a group broadcast. Browsers display what they are told; none of them decides when time is up.

The same state drives the rest of the room's behaviour. The number of questions and the time allowed come from the host's plan. Rooms lock after a short delay so players cannot join mid-quiz. Rooms can be grouped into a battle for team play.

Work that does not belong in a request runs in the background: APScheduler sends subscription expiry reminders and clears out old guest submissions, so guests can play without accumulating data forever.

The general lesson holds beyond quizzes: when several people must agree on what is happening right now, give one place the authority to say so, and push that to everyone.

Get new articles by email

Occasional notes on building and running business software.

Related reading