Katkat

Design Online Chess Matchmaking and Clocks

OpenAISoftware Engineer · Technical Screen

Last updated

This question tests your ability to design a real-time game backend, focusing on low-latency state synchronization, fair matchmaking, and reliable clock management in a distributed environment.

Problem Statement

Design the backend architecture for a global online chess platform. The system must support two core pillars: a skill-based matchmaking service that pairs users of similar ELO ratings and an authoritative clock system that tracks remaining time for each move.

Requirements

  1. Matchmaking: Pair players who are waiting in a queue into 1v1 matches. Users should be grouped by ELO rating brackets that expand over time if no match is found.
  2. Game Clocks: Ensure clocks are authoritative to prevent cheating (e.g., local clock manipulation). Handle time increments and timeouts.
  3. Scalability: Support 100,000 concurrent active games and 50,000 users in the matchmaking queue during peak hours.
  4. Reliability: A player should be able to reconnect to a game in progress if their connection drops briefly without losing their remaining time or game state.

Deliverables

  • API Design: Define the necessary endpoints or WebSocket events for joining a queue, making a move, and requesting current game state.
  • Data Model: Propose a schema or storage strategy for user profiles, active game states, and match history.
  • Architecture: Explain the interaction between the Matchmaker, the Game Server/Engine, and the Client.
  • Trade-offs: Discuss how you handle clock synchronization and latency. How do you account for network lag when a player makes a move near the end of their turn?

Hints

Hint 1

Consider using a distributed message queue or a pub/sub mechanism to notify clients of state changes rather than polling the server.

Hint 2

Think about the difference between 'client-side time' and 'server-side time' and how the server must validate moves based on the server-recorded timestamp.

Hint 3

For matchmaking, evaluate the trade-offs between a centralized matching server and a sharded approach based on ELO ranges.

Follow-up questions

  • How would you handle a player who intentionally disconnects when they realize they are going to lose to avoid a rating penalty?
  • If the game engine needs to support millions of games simultaneously, how would you design a microservices architecture that isolates specific game instances?
  • What metrics would you monitor to detect if the matchmaking system is becoming unfair or if the latency is consistently exceeding acceptable thresholds?