home / skills / pluginagentmarketplace / custom-plugin-game-developer / game-servers

game-servers skill

/skills/game-servers

This skill helps design and optimize scalable game servers, matchmaking, and backend systems for robust online multiplayer infrastructure.

npx playbooks add skill pluginagentmarketplace/custom-plugin-game-developer --skill game-servers

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
13.5 KB
---
name: game-servers
version: "2.0.0"
description: |
  Game server architecture, scalability, matchmaking, and backend systems
  for online games. Build robust, scalable multiplayer infrastructure.
sasmp_version: "1.3.0"
bonded_agent: 05-networking-multiplayer
bond_type: SECONDARY_BOND

parameters:
  - name: architecture
    type: string
    required: false
    validation:
      enum: [dedicated, listen, relay, hybrid]
  - name: scale
    type: string
    required: false
    validation:
      enum: [small, medium, large, massive]

retry_policy:
  enabled: true
  max_attempts: 5
  backoff: exponential
  jitter: true

observability:
  log_events: [start, complete, error, scale_event]
  metrics: [player_count, server_count, match_time, queue_time]
---

# Game Servers

## Server Architecture Patterns

```
┌─────────────────────────────────────────────────────────────┐
│                    SERVER ARCHITECTURES                      │
├─────────────────────────────────────────────────────────────┤
│  DEDICATED SERVER:                                           │
│  • Server runs game simulation                              │
│  • Clients send inputs, receive state                       │
│  • Best security and consistency                            │
│  • Higher infrastructure cost                               │
├─────────────────────────────────────────────────────────────┤
│  LISTEN SERVER:                                              │
│  • One player hosts the game                                │
│  • Free infrastructure                                      │
│  • Host has advantage (no latency)                          │
│  • Session ends if host leaves                              │
├─────────────────────────────────────────────────────────────┤
│  RELAY SERVER:                                               │
│  • Routes packets between peers                             │
│  • No game logic on server                                  │
│  • Good for P2P with NAT traversal                         │
│  • Less secure than dedicated                               │
└─────────────────────────────────────────────────────────────┘
```

## Scalable Architecture

```
SCALABLE GAME BACKEND:
┌─────────────────────────────────────────────────────────────┐
│                     GLOBAL LOAD BALANCER                     │
│                            ↓                                 │
├─────────────────────────────────────────────────────────────┤
│                      GATEWAY SERVERS                         │
│            Authentication, Routing, Rate Limiting           │
│                            ↓                                 │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐        │
│  │ MATCHMAKING │  │   LOBBY     │  │   SOCIAL    │        │
│  │   SERVICE   │  │   SERVICE   │  │   SERVICE   │        │
│  └─────────────┘  └─────────────┘  └─────────────┘        │
│                            ↓                                 │
├─────────────────────────────────────────────────────────────┤
│              GAME SERVER ORCHESTRATOR                        │
│         (Spawns/despawns based on demand)                   │
│                            ↓                                 │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────────────────────────────────────────────┐   │
│  │ GAME SERVERS (Regional, Auto-scaled)                 │   │
│  │ [US-East] [US-West] [EU-West] [Asia] [Oceania]      │   │
│  └─────────────────────────────────────────────────────┘   │
│                            ↓                                 │
├─────────────────────────────────────────────────────────────┤
│                    DATABASE CLUSTER                          │
│  [Player Profiles] [Leaderboards] [Match History] [Items]  │
└─────────────────────────────────────────────────────────────┘
```

## Matchmaking System

```
MATCHMAKING FLOW:
┌─────────────────────────────────────────────────────────────┐
│  1. QUEUE: Player enters matchmaking queue                  │
│     → Store: skill rating, region, preferences             │
│                                                              │
│  2. SEARCH: Find compatible players                         │
│     → Same region (or expand after timeout)                │
│     → Similar skill (±100 MMR, expand over time)           │
│     → Compatible party sizes                               │
│                                                              │
│  3. MATCH: Form teams when criteria met                     │
│     → Balance teams by total MMR                           │
│     → Check for premade groups                             │
│                                                              │
│  4. PROVISION: Request game server                          │
│     → Orchestrator spawns or assigns server                │
│     → Wait for server ready                                │
│                                                              │
│  5. CONNECT: Send connection info to all players            │
│     → IP:Port or relay token                               │
│     → Timeout if player doesn't connect                    │
└─────────────────────────────────────────────────────────────┘
```

## Player Data Management

```csharp
// ✅ Production-Ready: Player Session
public class PlayerSession
{
    public string PlayerId { get; }
    public string SessionToken { get; }
    public DateTime CreatedAt { get; }
    public DateTime LastActivity { get; private set; }

    private readonly IDatabase _db;
    private readonly ICache _cache;

    public async Task<PlayerProfile> GetProfile()
    {
        // Try cache first
        var cached = await _cache.GetAsync<PlayerProfile>($"profile:{PlayerId}");
        if (cached != null)
        {
            return cached;
        }

        // Fall back to database
        var profile = await _db.GetPlayerProfile(PlayerId);

        // Cache for 5 minutes
        await _cache.SetAsync($"profile:{PlayerId}", profile, TimeSpan.FromMinutes(5));

        return profile;
    }

    public async Task UpdateStats(MatchResult result)
    {
        LastActivity = DateTime.UtcNow;

        // Update in database
        await _db.UpdatePlayerStats(PlayerId, result);

        // Invalidate cache
        await _cache.DeleteAsync($"profile:{PlayerId}");
    }
}
```

