KatInterview

Design a Competitive Programming Practice Platform

System DesignModel answer
MediumModel answerSystem Designsystem-designdistributed-systemscode-execution

Last updated

Design a scalable web platform where users can browse coding problems, run code in a sandboxed environment, and receive automatic judgement across multiple languages.

Build a Coding Practice Platform

You are tasked with designing a web-based platform where developers can sharpen their algorithmic skills. The platform needs to handle two very different workloads simultaneously: serving content to millions of users, and safely executing untrusted code on their behalf.

What the platform does

  • Users register, authenticate, and maintain a profile.
  • Users browse a library of coding problems, filterable by difficulty and topic.
  • A browser-based code editor lets users write solutions in any of roughly 10 supported languages.
  • Users can run code against custom input and see output immediately, or submit code to be judged against a hidden test suite.
  • The judge returns a verdict: Accepted, Wrong Answer, Time Limit Exceeded, Memory Limit Exceeded, Runtime Error, or Compilation Error.
  • The platform tracks each user's submission history and overall progress (problems solved, difficulty breakdown, etc.).
  • An optional leaderboard ranks users globally or within a contest.

Constraints to assume

  • 5 million registered users, up to 200,000 daily active users.
  • Peak load: 10,000 code executions per minute.
  • Roughly 5,000 problems in the library; test data for each problem is order-of-megabytes.

What is expected

Describe the system end-to-end. Cover:

  1. High-level architecture — major components and how they interact.
  2. Data model and storage choices — what goes in a relational DB, what goes elsewhere, and why.
  3. Code execution and sandboxing — how you isolate untrusted code, enforce limits, and scale the judge fleet.
  4. Caching and read performance — how you keep problem browsing fast under load.
  5. Trade-offs and evolution — what you would change as the system grows, and what you would consciously defer.

You do not need to cover payments, collaborative live coding, or discussion forums.

Hints

Hint 1

Start by separating the two workloads: read-heavy CRUD (browsing problems, viewing profiles) and CPU-heavy untrusted compute (running/judging code). They have completely different scaling strategies, so the cleaner you separate them early, the easier the rest of the design becomes.

Hint 2

For the execution layer, think about what makes a sandbox trustworthy vs just convenient. Plain Docker shares the host kernel — what is a stronger boundary? Then think about warm pools: what is the cold-start cost of a JVM, and how do you avoid paying it on every submission?

Hint 3

Async is the right model for code execution — the client should get an ID immediately and receive results via WebSocket or SSE. Once you commit to async, think through the failure modes: what happens if a worker dies mid-job, and how do you avoid charging the user a submission attempt for an infrastructure failure?