Case study

Ronin Rush

Real-time multiplayer crash game, provably fair

p95 7 msin tests: k6 load test with 1,000 concurrent players

Live demo

Play-money demo: fictitious chips, no real money and no prizes. 18+. Play responsibly.

Cold start: the first load can take up to ~90 s while the server wakes up.

What it is and what it solves

A real-time multiplayer crash game: a ronin runs against an oni in 2D while every player decides when to cash out. The hard part is not the drawing but trust and money: outcomes must be verifiable, the clock must belong to the server and every chip must balance in a double-entry ledger.

Architecture

Ronin Rush: architectureHTTPS / WSoutboxBrowserNext.js 15 · PixiJSnginx / Ingress/ · /api · /socket.ioAPI #1 (leader)NestJS · round loopAPI #2 (relay)NestJSRedislease · live state · pub/subPostgreSQLledger · seeds · outboxKafkaronin.*.v1Platform Corehold · settle
  • Browser → nginx / Ingress (HTTPS / WS)
  • nginx / Ingress → API #1 (leader)
  • nginx / Ingress → API #2 (relay)
  • API #1 (leader) → Redis
  • API #2 (relay) → Redis
  • API #1 (leader) → PostgreSQL
  • API #1 (leader) → Kafka (outbox)
  • API #1 (leader) → Platform Core

Drawn from the architecture diagram in the repository README.

Three technical decisions

  1. Server-owned clock with a single leader

    One API instance holds a Redis lease and runs the round loop; the others relay. Cash-outs are priced at server time, so a slow or tampered client cannot cash out after the crash.

  2. SHA-256 seed chain + HMAC-SHA256

    Each round's crash point is precomputed from a seed whose hash is shown before betting and revealed afterwards, with a 1% house edge. HMAC-SHA256 uses the secret seed as the key over the round data, so the crash point is locked in before bets open and anyone can recompute it once the seed is revealed. A public verification page does exactly that.

  3. Double-entry ledger and Kafka outbox

    Stakes move between user, escrow and house accounts in balanced transactions; events are written in the same transaction and relayed to Kafka, so no event is lost or published for money that did not move.

Tests, with numbers

  • 1,000,000 simulated rounds matching the theoretical 0.99/x distribution.
  • 500 simultaneous bets and cash-outs with balances reconciled.
  • k6 with 1,000 players: p95 of 7 ms, measured with a probe client.
  • 8/8 failure tests against the real Platform Core: Core down mid-round, lost responses, self-exclusion.

Verified

  • Integrated with Platform Core /api/v1: hold, settlement intent and settle.
  • Public repository with CI on GitHub Actions.

Not claimed

  • Real-money operation or a third-party audit. All chips are fictitious.
  • Figures come from test runs, not from production traffic.

Stack

  • NestJS 11
  • Socket.IO + Redis
  • Next.js 15
  • React 19
  • PixiJS
  • PostgreSQL
  • Kafka
  • Docker
  • Helm
  • GitHub Actions
  • Vitest
  • Playwright
  • k6