Sobes.tech
Senior

Design a matchmaking system for a chess platform. The input is User ID, and you need to find a pair of players with similar ratings. Load: 1 million registered users, 100 thousand DAU, 500-1500 concurrent game sessions at peak. What architecture would you suggest?

sobes.tech AI

Answer from AI

For a matchmaking system of a chess platform with a given load, the following architecture can be proposed:

  1. User and rating storage — use a fast and scalable NoSQL or in-memory storage (e.g., Redis) for quick access to ratings.

  2. Matchmaking queue — maintain a queue of players waiting for an opponent, grouped by rating with some tolerance (e.g., ±100 rating points).

  3. Matchmaking service — a separate microservice that:

    • Accepts User ID and rating.
    • Searches for a suitable opponent in the queue.
    • If an opponent is found, creates a game session.
    • If not, places the player in the waiting queue.
  4. Load balancing — use horizontal scaling of matchmaking services.

  5. Game sessions — a separate service for managing game sessions, which scales with the number of concurrent games.

  6. Caching and indexing — for quick search of opponents by rating.

  7. Monitoring and logging — to track performance and errors.

An example of simplified matchmaking logic in Go:

func findMatch(userID string, rating int) (opponentID string, err error) {
    // Pseudocode:
    // 1. Check the waiting queue within the rating range
    // 2. If an opponent is found — remove them from the queue and return
    // 3. Otherwise, add the current user to the queue
}

This approach will ensure a fast and scalable matchmaking system for the given load.

Design a matchmaking system for a chess platform. The… - sobes.tech