NebulaRealtime
A server-authoritative multiplayer backend with matchmaking, WebSocket sessions and shared state coordination.
Tools Node.js · TypeScript · Fastify · WebSocket · Redis · PostgreSQL · BullMQ · Docker · Prometheus
Topics WebSockets · Redis · PostgreSQL · Real-Time · Distributed
- Player input
- Validate on tick
- Match history
One authority for match state
Clients send inputs over WebSockets. The simulation validates them and applies the updates on a fixed tick, so the server controls the resulting game state.
Coordination across instances
I used Redis for shared matchmaking and cross-server messages, BullMQ for background work, and PostgreSQL to persist match data. The repository includes a two-instance Docker Compose setup.
What the tests measured
I benchmarked individual endpoints and WebSocket behavior in a local Docker Compose setup. The health check was a lightweight HTTP workload. The raw files show slower authenticated endpoints and include errors and timeouts for those workloads.
Results from a local test
| Workload | Measured result |
|---|---|
| HTTP health check | 48,365 requests/s on one instance |
| WebSocket connection batch | 30 of 30 stayed connected |
| WebSocket ping/pong | 1.29 ms average, 13.91 ms p99 |
Local Docker Compose. The HTTP run used 100 connections over about 15 seconds. The ping test recorded 50 rounds. Benchmark scripts and raw results.
Development notes
Production-grade real-time multiplayer backend with horizontally scalable WebSocket servers, Redis coordination, matchmaking, and authoritative simulation. Load-tested to ~96K req/s across instances.
Built and scaled a real-time multiplayer infrastructure with WebSocket horizontal scaling, server-authoritative simulation, and comprehensive observability
The figures below are from the original project notes. See the local test table above for the workloads and results supported by the published raw files.
My responsibilities
- Designed and implemented full WebSocket scaling architecture
- Built matchmaking, presence, and leaderboard systems
- Integrated PostgreSQL persistence with BullMQ workers
- Load-tested and hardened for production deployment
Design & engineering concepts
- Horizontally scalable WebSocket architecture with Redis Pub/Sub coordination
- Server-authoritative game simulation preventing client-side cheating
- Distributed matchmaking with presence tracking across instances
- Production observability with Prometheus metrics and structured logging
Mechanics & implementation
- ~48K req/s single instance, ~96K req/s multi-instance proven capacity
- ~1.29ms average WebSocket RTT, ~1.98ms handshake latency
- 5K concurrent connection load profile with stable performance
- Distributed locks for race condition prevention
Lessons learned
- Real-time systems require careful state synchronization and conflict resolution
- Load testing early reveals scalability bottlenecks before production
- Observability is not optional for distributed systems
Problem
Real-time multiplayer systems must handle persistent connections, matchmaking, presence, state synchronization, concurrent actions, and scaling across multiple server instances.
System design
- WebSocket multiplayer infrastructure
- Horizontal WebSocket scaling
- Redis Pub/Sub
- Matchmaking and presence
- Server-authoritative simulation
- Leaderboards
- PostgreSQL persistence
- BullMQ workers
- JWT authentication
- Prometheus metrics
- Structured logging
- Rate limiting
- Distributed locks