Courses / System Design Interview / Chapter 41
Module 9 · Design Problems IV: Platforms and Money · Chapter 41 of 49
Design an Online Judge like LeetCode
Builds on Non-Functional Requirements: Availability, Scale, Latency and More, Back-of-the-Envelope Estimates, Databases: Choosing, Replicating and Partitioning, Distributed Caches, Distributed Message Queues, Rate Limiters, Blob Stores, Distributed Task Schedulers and Design a Messaging App like WhatsApp. Next up: Design a Calendar Service like Google Calendar.
Part 1 · Requirements and estimates
What the judge must do
An online judge takes a program written by a stranger, runs it against hidden tests and reports whether the answer was right. Contest days make the job hard: thousands of people press submit in the same few minutes, and every submission is code the service must treat as hostile.
The functional requirements are these. A user reads a problem and sends a solution in one of a few languages. The service runs it against the problem's tests and returns a verdict: accepted, wrong answer, time limit exceeded, memory limit exceeded, runtime error or, when the code does not build, compile error. Alongside the verdict it reports the number of the first failing test and the time and memory the program used. A user can also press Run, which checks only the sample tests and is cheaper than a full judging. In a contest, a leaderboard ranks the participants while the contest is still going. We leave out writing problems, discussion threads and plagiarism checks.