May we use cookies so Meta, Google, LinkedIn and ChatGPT see your visit and we learn which ads work? PrivacyMay we use cookies to see which pages help, and let Meta, Google, LinkedIn and ChatGPT see your visit, so we know which of our ads work? That way we spend less on ads that do not work. We do not sell your data, and the site works the same if you decline. You can change your answer at any time under Cookie settings at the foot of the page. Privacy policy
Loading...
System Design and AI Engineering, by Roni Das. 989 interactive lessons in two courses.: 770 in System Design and 219 in AI Engineering.
Start LearningSystem design interview guide
in this guide
7 parts open to everyone · 3 with a free account · 3 with the course
You can read 7 of 13 parts. A free account opens the deep dive; the course opens all of it.
Interviewers like this problem because it looks like a simple CRUD app and turns out to be an operating-systems and distributed-systems question in disguise. It tests whether a candidate understands that you cannot just call docker run on a stranger's binary and hope for the best. A strong answer has to cover async job processing with a queue and worker pool, real resource isolation using kernel primitives, a threat model for untrusted code, fair scheduling so one abusive user or one contest does not starve everyone else, and the bursty load pattern of contests. Weak answers stop at the request-response API. Strong answers get into seccomp, cgroups, fork bombs, TLE detection, checker programs, and how the leaderboard stays consistent while thousands of verdicts land per second.
This page is the free part.
₹1,111 in India$35 everywhere elseonce, for the whole course
The System Design course covers the Online Judge design across a run of lessons, not one page. These 4 alone are about 95 minutes of step-by-step reading, 1 of them with code you run in the browser, all with a quiz.
Always clarify these in the first 5 minutes of the interview. Do not start drawing boxes until both lists are agreed.
This guide is built on these 5 lessons. Each one teaches one piece of the Online Judge design above, step by step.
Lifetime access for ₹1,111 in India or $35 elsewhere. Interactive diagrams, quizzes, and 20 capstone projects to practise on.
This one question is not enough for the interview.
Each question has why it is asked, a full answer, what the interviewer listens for, the follow-ups, the common mistakes and a diagram (268 diagrams in all). A PDF you keep, junior to staff level.
Two courses by the author of this page:
770 lessons · 18 free to read
₹1,111 in India · $35 elsewhere, once
Get System DesignYou own this course
219 lessons · 10 free to read
₹1,333 in India · $35 elsewhere, once
Get Generative AI and Agentic AIYou own this course
Save your progress and get the interview checklist PDF
A large online judge fields tens of millions of submissions a year, and almost none of that load is uniform. When a rated contest opens, thousands of people hit Submit in the same few minutes, so a queue that idles at a handful of jobs per second can spike past a thousand. Every one of those jobs is a stranger's program that you have to compile and run on your own hardware without letting it read the hidden tests, phone home, or take down the box. Figures here are illustrative estimates unless a source is cited.
An online judge accepts source code, runs it against a set of hidden test cases, and returns a verdict such as Accepted, Wrong Answer, Time Limit Exceeded, or Memory Limit Exceeded. The hard part is not the web app. It is executing untrusted code safely and cheaply at high concurrency. A submission is accepted quickly, persisted, and dropped onto a queue, then a pool of judge workers pulls jobs and runs each one inside a locked-down sandbox with hard limits on CPU time, wall time, memory, process count, and output size. The judge compiles the code, runs it test by test against stored inputs, compares output to the expected answer with a checker, and emits the first failing verdict. Results flow back through a results channel that the client polls or receives over a websocket. The interesting design pressure comes from contests, where a synchronized burst of submissions creates a thundering herd on the queue and the worker pool, and from security, where a single sandbox escape leaks every hidden test on the machine. Good answers treat isolation, back-pressure, and fair scheduling as first-class, not as an afterthought.
Where it shows up
Asked at Google, Meta, Amazon, and many competitive-programming and ed-tech companies such as LeetCode, HackerRank, Codeforces, and Codechef. It is a favorite for backend and infrastructure roles because it forces a candidate to reason about running untrusted workloads.
Spec sheetOnline Judge
worked through below, with the maths
The hard parts of this design are taught step by step in the System Design course: Message Queues, Auto-Scaling and Containerization.
Asynchronous processing lets a system accept work now and finish it later, so nobody waits. Sync vs async side by side, common patterns, and the costs.
Reuse threads instead of creating them, the pattern that makes web servers handle thousands of concurrent connections.
Protect your API from abuse and overload by controlling how many requests each consumer can make.
A cache stampede is many requests rebuilding expired keys at once. Single flight and TTL jitter, measured on one run: what each fixes and what it does not.
all part of
System Design Masterclass
770 lessons · about 290 hours · 18 free to read
₹1,111in India, by UPI
$35everywhere else, by card or PayPal
You own this course
Continue with Asynchronous Processingpay once,
yours for life
Live from the course bench
Real interview questions, live diagrams and measured lab results, pulled at random from the lessons. A new set every time you come back.
Show your math. Pulling numbers from thin air signals you have not thought about the load.
Baseline submissions per second
~10 to 30 submissions/sec
Estimate. Roughly 1 to 2 million submissions/day spread over active hours. 1.5M / 86400 is about 17/sec average, higher in the evening. This is the easy case.
Contest peak submissions per second
~1,000 to 1,500 submissions/sec
Derived estimate. If 100,000 contestants each submit a few times in the final rush, a 400,000-submission surge compressed into the last five minutes is 400000 / 300 which is about 1,330/sec, roughly 50x to 100x baseline.
Concurrent sandboxes at peak
~3,000 to 4,000 active sandboxes
Derived estimate. At 1,330 jobs/sec with an average judged runtime near 2 seconds per submission, Little's law gives 1330 x 2 which is about 2,660 in flight, rounded up for compile time and headroom to 3,000 to 4,000.
Judge worker machines needed at peak
~250 to 500 machines
Derived estimate. If a machine safely runs 8 to 16 concurrent sandboxes without CPU contention skewing time limits, 3,500 sandboxes / 10 per box is about 350 machines, which you pre-warm before a contest and scale down after.
Test case and problem storage
~a few TB
Estimate. Tens of thousands of problems, each with test suites from a few KB to hundreds of MB for heavy inputs. 50,000 problems x an average of 20 MB is about 1 TB, kept in object storage and cached on the judges.
Leaderboard read traffic during a contest
~100,000 to 200,000 reads/sec
Estimate. Contestants refresh standings constantly. 100,000 viewers polling every 1 to 2 seconds is 50,000 to 100,000 reads/sec, more with auto-refresh, which is why the board is served from cache, not the primary database.
A submission enters through an API gateway that authenticates the user, applies per-user rate limits, and hands off to a submission service. That service does the cheap work synchronously: validate the language and payload size, write a submission row in the primary database with status Queued, upload the source to object storage, and return a submission token. It then publishes a submission event to a durable queue, partitioned so that all of a single user's submissions stay ordered. A fleet of judge workers pulls from the queue. Each worker fetches the source and the problem's test bundle, warming a local cache so popular problems are not re-downloaded, then spins up a sandbox. Inside the sandbox the worker compiles the code, and if compilation succeeds it runs the binary once per test case under strict CPU, wall-clock, memory, process, and output limits. After each run it compares the program's stdout against the expected output using either an exact comparator or a custom checker, and it stops at the first failing test to save compute. The worker writes the final verdict and resource usage back to the database, updates the contest scoring stream, and publishes a result event. The client learns the outcome by polling the submission token or by receiving a websocket push. A separate leaderboard service consumes the scoring stream and keeps a cached ranking that thousands of viewers read without touching the primary store. A background plagiarism pipeline runs after the fact, comparing accepted submissions per problem.
In a real interview, sketch this on the whiteboard before diving into any single box.
Walk through each service. The interviewer wants to hear what each one owns, not just the names.
The front door. It authenticates, rate limits per user and per IP, validates the language and code size, persists the submission, uploads source to object storage, and enqueues a job. It returns fast and never blocks on judging, so intake stays available even when the judge fleet is backed up.
A durable message queue such as Kafka or a Redis-backed job queue sits between intake and judging. It absorbs contest bursts, decouples producers from consumers, and provides at-least-once delivery. Partitioning by user id keeps a single user's submissions in order and spreads load across many partitions.
Stateless workers that pull jobs, run them in a sandbox, and report verdicts. Workers are grouped or pre-warmed by language so a contest that is mostly C++ does not wait on cold Java toolchains. The pool auto-scales ahead of scheduled contests and scales down afterward.
The security core. Each run happens in an isolated environment built from Linux namespaces, cgroups, and seccomp filters, or a microVM for stronger isolation. It enforces hard limits on time, memory, processes, and output, blocks network access, and mounts the filesystem read-only so nothing leaks or persists between runs.
Object storage holds immutable, versioned problem bundles: inputs, expected outputs, checker binaries, and per-language limits. Bundles are content-addressed by hash so the judge can cache them locally and trust the cache. Large heavy-input problems are streamed rather than loaded whole.
Consumes result events, writes final verdicts, and for contests updates each user's score and penalty time. It must be idempotent so a retried job does not double-count. It publishes to the leaderboard stream and to any push channel that notifies the waiting client.
The leaderboard service maintains a cached, sorted ranking updated from the scoring stream and served to a flood of readers. The plagiarism service runs asynchronously, fingerprinting accepted solutions per problem and flagging similar pairs for human review.
submissions. One row per submission. status moves Queued to Running to a terminal verdict. source lives in object storage, not the row. Partition or shard by user_id; index by…
Every table for Online Judge, its keys, and which store fits it and why.
Sandboxing untrusted code. This is the heart of the system. You are running code written by anyone, including people actively trying to break out. The standard approach layers Linux kernel…
7 deep dives on the parts that break at scale: Sandboxing untrusted code; The queue and judge worker pool; The verdict pipeline: compile, run, compare.
Container sandbox such as isolate versus microVM such as Firecracker. Namespaces plus cgroups plus seccomp are lightweight and start in milliseconds, which is cheap per job but shares the host kernel, so a kernel exploit is a full escape…
6 decisions an interviewer expects you to defend, each with the alternative and why it loses here.
Mid-contest you discover that one hidden test case was wrong. What happens to submissions that were already judged?
4 follow-up questions with model answers, the interview scorecard for this question, and a mock interview on Design Online Judge with the AI tutor.
The building blocks here are real and open. Judge0 is a widely used open-source execution engine that runs submissions inside the isolate sandbox, supports more than 90 languages, and exposes an async submit-then-poll API with webhooks. Isolate itself was written for the International Olympiad in Informatics and relies on Linux namespaces, cgroups, and a read-only chroot to bound untrusted programs, which is the same recipe most judges use. Codeforces publicly documents its two-phase model, pretests during the round and full system tests after, precisely to survive contest-scale bursts. For stronger isolation, teams increasingly reach for Firecracker microVMs or gVisor instead of plain containers. On the anti-cheating side, Stanford's MOSS pioneered the tokenize-fingerprint-winnow approach that most code-similarity detectors still follow. None of these components is exotic; the engineering is in wiring them together so the queue absorbs the herd, the sandbox never leaks, and the leaderboard stays fast while thousands of verdicts land.
If any of these topics are fuzzy, the interviewer will catch it. Each lesson is 15 to 60 minutes with diagrams, code, and a quiz.
interview readiness
Three questions from this guide. Answer them without scrolling up, the way you would have to in the room.
Pay by UPI, cards or netbanking through Razorpay. Pay by card or PayPal, in US dollars. Download at once from My packs.
NEWSystem Design Hands-On
Postgres Sharding: Complete Hands-On (PgBouncer + Citus). 2 h 36 min and 20 chapters: one PostgreSQL loaded until it breaks, then four shards behind a router you write, PgBouncer and Citus, with the 139-page slide deck. The first 15 minutes are free to watch.
Free PDF · 79 pages
25 real tech interview questions, answered in full
Five from each of our AI, GenAI, Inference, Maths for ML and Forward Deployed packs. Each with a diagram and a model answer. Free by email.
free tool
Check these numbers yourself
Put in your own guesses for Online Judge and see requests per second, storage, bandwidth and servers, with every sum written out.
Open the Capacity EstimatorIt is really nice and good Please join the course