WhatNot: Design an Online Coding Practice Platform
Design a coding practice and judging platform with a problem bank, safe judging of untrusted submissions, and timed contests whose submission bursts and live ranking the system must absorb.
Problem statement
This is WhatNot's version of Design an Online Coding Practice Platform, built from WhatNot's interview reports.
Design an online coding practice and judging platform. Users browse a bank of programming problems, write a solution in the browser, and submit it. The platform runs the code against hidden tests and returns a verdict. It also hosts timed contests, where many users solve the same new problems at once and see a ranking.
For this exercise, assume:
Problems. The bank has about 5,000 problems. Each has a statement, a few visible examples, hidden tests, and time and memory limits. Users can filter the list by difficulty and topic. Problem pages are read far more often than problems change. Hidden test files can add up to 100 MB for one problem and are kept in file storage.
Submitting. A signed-in user picks one of 10 languages and submits code up to 64 KB. A submission moves from queued to running to a final verdict: accepted, wrong answer, time limit exceeded, memory limit exceeded, runtime error, or compile error. The user can close the page and look up the result later. If the browser retries a submit after a timeout, that must not create a second submission. Users never see hidden test contents.
Untrusted code. Submitted code may try to read files, open network connections, start many processes, use all memory, or never stop. It must not reach other users' code, the expected outputs, the platform's internal network, or any secrets. One bad submission must not noticeably slow down others.
Contests. A contest lasts 90 minutes and has 4 new problems that stay hidden until it starts. Up to 50,000 users take part. Users are ranked by problems solved, then by penalty time: for each solved problem, the minutes from the start to the accepted submission plus 5 minutes for each wrong submission before it. The ranking page shows the top 100 and the user's own rank, and may be up to 30 seconds behind.
Out of scope: running code on your own input, discussion forums, written solutions, paid plans, plagiarism checks, recommendations, tools for writing new problems, and running in more than one region.
What to build
- Users can list problems, filter them by difficulty and topic, and open a problem's statement, examples, limits and supported languages.
- A signed-in user can submit code in a supported language, and a retried submit never creates a second submission. The platform runs it against the hidden tests in isolation and decides one final verdict.
- A user can watch a submission move from queued to running to its final verdict, and find it later in their submission history.
- Users can join a timed contest, open its problems only once it starts, submit during it, and see the top of the ranking plus their own rank.
At scale
- For this exercise, assume about 1 million daily users and about 30 submissions per second on an ordinary day.
- For this exercise, assume that during a contest, 50,000 users open the 4 problems in its first minute, and submissions peak at about 1,000 per second near the start and the end. One run takes about 3 seconds of machine time across all tests.
- For this exercise, assume a verdict should be ready within 10 seconds at p95 on an ordinary day and within 30 seconds at p95 at a contest peak, and a saved submission and its final verdict must never be lost.