FireDevOps FireMUD & Ops Projects

🧠 FireMUD System Architecture: Redis

This document outlines FireMUD’s usage of Redis as a transient, high-performance, distributed coordination layer. It focuses on Redis’s responsibilities, safety guarantees, key patterns, and operational practices.

πŸ”— For full tick execution, retries, and lock behavior, see Tick System and Runtime Design. Out-of-band workflows rely on the gRPC-based Saga approach described in Transaction Strategies.


⚠️ Redis as a Volatile State Layer

Redis is used exclusively for non-authoritative, transient data, including:

All canonical game data β€” accounts, entities, items, rooms β€” resides in PostgreSQL, owned by domain-specific services.

Redis acts as a coordinated real-time buffer, not a source of truth β€” but is still treated as critical for game availability and consistency.

The Game Session Service is responsible for coordinating tick and session behavior using Redis as its execution substrate.

βœ… Benefits


πŸ›‘οΈ Redis Availability, Consistency, and Safety Guarantees

Redis is a non-persistent layer β€” but FireMUD treats it as essential for consistent multiplayer behavior. Availability and deterministic recovery are prioritized.

Cluster Deployment

FireMUD runs Redis in a clustered, replicated configuration:

For operational context on Docker Compose vs Kubernetes, see Deployment Environments.

Replication and Durability


πŸ—‚οΈ Key Naming and Shard Discipline

Redis keys follow strict naming conventions to ensure:

Key Format Examples

Redis KeyDescription
tick:lock:{entityId}Lock for entity during tick execution
tick:pending:{regionId}Staged results for a tick region
room:{roomId}:occupantsRoom occupancy snapshot
retry:{regionId}Retry queue for failed actions
timer:{entityId}:{effectId}Cooldown/effect timer metadata (in ms)

πŸ“Œ For session-related keys and structure, see Session Keys and Gameplay Binding ⚠️ Tick regions and player sessions are always scoped to a single Redis shard to preserve atomicity. Cross-shard operations are avoided.


πŸ”’ Atomicity and Concurrency Control

Redis’s single-threaded model is extended using Lua scripts for atomic operations:

All Lua scripts are:

πŸ”— For use during tick execution, see Distributed Locking

Example Lock Workflow

  1. Acquire tick:lock:{entityId} using SET NX PX with a TTL equal to the tick duration.
  2. Stage updates under tick:pending:{regionId} via Lua script while the lock is held.
  3. On successful commit the lock is released and staged data is flushed.
  4. If the lock expires, the next tick replays tick:pending:{regionId} and attempts the workflow again.

⏱️ Tick Integration (Resilience, Locking, Staging)

Redis is essential for coordinating tick execution across distributed worker services.

It provides:

πŸ” Ticks are replayable and deterministic due to Lua-based staging, lock control, and AOF durability. πŸ”— See Tick Execution Flow

πŸ’₯ Crash and Recovery Safety

If a tick is interrupted:

All recovery is deterministic and safe.


πŸ“ˆ Observability and Reliability

FireMUD actively monitors Redis performance and tick health:

πŸ”— Redis observability feeds into the common stack described in Logging & Monitoring


🧠 Session Keys and Gameplay Binding

Redis stores transient gameplay session state for each connected player, including:

This state is used by the Game Session Service to:

πŸ” Key formats are internal and subject to change. Services treat Redis as a coordination layer, not a persistent or public contract.


βœ… Summary

Redis in FireMUD is:


πŸ“š Related Documentation