Think Beyond the Happy Path
Real production systems aren't just about running code submissions — they're about security, isolation, and scaling under pressure.
Before diving into the material, take a moment to ask yourself:
- Do you know how to safely execute untrusted user code without compromising system security or stability?
- Do you know how to isolate failures so that a malicious or buggy submission doesn't bring down the entire judging infrastructure?
- Do you know how to handle 10K concurrent submissions during a live coding competition, with results returned in under 5 seconds?
- Do you know the trade-offs between VMs, Docker containers, and serverless functions for code execution?
You don't need to answer all of these right away. A Senior/Staff+ Engineer doesn't stop at basic functionality — they anticipate edge cases, design for resilience, and push for production-grade reliability.
But great systems start with great questions. What would you ask next?
Problem Statement
Design a coding challenge platform like LeetCode that allows users to browse coding problems, write solutions in multiple programming languages, and receive automated judging results. The system should:
- Support viewing and searching coding questions by various criteria.
- Provide an in-browser IDE for coding solutions in multiple languages.
- Execute user-submitted code safely and return results within seconds. And the scale is up to 10,000 concurrent submissions with 5X peak capacity.
Functional Requirements
FR1 – View and Search Questions
Users should be able to view and search a list of coding questions based on difficulty level, topic/tag, question name, and completion status.
FR2 – Code Solutions
Users should be able to view a question and code a solution using an in-browser IDE that supports multiple programming languages.
FR3 – Submit and Judge
Users should be able to submit a solution and receive submission results (pass/fail, runtime, memory usage) from the automated judging system.
Non-Functional Requirements
NFR1 – High Availability
The system should be highly available for common operations including viewing/searching questions, accepting code submissions, and returning submission results.
NFR2 – High Scalability
The system should be scalable to support 10K concurrent submissions and handle peak loads of 5X during competitions.
NFR3 – Low Latency
The system should be efficient and return submission results within ≤ 5 seconds.
NFR4 – Security and Isolation
The system must support isolation and security when executing user-submitted code to prevent malicious code from compromising the infrastructure.
Security and isolation are critical non-functional requirements for LeetCode-like systems, particularly those using a scheduler-worker pattern. The fundamental principle is that each worker must operate in complete isolation, ensuring that a failure in one worker cannot affect others, effectively containing the "blast radius" to a single runtime environment. For code execution specifically, all user submissions must run in sandboxed environments with strict resource limits on CPU, memory, and network access to protect against malicious code. This isolation-first design is essential for maintaining system stability and preventing single points of failure from compromising the entire judging infrastructure.
Requirement Summary
| Functional Requirements (FRs) | |
|---|---|
| Name | Description |
1. View and Search Questions | Browse and search coding questions by difficulty, topic, name, or completion status. |
2. Code Solutions | Write solutions in an in-browser IDE supporting multiple programming languages. |
3. Submit and Judge | Submit solutions and receive automated judging results (pass/fail, runtime, memory). |
| Non-Functional Requirements (NFRs) | |
|---|---|
| Name | Description |
1. High Availability | System remains operational for viewing, searching, and submitting. |
2. High Scalability | Support 10K concurrent submissions with 5X peak capacity. |
3. Low Latency | Return submission results within ≤ 5 seconds. |
4. Security and Isolation | Execute untrusted code in isolated, sandboxed environments. |
Below the Line (Out of Scope)
Additional Features to Consider
While LeetCode offers many features, during system design interviews it's recommended to focus on core features first, then potentially expand into one or two additional domains where you have expertise. For example:
You could combine core features with:
- Competition/Leaderboard features (if you're experienced with real-time processing)
- Users should be able to join a competition;
- Users should be able to view the live leaderboard for a competition;
- Social features (if you're familiar with social media systems)
- Users can share a question with friends or post in other social media platform (Meta, LinkedIn etc);
- User can comment or like a question (and/or create their own "favorite list")
- Identity/Access Management (if you have security/authentication expertise)
- Register a user and buy premium (regular user vs premium);
- Premium users can see/practice more questions;
- Recommendation systems (if you have ML/recommendation experience)
- User can view their "submission history" (for a given time range);
- The system can recommend questions based on user preferences (and/or submission history);
- Others:
- The system should allow users to create/contribute a new question and/or add test cases;