Design an online coding practice and interview platform (similar to well-known coding challenge sites).
The platform should allow:
-
Users to sign up, log in, and manage profiles.
-
Users to browse, search, and filter coding problems.
-
Users to write, run, and submit code solutions in multiple programming languages through a web-based editor.
-
Automatic judging of submissions against hidden test cases, with results (e.g., Accepted, Wrong Answer, Time Limit Exceeded).
-
Tracking of user statistics and progress (e.g., solved problems, difficulty distribution).
Requirements and considerations:
-
Functional requirements
-
Problem management: create, update, and categorize coding problems (by difficulty, topic, etc.).
-
Code execution: run user-submitted code safely and efficiently in isolated environments.
-
Submissions: store submission history and results per user and per problem.
-
Ranking/leaderboards: optionally show user rankings.
-
Non-functional requirements
-
High availability and scalability to support millions of users and high QPS during peak times.
-
Low latency for listing problems and fetching problem details.
-
Reasonable turnaround time for judging submissions.
-
Strong isolation and security for untrusted user code.
-
Constraints (assume)
-
Target: 5M registered users, up to 200k daily active users.
-
Peak: 10k code runs per minute.
Describe how you would design this system end-to-end. Talk about:
-
High-level architecture and major components.
-
Data modeling and storage choices.
-
Code execution and sandboxing, including how to scale the judge/execution layer.
-
Handling of traffic patterns, caching, and performance optimizations.
-
Key trade-offs and how you would evolve the design as traffic grows.