Multiplayer game events and live leaderboard
Stream player and match events through Redpanda, fan them out to a live leaderboard, an achievements service and a Postgres match history, and replay them on demand.
A game studio needs one event stream that feeds a live leaderboard, awards achievements, and keeps a queryable match history, without the services knowing about each other. This solution builds that system on Redpanda: a simulator produces Protobuf game events, three independent consumers read the same topics, and Redpanda Connect lands match history in Postgres with no code.
Steps
Architecture
Every service reads the same game.player-events and game.match-events topics through its own consumer group, so adding the achievements service later did not touch the leaderboard. Keys are player_id and match_id, which gives per-player and per-match ordering for free.
Prerequisites
-
Docker Desktop 4.30 or later with 8 GB of memory available
-
rpk24.3 or later -
Go 1.22 or later if you want to change the services
The environment file every service reads:
REDPANDA_BROKERS=localhost:9092
SCHEMA_REGISTRY_URL=http://localhost:8081
REDIS_ADDR=localhost:6379
POSTGRES_DSN=postgres://solutions:solutions@localhost:5432/matches
Production considerations
| Concern | What this solution does | What to change for production |
|---|---|---|
Brokers |
One broker, replication factor 1 |
Three brokers, replication factor 3 |
Security |
No TLS, no authentication |
TLS, SASL/SCRAM, ACLs per service |
Consumer scaling |
One instance per service |
Scale on consumer lag |