## Auto-Scaling Strategy

```
SCALING TRIGGERS:
┌─────────────────────────────────────────────────────────────┐
│  SCALE UP when:                                              │
│  • Queue time > 60 seconds                                  │
│  • Server utilization > 70%                                 │
│  • Approaching peak hours                                   │
│                                                              │
│  SCALE DOWN when:                                            │
│  • Server utilization < 30% for 15+ minutes                │
│  • Off-peak hours                                           │
│  • Allow graceful drain (don't kill active matches)        │
├─────────────────────────────────────────────────────────────┤
│  PRE-WARMING:                                                │
│  • Spin up servers before expected peak                    │
│  • Use historical data to predict demand                   │
│  • Keep warm pool for instant availability                 │
└─────────────────────────────────────────────────────────────┘
```

## 🔧 Troubleshooting

```
┌─────────────────────────────────────────────────────────────┐
│ PROBLEM: Long matchmaking times                             │
├─────────────────────────────────────────────────────────────┤
│ SOLUTIONS:                                                   │
│ → Expand skill range over time                              │
│ → Allow cross-region matching                               │
│ → Reduce minimum player count                               │
│ → Add bots to fill partial matches                          │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│ PROBLEM: Server crashes during peak                         │
├─────────────────────────────────────────────────────────────┤
│ SOLUTIONS:                                                   │
│ → Pre-warm servers before peak                              │
│ → Increase max server instances                             │
│ → Add circuit breakers                                      │
│ → Implement graceful degradation                            │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│ PROBLEM: Database bottleneck                                │
├─────────────────────────────────────────────────────────────┤
│ SOLUTIONS:                                                   │
│ → Add caching layer (Redis)                                 │
│ → Use read replicas                                         │
│ → Shard by player ID                                        │
│ → Queue non-critical writes                                 │
└─────────────────────────────────────────────────────────────┘
```

## Infrastructure Costs

| Scale | Players | Servers | Monthly Cost |
|-------|---------|---------|--------------|
| Small | 1K CCU | 10 | $500-1K |
| Medium | 10K CCU | 100 | $5K-10K |
| Large | 100K CCU | 1000 | $50K-100K |
| Massive | 1M+ CCU | 10000+ | $500K+ |

---

**Use this skill**: When building online backends, scaling systems, or implementing matchmaking.

Overview

This skill explains game server architecture, scalability, matchmaking, and backend patterns for building robust multiplayer infrastructure. It provides practical guidance on server types, orchestration, matchmaking flow, player session handling, auto-scaling triggers, and common troubleshooting. Use it to design reliable, cost-aware online game backends.

How this skill works

The skill inspects common architecture patterns (dedicated, listen, relay) and maps them to scalable backend components: global load balancer, gateway services, matchmaking/lobby/social microservices, orchestrator, and regional game servers. It describes matchmaking flow from queue to provision to connect, outlines player session caching and updates, and defines scale-up/scale-down triggers and pre-warming strategies. It also summarizes operational best practices and troubleshooting steps for latency, crashes, and database bottlenecks.

When to use it

  • Designing multiplayer server architecture for a new online game
  • Implementing or improving matchmaking and session provisioning
  • Scaling game servers to handle regional or global CCU growth
  • Reducing matchmaking latency and improving match quality
  • Planning infrastructure costs and capacity ahead of launches
  • Troubleshooting peak load issues and database bottlenecks

Best practices

  • Choose server model based on security and cost: dedicated for authoritative state, relay for NAT traversal, listen for small social games
  • Use gateway servers for auth, routing, and rate limiting before match services
  • Keep matchmaking tolerant: expand region/skill range over time and respect party constraints
  • Orchestrate game servers with autoscaling and a warm pool to reduce provisioning latency
  • Cache player profiles for short durations and invalidate on updates to cut DB load
  • Drain instances gracefully; never kill active matches during scale-down

Example use cases

  • Competitive shooter: dedicated regional servers, strict match balance, pre-warmed pool before tournaments
  • Casual co-op game: relay servers for NAT traversal, party-friendly matchmaking, lower infrastructure cost
  • Massively concurrent MMO zones: orchestrator spawning regional fleets and DB sharding by player ID
  • Mobile slot-based matches: short-lived game servers, aggressive autoscale triggers based on queue time
  • Live event rollout: pre-warm capacity using historical peak predictions and circuit breakers to protect services

FAQ

How do I reduce long matchmaking times?

Expand acceptable skill range over time, allow cross-region matches, reduce minimum party size, or use bots to fill partial matches.

When should I pre-warm servers?

Pre-warm before known peak hours, events, or launches using historical demand; keep a warm pool for instant provisioning to avoid queue spikes.