Katkat

Design an Online Coding Contest Platform

WhatnotSoftware Engineer · Technical Screen

Last updated

This problem tests your ability to design a distributed architecture for an online coding platform, focusing on secure code execution, high-concurrency submission handling, and real-time leaderboard updates.

Design an Online Coding Contest Platform

Design a system where thousands of users participate in real-time coding contests. Participants submit code in various languages, which must be executed against hidden test cases. The system must provide timely feedback and maintain an accurate, live leaderboard.

Functional Requirements

  • Users can register for contests and view problems.
  • Users submit solutions in multiple programming languages (e.g., Python, C++, Java).
  • The system must execute code in a sandboxed environment to prevent malicious activity.
  • A global leaderboard must update as submissions are graded.

Non-Functional Requirements

  • The system must handle high concurrency during contest starts (e.g., 50k concurrent users).
  • Submissions must be graded with minimal latency.
  • The system should be resilient to sudden spikes in traffic.

Deliverables

  1. High-level architecture diagram (described in text).
  2. API design for code submission and leaderboard retrieval.
  3. Strategy for secure code execution (sandboxing).
  4. Database schema for tracking submissions and scores.
  5. Discussion on scaling the grading pipeline.

Hints

Hint 1

Consider using an asynchronous message queue to decouple submission acceptance from the resource-intensive grading process.

Hint 2

Think about using containerization technologies like Docker or gVisor to isolate code execution environments securely.

Hint 3

For the leaderboard, evaluate if a traditional relational database can handle constant updates or if an in-memory data store like Redis would be more efficient.

Follow-up questions

  • How would you handle a scenario where a user attempts a Denial of Service attack by submitting an infinite loop or high-memory consumption script?
  • If the contest is global, how would you minimize latency for users connecting from different geographical regions?
  • How would you implement a fair 're-judging' mechanism if a flaw is discovered in a specific test case after the contest has started?