← All projects
2023 — now
Real-time game backend
The server side of an online game with complex gameplay logic — stateful requests, background processing, analytics and real-time delivery, built to stay fast under load.
Also available in Русский
- Role
- Backend developer · server architecture
- Period
- 2023 — now
- Stack
- Python, FastAPI, PostgreSQL, Redis, RabbitMQ, Kafka, ClickHouse, MinIO, OpenTelemetry, Prometheus, Grafana, Docker, GitLab CI
- RPS sustained, stateful logic per request
- 100+
- RPS sustained, stateful logic per request
- p99 server-side latency
- < 50 ms
- p99 server-side latency
- peak headroom on current hardware
- 4×
- peak headroom on current hardware
The problem
In an online game almost every request changes state: it has to be validated, run through non-trivial rules, persisted and followed by background work — without slowing the player down and without ever applying the same action twice.
Approach
- Async Python — FastAPI with an async database layer and strict request and response schemas.
- PostgreSQL as the source of truth, Redis for caching and pub/sub, MinIO for files.
- Message queues for everything that can wait — the request does the essential work and returns, the rest is processed in the background.
- Analytics kept apart from gameplay — events stream into a column store, so reporting never competes with players for resources.
Practices
- Reliable event delivery — events are stored together with the state change and published only after commit.
- Retries with backoff and dead-letter queues — failures are retried and parked, never silently dropped.
- Observability from day one — traces, metrics and dashboards on every endpoint drive each optimization.
- Quality gates in CI — linting, type checks, unit, integration and end-to-end tests, plus regular load testing.
Results
The backend sustains 100+ requests per second where each request runs real game logic, keeps p99 latency under 50 ms and leaves roughly 4× headroom for peaks without new hardware.