System Design: Scalable Coding Platform with Live Global Leaderboard
Context
Design a coding challenge platform (similar to LeetCode) where users submit code to be compiled and executed against test cases at scale. The system must provide a live global leaderboard that updates in near real time.
Assume:
-
Millions of users, with peak submission bursts (e.g., during contests).
-
Multiple languages/runtimes (e.g., Python, Java, C++), each with time/memory limits.
-
Hidden and public test cases; hidden cases must never be leaked to clients.
-
Fairness and isolation: untrusted user code must run in sandboxed environments.
Requirements
Design the system to address:
-
Test-case storage and distribution to executors.
-
Execution orchestration (compile, run, shard across test cases, aggregate results).
-
Message-queue fault tolerance (retries, idempotency, DLQs, ordering where needed).
-
Scalability and elasticity across services.
-
Live global leaderboard with low-latency updates.
Call out key APIs, data models, high-level architecture, and operational considerations.