KatInterview

Build a Live Programming Competition Judge at Scale

System DesignModel answer
MediumModel answerSystem Designsystem-designsandboxingmessage-queue

Last updated

Architect a platform where tens of thousands of contestants submit code during timed contests, with sandboxed grading, fast verdicts and a continuously updated ranking.

Build a Live Programming Competition Judge at Scale

You are asked to design the backend for a service that hosts timed programming competitions. Many people compete at once. Each contestant reads the problem set, writes a solution in a language of their choice, and sends it in. The platform runs that code against test cases the contestant cannot see, reports a verdict, and keeps a ranking table current for everyone.

What the system must do

  • Let users sign up for a contest and read its problems.
  • Accept solutions in several languages (for example Python, C++ and Java).
  • Run every submission inside an isolated environment so that hostile code cannot harm the platform or other users.
  • Keep a single, contest-wide ranking that changes as verdicts arrive.

Quality targets

  • Cope with a very large simultaneous load at the opening of a contest (think 50,000 active participants).
  • Return verdicts with low delay.
  • Stay healthy through sudden bursts of traffic.

What to deliver

  1. A written description of the overall architecture (components and data flow).
  2. API design covering submitting code and reading the ranking.
  3. Your approach to safely executing untrusted code.
  4. A data model for submissions and scoring.
  5. How you would scale the grading pipeline.

State your assumptions (scoring rules, contest size, submission rate) and justify the numbers you pick.

Hints

Hint 1

Start by fixing a scoring rule and a rough load estimate (participants, submissions per user, peak submissions per second, CPU time per grading run). These numbers decide how big the grading fleet must be.

Hint 2

Separate accepting a submission from judging it. A fast acknowledgement plus a durable queue lets you absorb bursts, and workers can be scaled independently of the web tier.

Hint 3

Treat all submitted code as hostile and layer defenses: a strong isolation boundary, resource caps, syscall filtering, no network, disposable environments. For the ranking, think about a structure that supports ordered insertion and rank lookup without sorting the whole table each time.