Design an Online Judge (LeetCode)

Online coding judge inspired by LeetCode and Codeforces: submissions saved and queued per language, untrusted code run in throwaway container sandboxes with no network and fixed limits, hidden test cases in object storage, verdicts polled from a cache, live contest rankings in a sorted set, and judges scaled ahead of contests. A teaching design.

Functional requirements

  • Users can browse and read problems.
  • Users can submit code in several languages and get a verdict (accepted, wrong answer, time limit, runtime error).
  • Submitted code runs in isolation and can never read hidden test cases or reach the network.
  • Users can see their past submissions.
  • Contests show a live ranking by problems solved and penalty time.

Non-functional requirements

  • Problem page latency: p99 < 300ms.
  • Verdict within 10 seconds for most submissions, even during contests.
  • Scale: 2M daily users; contests of 50K people submitting in the final minutes.
  • Availability: 99.9%; a submission once accepted is never lost.
  • Security: untrusted code is fully isolated from other submissions and the platform.

How the design evolves

Stage 1: Run Code on the Web Server

See why running untrusted code next to the website is the first thing to fix.

What was missing: Nothing yet.

Why that's risky: Submitted code is untrusted. An infinite loop ties up the server, a fork bomb takes it down, and code that reads the disk can leak the hidden test cases. Every page load waits behind running submissions.

What gets added: One server that serves problems and compiles and runs each submission on the same machine before replying.

Trade-offs: The simplest possible design. Isolation and capacity are both missing.

Stage 2: A Queue and Sandboxed Judge Workers

Take judging off the web tier and run every submission in an isolated sandbox.

What was missing: Untrusted code ran on the web server.

Why that's risky: Every problem page and every poll hits the databases, and hidden test cases are large files stored as rows.

What gets added: A submission service that saves each submission as queued and returns its id at once, a queue per language, and judge workers that run code in throwaway containers with no network and fixed CPU, memory and time limits. Clients poll for the verdict.

Trade-offs: Users wait a few seconds for a verdict instead of holding a connection open, in exchange for a website that never stalls.

Stage 3: Problems from a CDN, Test Cases in Object Storage

Serve the read-heavy pages cheaply, and keep big test files out of the database.

What was missing: Problem pages, verdict polling and test case reads all hit the databases.

Why that's risky: Contests have no live ranking, and nothing stops one user from flooding the judges.

What gets added: A CDN and a cache for problem pages, hidden test cases as files in object storage that judges cache locally, and a status service that answers polling from a cache the judges write to.

Trade-offs: Test case files are cached on judges, so an edited test needs a version bump to take effect.

Stage 4: Contest Rankings

Rank a live contest as verdicts arrive.

What was missing: No live contest ranking.

Why that's risky: One load balancer, and a single user can still submit as fast as they like.

What gets added: A sorted set per live contest, ordered by problems solved and then penalty time, updated by the judges as each accepted verdict lands. More judges for contest load.

Trade-offs: Rankings during the contest are provisional. Final standings are recomputed from the submissions database after hidden re-judging.

Stage 5: Rate Limits, Judge Scaling and Monitoring

Survive the last ten minutes of a big contest.

What was missing: No per-user submission limit, no spare load balancer, and no view of queue wait.

Why that's risky: Remaining risk is low. A very slow language can still build a backlog. Per-language queues keep it from delaying others.

What gets added: A rate limiter (a few submissions per user per minute), a second load balancer, judges that scale out on queue depth before a contest starts, a replicated submissions database, and monitoring of queue wait per language and verdict latency.

Trade-offs: Judges are scaled up ahead of scheduled contests rather than purely on demand, since containers take seconds to start.

PRISM
System Design Interview
Round 1 of 4 · Architecture Design · 60:00 remaining
PRISM logo
AI Interview
Interview Prep
Interview Challenges
Build & Stress Test NEW
System Architectures
Design & Fix NEW
Interactive Roadmap System Design Guides
Notifications
  • No new notifications
Feedback
Signed in
Send feedback
Phase
Build & Stress Test
Phase 01: Thinking in Systems
Upcoming

Components

User
CDN
Load Balancer
Server
Cache
Database
Blob Storage
Search Index
Queue
Worker
Rate Limiter
Service
API Gateway
Reverse Proxy
WebSocket Server
Third-party API

Inspector

