# MatchMaker Module

## Overview

**Diarkis MatchMaker** is a high-performance, decentralized matchmaking system designed for online multiplayer games requiring **low-latency, real-time session coordination** at scale. Unlike traditional matchmaking solutions that rely on centralized databases or master servers, Diarkis MatchMaker utilizes a **distributed data-sharing model across the Diarkis server cluster**.

**Key Technical Characteristics:**

* **Decentralized State Storage:**\
  Match data is **dynamically distributed across multiple nodes** within the Diarkis server cluster, eliminating single points of failure and enhancing both **redundancy and availability**.
* **High Throughput and Low Latency:**\
  Designed for **fast player pairing**, the system supports high matchmaking concurrency with **minimal latency**, ideal for session-based or competitive multiplayer environments.
* **Fault Tolerance and Scalability:**\
  The distributed architecture enables **horizontal scaling**, allowing additional nodes to be added seamlessly without impacting system performance. In the event of a node failure, matchmaking continuity is maintained by rerouting tasks to other healthy nodes within the cluster.
* **Robust Query & Grouping Logic:**\
  Diarkis MatchMaker supports **customizable match logic**, including rule-based filters, dynamic prioritization, and conditional queueing for optimized player experience.

Diarkis MatchMaker is engineered for **resilient, real-time matchmaking in globally distributed systems**. For integration guidance, API endpoints, and cluster configuration options, please refer to the [**Diarkis Server API Documentation**](https://docs.diarkis.io/docs/server/current/diarkis/matching/index.html#hdr-Matchmaking_Rule_Examples).

### Comparative Analysis: Conventional Matchmaking vs. Diarkis MatchMaker

This section provides a technical comparison between **traditional matchmaking architectures** and the **Diarkis MatchMaker implementation**.

Conventional matchmaking systems typically rely on **centralized services or database-driven queues**, where a single or limited number of servers handle player matching logic and session coordination. These implementations often suffer from **scaling limitations, single points of failure, and bottlenecks** under high concurrency.

In contrast, **Diarkis MatchMaker** employs a **distributed, in-cluster matchmaking architecture**. Instead of centralized data storage, matchmaking state and queue data are **shared across multiple nodes** in the Diarkis server cluster. This design provides **horizontal scalability, fault tolerance, and reduced latency**, even at scale.

The comparison focuses on key operational dimensions such as **data distribution, failover behavior, throughput capacity, latency performance, and scalability**, offering a clear view of the architectural and operational advantages of Diarkis’ approach.

### Database-Driven Matchmaking

<figure><img src="https://3799879693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FryZ6XqKeHRZxcxMovWdn%2Fuploads%2Fgit-blob-2e4edec2f9ef11f18ef456340416714875d50203%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

In traditional **database-driven matchmaking systems**, player data (e.g., queue status, rank, region) is stored in a centralized database, and match generation is performed through **scheduled database queries** and **batch processing logic**.

**Technical Characteristics:**

* **Performance Bottlenecks:**\
  System scalability is inherently constrained by the **I/O performance, concurrency handling, and query efficiency** of the underlying database. As player volume increases, database contention can lead to **latency spikes and degraded throughput**.
* **Polling-Based Matching Logic:**\
  Matchmaking typically relies on **background worker processes** or cron jobs that poll the database at **fixed intervals** (e.g., every few seconds). This results in **non-instantaneous matchmaking**, introducing delays and reducing responsiveness under dynamic load conditions.
* **Data Partitioning and Isolation Issues:**\
  In multi-database deployments (e.g., sharded or region-based architectures), matchmaking across databases is not inherently supported. Players housed in **separate database instances** are **unable to match with each other**, limiting global matchmaking capabilities and reducing player pool efficiency.

This centralized approach, while simple to implement, lacks the **scalability, real-time responsiveness, and fault tolerance** required by modern multiplayer systems operating at global scale.

### In-Memory Matchmaking

<figure><img src="https://3799879693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FryZ6XqKeHRZxcxMovWdn%2Fuploads%2Fgit-blob-557041a1a50f5c11cff0e71626a8bbabdd12382f%2Fimage%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

In the **in-memory matchmaking architecture**, matchmaking state and operations are managed directly within a **front-end server**—a node responsible for both **client communication** and **match coordination**. All queue data, filtering logic, and matchmaking decisions reside in the server’s **local memory** (e.g., heap or cache layer).

**Technical Characteristics:**

* **Resource-Constrained Scalability:**\
  System scalability is limited by the **hardware and memory constraints** of each front-end server. As the matchmaking load increases, memory saturation or CPU contention can lead to degraded performance or service instability.
* **Single-Node Isolation:**\
  Matchmaking data is not shared between nodes. Clients connected to **different front-end servers operate in isolated matchmaking pools**, preventing cross-server pairing. This results in **fragmented player pools**, increased queue times, and inefficient resource utilization.
* **Tight Coupling with Session Lifecycle:**\
  Since matchmaking and session management reside on the same server, **failures or restarts** can lead to **loss of matchmaking state** or inconsistent client behavior.

While offering faster performance than polling-based database systems under small-scale conditions, the in-memory method lacks the **distributed state management, redundancy, and global coordination** required for large-scale, resilient multiplayer infrastructures.

### Diarkis MatchMaker – Advanced Architecture and Scalability

<figure><img src="https://3799879693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FryZ6XqKeHRZxcxMovWdn%2Fuploads%2Fgit-blob-cce5c9c4ab997201cb41054f03741571e301ddb4%2Fimage%20(2).png?alt=media" alt=""><figcaption></figcaption></figure>

**Diarkis MatchMaker** significantly outperforms traditional matchmaking systems by offering **near-infinite scalability, high concurrency, and fault tolerance** through its decentralized design. Unlike legacy approaches constrained by centralized databases or isolated memory stores, Diarkis MatchMaker operates on a **shared in-memory data model** distributed across all nodes in the server cluster.

**Key Technical Features:**

* **Cluster-Wide Shared Memory Architecture:**\
  Matchmaking data is stored in **redundant, distributed memory** across the entire Diarkis server cluster. This enables **ultra-fast matchmaking operations** as all nodes have access to up-to-date, synchronized state, eliminating the need for centralized lookups or polling.
* **Concurrent Operation Execution:**\
  Matchmaking operations are **executed on-demand** in real time. Unlike traditional systems that rely on scheduled background processes, Diarkis MatchMaker processes each matchmaking request **immediately**—yielding match results in **milliseconds to seconds**, depending on filtering logic and queue conditions.
* **Horizontal Scalability Without Boundaries:**\
  The system supports **dynamic scaling**—new nodes can be added or removed without downtime, and the matchmaking capacity scales linearly with cluster size. This enables seamless adaptation to fluctuating player volumes or regional expansion.
* **Global Match Pool Unification:**\
  Users are not isolated by server boundaries. Because matchmaking data is globally visible across the cluster, players connected to **different front-end servers can be matched together** seamlessly.
* **High Fault Tolerance and Redundancy:**\
  The absence of a **single point of failure** ensures that **node failures have no impact** on ongoing matchmaking operations. Redundant memory synchronization allows the system to reroute and recover instantly without loss of state or performance degradation.

Diarkis MatchMaker is engineered for high-performance, distributed multiplayer environments, providing a **scalable, fast, and resilient matchmaking layer** suited for global, real-time applications.

### Diarkis MatchMaker – Integrated Pre-Match Communication and Lobby Support

**Diarkis MatchMaker** includes a specialized capability that enables **real-time communication and state synchronization between matched users** prior to session initialization. This functionality is particularly well-suited for implementing **lobby systems** or **pre-game staging areas** within multiplayer games.

**Technical Details:**

Once a matchmaking operation completes and a group of users is paired, Diarkis MatchMaker allows these users to **enter a shared communication context** where they can **exchange messages and synchronize state changes** (e.g., avatar customization, equipment loadouts, team assignments) prior to actual game session deployment.

**Use Case Example:**

In a multiplayer game where players are matched but waiting to deploy, users can freely **chat, change their equipment, or update character appearance**, and those changes are **instantly reflected to all other group members**. This improves the user experience by allowing interactive pre-game engagement while preserving matchmaking integrity.

By integrating this capability, developers can build **rich, dynamic lobby systems** that maintain Diarkis' core advantages in **speed, scalability, and fault tolerance**.

### Diarkis MatchMaker – Dynamic Backfill Support

**Diarkis MatchMaker** provides robust support for **backfill matchmaking**, enabling dynamic population of game sessions **after they have already begun**. This feature is critical for maintaining **session integrity and player balance** in scenarios where users disconnect, leave prematurely, or when games are designed to allow continuous entry.

**Technical Overview:**

Backfill in Diarkis MatchMaker allows game sessions to remain in a **matchable state** post-initial launch. This means the system can **continuously monitor open slots** within active sessions and dynamically match new users to fill those positions, ensuring **optimal player count and balanced gameplay** throughout the session lifecycle.

* **Session Awareness:**\
  Active game instances register their current state (e.g., player count, roles needed, status flags) with Diarkis MatchMaker, which treats them as **eligible backfill targets**.
* **Live Matching Integration:**\
  New players entering the queue can be evaluated not only for new matches but also for backfill eligibility based on **session parameters, compatibility rules, and timing thresholds**.
* **Real-Time Join:**\
  Once matched, the new participant is **seamlessly integrated** into the ongoing session via Diarkis' low-latency network layer, ensuring minimal disruption to gameplay flow.

## Team Matchmaking

**Team Formation and Opponent Matching:**\
The system can execute **multi-stage matchmaking pipelines**, such as:

* **Team Assembly:** Grouping players based on rank, latency, roles, or predefined party structures.
* **Match Pairing:** Matching formed teams against each other according to custom logic or scoring algorithms.

<figure><img src="https://3799879693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FryZ6XqKeHRZxcxMovWdn%2Fuploads%2Fgit-blob-662ab931198979ed636f60ff0b0594357c0383fa%2Fimage%20(3).png?alt=media" alt=""><figcaption></figcaption></figure>
