Back to work
Sports Betting / Real-Time Systems2021

BoltBet — High-Concurrency Betting Engine

Role

Backend Engineer

Client

Personal Project

Duration

6 months

Context & Goals

Real-time sports betting platform built for high concurrency — async bet settlement via RabbitMQ DLX, Lua-based edge rate limiting with JWT blacklist in OpenResty/Nginx, idempotency patterns, and integer money arithmetic to eliminate floating-point errors.

Constraints & Challenges

Sports betting platforms face extreme concurrency spikes — thousands of simultaneous bets during live events, race conditions on bet settlement, and the risk of double-processing payouts. Standard HTTP request handling and floating-point money arithmetic are inadequate at this scale.

Solution & Approach

Designed an async settlement pipeline using RabbitMQ with Dead Letter Exchange for retry/backoff. Implemented Lua scripts in OpenResty (Nginx) for edge-level JWT blacklisting and rate limiting — keeping auth logic off the Node.js process entirely. Used integer arithmetic (pence/cents) throughout to eliminate floating-point rounding errors. Applied idempotency keys on all settlement operations to prevent double payouts.

Delivered a production betting engine handling high-concurrency live events with zero double-settlement incidents. RabbitMQ DLX handles failed settlements with configurable retry logic. OpenResty Lua scripts enforce per-IP and per-user rate limits at the edge. All financial operations use integer arithmetic and are fully idempotent.

Technology Stack

NestJSTypeScriptRabbitMQPostgreSQLPgBouncerRedisOpenRestyNginxLuaSocket.ioDocker

Results & Impact

  • Async RabbitMQ DLX settlement — zero double-payout incidents under load
  • Lua-based JWT blacklist and rate limiting at the Nginx edge layer
  • Integer money arithmetic throughout — no floating-point rounding errors
  • Idempotency keys on all settlement operations

Project Links

Interested in similar outcomes for your project?

Get in touch