Notes
Use clear names so your design intent is easy to understand.
Good
Name by business meaning
"Order API", "Restaurant Service"
Avoid
Generic names = zero signal
"Server 1", "API", "Queue"
A short description for each component makes feedback much better.
100%
Start by identifying:
  • Users & entry points
  • APIs & services
  • Databases & storage
  • Traffic flow & scale

Round 1 of 4 Architecture Design

Run a simulation to see results.

Time Remaining
60:00
System Design Interview

What are the core functional requirements?
What are the key non-functional constraints?

Questions

Start Evaluation to unlock questions.

EVALUATE MODE

Test yourself like it's the real thing.

A structured 4-module evaluation that mirrors how top companies assess system design candidates.

Architecture Design
Draw your system on the canvas. Define components, connections, and data flow.
FR & NFR Requirements
Answer functional and non-functional requirement questions about your design.
MCQ Round
Multiple choice questions testing your depth on the chosen system.
Tradeoff Analysis
Justify your design decisions and defend your architectural tradeoffs.
AI Report Generated
Choose a Problem
No problem selected
  • 30 min
  • 45 min
  • 60 min
Round 2 of 4
MCQ Round
Answer multiple-choice questions based on your design.

Exit Interview?

You're in the middle of an interview session. Leaving now will end your current attempt.

Your progress will be saved.

Open a saved design

Select a design to load into the canvas.

My Evaluations

Your past evaluation sessions

Here’s a simple request flow that follows the expected layer order.

External User
→
Edge CDN → API Gateway → Load Balancer
→
Compute App Servers / Services
→
DataAccess Cache
→
Storage Database / Search Index
→
Async Queue → Worker

Tip: keep arrows moving forward through layers (Edge → Compute → Storage). Avoid sending storage back to compute.

Evaluation Instructions

Read the rules carefully before starting. The test auto-submits on refresh.

Before you start

  • Build your architecture on the canvas. The timer starts when you click Start Evaluation.
  • Don't forget to answer Functional Requirement and Non Functional Requirements.
  • When satisfied with your design, click Next to lock it and view the questions.
  • Please answer final step questions to complete the evaluation.

Dos

  • Do read each question carefully before answering.
  • Do include required components to maximize component coverage.
  • Do save a copy of your design if you want to keep it before submission.

Don'ts

  • Don't refresh or close the tab during an active evaluation — this will auto-submit your answers.
  • Don't switch app modes or open another tab while the evaluation is running.
  • Don't attempt to edit the design after clicking Next; the workspace will be locked.

All the best!!

Confirm

Input

Notice

Evaluation Report

Evaluation Complete

Generating Your Report

Hang tight — our AI is evaluating your design…

Did you know?

Loading…

Share feedback

Tell us what worked well and what we can improve.

Let's personalize this

Answer a couple of quick questions so we can tailor your journey and missions.

Your welcome gift: of Full PRISM Access

You can change these answers from Mission Control until your missions are done.

Your personalized missions are ready

We tailored these first steps based on your answers.

    PRISM Welcome Gift

    This is a personal welcome gift from PRISM.

    Congratulations.

    You explored PRISM.

    You earned Apprentice.

    As a welcome gift, unlock Full PRISM Access for the configured trial duration.

    This starts Trial. Trial timer begins only after you activate this gift.

    Welcome to PRISM

    We've prepared a personalized Apprentice Journey based on your goals and experience.

    This journey introduces you to the capabilities of PRISM that are most relevant to you.

    Complete all 5 missions to earn your Apprentice title. 5 MISSIONS

    PRISM Surprise Offer

    Complete your Apprentice Journey to unlock a special gift from PRISM.

    • No payment required
    • No credit card required
    • Just complete the journey
    MISSION CONTROL
    0 / 8 missions complete
    NEXT UP Continue your missions
    View full roadmap →
    Mission Complete 0 / 8 Completed Next: Keep going
    SYSTEM BRIEF

    System Constraints

    What the system must do — every item is a user-facing behaviour your architecture must support.

      ↑ Engineering Constraints

      These are the failure modes you must design against — latency SLAs, durability targets, traffic ceilings.

        ⇆ Architecture Constraints

        Core Concepts to Master

        Your Journey
        PHASE – –
        0 / 0 0%
        0
        Mock Interview Checklist

        Pick a topic to start

        Explore concept overviews, real-system examples, key tradeoffs, and interview talking points for each roadmap section.

        Phase Mastered

        You've conquered this phase. These are the skills you now own:

          +500 XP

          Company Interview Paths

          Progress Summary