Skip to content
Back to skills

Scaling Architecture

ASecurity

Use when the user asks about game server scaling, shards, zone servers, Agones, game server fleet autoscaling or game backend capacity. Produces fleet, persistence and region design with capacity math. Not for a single server tick loop (use authoritative-server) or generic web autoscaling (use devops-kubernetes-autoscaling).

  • 46 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 27, 2026
ai-agentsgokubernetesawsbackenddevops

Works with

  • cli

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned November 27, 2026

npx -y skills add j4flmao/agent-skills --skill scaling-architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Scaling Architecture?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Scaling Architecture
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/j4flmao-scaling-architecture/badge)](https://www.skillsdirectory.com/skills/j4flmao-scaling-architecture)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: scaling-architecture
description: >
  Use when the user asks about game server scaling, shards, zone servers,
  Agones, game server fleet autoscaling or game backend capacity. Produces
  fleet, persistence and region design with capacity math. Not for a single
  server tick loop (use authoritative-server) or generic web autoscaling (use
  devops-kubernetes-autoscaling).
version: "2.0.0"
author: "j4flmao"
license: "MIT"
last_verified: "2026-11-17"
tags: [game, scaling, server, infrastructure]
---

# Scaling Architecture — Deep Engineering Guide

## Purpose
From "hundreds playing" to "a million in a weekend": how the server fleet grows without breaking determinism, latency or cost. Skill covers zone/sharding, stateless matchmaking + stateful game pods, persistence, region/edge, observability and capacity/autoscaling.

## Agent Protocol

### Trigger
"game server scaling", "sharding", "zone servers", "agones", "game server autoscaling", "game backend capacity".

### Input Context
- Concurrent user targets and regions
- Session length and state size
- Hosting (bare metal, Kubernetes/Agones, cloud fleet services)

### Output Artifact
Fleet architecture and capacity plan. No file unless requested.

### Response Format
```
Topology: {services and pods}
State: {where it lives}
Capacity: {CCU per server, buffer}
Scaling: {trigger and policy}
```

## 1. The Scale Model (Start Simple, Grow Recursively)

```
Tier 1: one game server process + one lobby = 10–200 players
Tier 2: many per-region pods; lobby → matchmaker → pod (stateful), stateless elsewhere
Tier 3: zone-sharded (an open world is units of zones), state in DB, edge relay
```

The rule: **stateful = the game pod only; everything else stateless + horizontally scalable.**

## 2. Stateless vs Stateful

| Service | State? | Scale |
|---------|--------|-------|
| login / auth | token-cache only | stateless, autoscale |
| matchmaker / queue | KV session state | stateless, replica |
| lobby | KV per lobby | stateless, replica |
| **game pod** (sim + authoritative) | **in-memory world** | stateful, region pods |
| anti-cheat ledger | append-only store | stateless readers |

Stateless services scale by adding replicas (a load balancer + key reconciliation). The *game pod* can't split mid-match — the world is one authority. Match *size* and *zones* bound it.

## 3. Zone Sharding (The Open-World Pattern)

A huge world is divided into **zones** (usually map regions, ~200–1000 players each):

```
world = zone_A (pod A) | zone_B (pod B) | ... 
zone boundary: players crossing migrate (state transfer + connection handoff)
```

Each zone runs : authoritative sim + interest management (the IM skill) + a **boundary service** that exchanges the *edge band* (entities within N m of the boundary) so players see across seamlessly.

Migration protocol:
```
detect crossing → freeze at zone, hand serialized entity+connections
  → zone B takes over → client reconnects to zone B pod (token re-issue)
```
Use interest gating to keep the handshake *small* (only edge entities travel, not the world).

## 4. Region Routing & the Edge Band

- Region = a cloud region with its own pod pool (see `references/region-and-edge.md`).
- Player → nearest region (measured, not claimed).
- **Edge relay**: a regional UDP proxy in front of game pods — hides pod IPs (DDoS protection), lets players enter a private backbone close to home, and lets you move/replace pods without changing what clients connect to. It does not remove jitter; it can only shorten the public-internet part of the path.

```
client → edge relay (region-local) → game pod
```

### 4.1 The Two Bandwidth Paths

| Path | Purpose | Cost |
|------|---------|------|
| client → relay → pod | gameplay traffic | region-local, low |
| pod → relay → client | snapshots (interest-gated) | proportional to interest |

Keep the relay *stateless* (it forwards, doesn't decode) — a fleet of relays autoscale like any stateless tier.

## 5. State Persistence (The Durable Truth)

- **The world is ephemeral** (a match dies at end). Persist only: player account state (MMR, unlocks, inventory), match outcomes, cheat ledger.
- DB by shape:
  - MMR/inventory (per-player small) — KV/cache with snapshots.
  - Match outcomes (append) — timeseries/append.
  - Blob/demo archives (wire logs) — object store.
- **Golden player state** = DB row; the game pod holds a working copy, writes back on end/milestone (write-behind).
- Never have a pod *own the only copy* of a player's progression (pod dies → lose MMR).

```cpp
// end of match: worker flushes:
SaveProgress(playerId, {mmrDelta, unlocks, inventory})
// idempotent, versioned (optimistic lock per player)
```

## 6. Observability (See Everything)

Every service emits RED metrics (rate, errors, duration) plus queue depth:

| Layer | Tool shape |
|-------|-----------|
| logs | structured JSON, sampled at 1% (heavy paths) |
| metrics | counters + histograms (p50/p95/p99) per service |
| traces | distributed spans: matchmaker→lobby→pod→relay |
| profilers | tick-time histograms per pod (§ tick-loop) |

SLOs (examples):
- queue→match < 90s p95
- pod tick p99 < 5 ms
- relay drop < 0.5%

## 7. Capacity & Autoscaling

- Pods are **ephemeral**; capacity = "pods per region" decided by predicted DAU × match rate.
- On Kubernetes, Agones models this directly: `GameServer` (one match process), `Fleet` (a warm pool), `FleetAutoscaler` (buffer or webhook policy) and `GameServerAllocation` (the matchmaker claims a Ready server, which Agones then protects from scale-down until it shuts down). Managed alternatives include AWS GameLift.
- Autoscale signals: queue→match latency rising, pod CPU/bandwidth, relay capacity.
- Predictive: pre-warm pods for big events (launch, sale, weekend) from telemetry — *never* first-tick to scale.

```
capacity planner: 
  DAU → ccu curve → avg concurrent matches → pods(region)
  + headroom 20% + burst pod-provision latency scaled in
```

- **The "cheaper than a player-rush-DDOS" rule**: oversized headroom is cheaper than losing a launch.

## 8. Stateless/LB Patterns

- Load balancer routes by *region affinity* (sticky) + health checks.
- A stateless service must be **idempotent** (retry-safe): matchmaker formation, lobby ops, rating updates (see the matchmaking-lobby refs).

## 9. The Determinism + Scale Conflict

Scaling tempts you to split *within* a match (sub-sim). That breaks determinism (two pods disagree → desync). **Never split a match's sim.** Split matches (more pods) and (for open worlds) split the world into zones — but a single match = a single pod's sim, forever.

## 10. References

- `references/zone-and-shard.md` — zone partition, boundary migration, edge-band exchange, region-capacity
- `references/stateless-services.md` — stateless design, idempotency, replica scaling, LB affinity
- `references/state-and-persistence.md` — golden-state DB, write-behind, optimistic concurrency, durability
- `references/region-and-edge.md` — region routing, edge relays, bandwidth throttling, jitter absorb
- `references/observability.md` — metrics, traces, logs, SLOs, dashboards, cost of telemetry
- `references/capacity-and-autoscaling.md` — capacity math, predictive prewarm, autoscale signals, pods

Files in this skill

  • SKILL.md7.1 KB
  • references/capacity-and-autoscaling.md3.5 KB
  • references/observability.md3.5 KB
  • references/region-and-edge.md3.6 KB
  • references/state-and-persistence.md3.8 KB
  • references/stateless-services.md3.5 KB
  • references/zone-and-shard.md3.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.