Skip to the guide

Design an online code judge (like LeetCode)

IntermediateCase study12 pages

People solve programming problems in the browser, press Submit, and within seconds learn whether their code passed hidden tests. Weekly contests put tens of thousands of them on the same problems at the same minute, with a live leaderboard. It's an exam hall where every candidate's answer is marked by a machine, in a locked room, on the same clock.

It's also asked as "design HackerRank", "design Codeforces" or "design a remote code execution service". Prep sites list it among Meta's product architecture questions (Hello Interview, as of 2026), where the API and what the page shows matter as much as the machines (The product architecture round). The closest page is Long-running work, which this design applies to judging. Interviewers like it because every submission is a stranger's program you have to run. It must run safely and fairly, survive a contest's first minutes, and count once.

Below is a full mock interview following the seven steps of the framework. You're the candidate: at each Guess before you read on, stop and answer first.

Step 1 · Clarify the features and cut the scope

Minutes 0–5 · How this step works

Interviewer: Design an online judge like LeetCode.

You: What does a user do? I'm assuming she reads a problem, writes code in the browser, and submits it to run against hidden tests.

Interviewer: Yes. She can also run it against her own input first.

You: How many languages?

Interviewer: About ten, from C++ and Java to Python and JavaScript.

You: Contests: how big, and how are they scored?

Interviewer: A weekly contest, 90 minutes, four problems, a live leaderboard. Ranked by problems solved, then time, with a penalty for wrong attempts.

You: Writing problems, discussions, premium plans?

Interviewer: Out.

You: Then I'll cover browsing problems, Run and Submit, judging with verdicts, contests and the leaderboard. Out: authoring, discussions, payments and editorials. OK?

Interviewer: Good.

Each answer shapes the design. Running strangers' code makes the sandbox the core, ten languages mean ten prepared environments, and a contest gives the peak a start time we know in advance.

Step 2 · Non-functional requirements

Minutes 5–8 · How this step works

You: Say 1 million daily users and 2 million practice submissions a day. A contest has 50,000 contestants (an assumption). A verdict arrives within 10 seconds of Submit at p99, contest peak included. Submitting works 99.95% of the time, and once we've answered "received", the submission is never lost. The same code gets the same verdict, with run times within ~5% run to run. Each submission is judged and scored once, and the leaderboard is at most 10 seconds behind.