Katkat

Design an Online Coding Judge Platform

GoogleSoftware Engineer · Onsite

Last updated

This question tests the ability to design a high-throughput, secure, and fault-tolerant distributed system capable of executing untrusted user code in isolated environments.

Problem Statement

Design a scalable online coding judge platform (e.g., LeetCode, HackerRank) where users submit code for various programming languages to be evaluated against hidden test cases.

Functional Requirements

  • Users can submit code for a specific problem.
  • The system must compile and execute code against test cases.
  • Users receive results: 'Accepted', 'Wrong Answer', 'Time Limit Exceeded', 'Runtime Error', or 'Compilation Error'.
  • Users can view their submission history.

Non-Functional Requirements

  • Security: Code must run in a sandboxed environment to prevent malicious activity (e.g., file system access, network calls).
  • Performance: Execution should be fast, and the system should handle traffic spikes during coding contests.
  • Scalability: The system should support thousands of concurrent submissions.
  • Reliability: Submission results must be consistent and durable.

Deliverables

  1. High-level architecture diagram (described in text).
  2. API design for submission and result polling.
  3. Detailed approach for secure code execution (sandboxing strategy).
  4. Data model and storage considerations.
  5. Discussion on managing system load during peak traffic.

Hints

Hint 1

Consider decoupling the submission ingestion from the actual execution logic using a message queue.

Hint 2

Think about how to use containerization technologies like Docker or gVisor to provide resource isolation and security for untrusted code.

Hint 3

Address how to handle 'Time Limit Exceeded' by setting strict cgroup limits on CPU and memory usage for the execution process.

Follow-up questions

  • How would you optimize the system to reduce 'cold start' latency for compilers and runtime environments?
  • If you needed to support interactive problems (e.g., code that communicates with an external process), how would your architecture change?
  • How would you ensure fairness and prevent resource starvation if one user floods the system with massive, computationally expensive submissions?