Online Gaming and Sports Platform
As one of the core backend engineers on an online gaming and sports platform of about ten microservices, I designed and owned the player-facing market and bet-placement service in Go, and contributed across the rest of the platform, from the betting engine to the pipeline that turns every bet into live profit and loss for partners.
- Client
- Online gaming and sports platform
- Role
- Core backend engineer
- Year
- 2025
In brief#
I was one of the core backend engineers on an online gaming and sports platform, with real-money sports betting and casino games, built from about ten microservices. I designed and owned the service players use to see live markets and place bets, written in Go, and contributed across the rest of the platform, including the pipeline that turns every bet into live exposure and profit and loss for the partners who run accounts on it.
The challenge#
A betting platform has to show prices that change by the second, accept bets against them, reserve each player's funds exactly once, and settle every bet correctly once the result is known. Here, odds came from several sources: a third-party betting exchange, bookmaker (fixed-odds) markets and fancy (proposition) markets. Every bet also had to reach a hierarchy of partner accounts, each watching its own live profit and loss.
The platform had to hold up under the moments that matter most: many players watching the same live event, a burst of bets on a single market, settlements running while new bets arrive, and partners checking live profit and loss throughout a busy event. A design that works for one bet at a time fails in exactly those moments.
What I did#
The market and bet-placement service (designed and owned). I designed this service from the ground up in Go with the Fiber web framework, organized as one module per concern: exchange odds, bookmaker markets, fancy markets, live scores, live TV, accounts and authentication. Each module keeps its handlers, business logic and data access separate, so a new market source slots in without touching the others.
- Live event views. Building an event page means asking several sources at once. The service fetches exchange odds, bookmaker and fancy markets, scores and stream details concurrently, merges them, and applies each player's betting restrictions and stake limits before responding.
- Bet placement. Each market type has its own placement path. Before accepting a bet, the service checks that the market is still visible, that the player is allowed to bet, that the stake is within the player's caps, and that no settlement is running on the platform.
- Reserving funds safely. The player's stake is reserved against their balance per market, inside a Redis distributed lock with an expiry. Two bets arriving at the same moment are handled one after the other instead of racing for the same balance, and a crashed request cannot hold a lock forever. The service also handles cash-out.
- Handing off. Once a bet is accepted, the service publishes it to Kafka for the rest of the platform.
- Running it. Requests are traced with OpenTelemetry, the API is documented with Swagger, and CI builds each release as a container image pushed to Amazon ECR.
Live exposure and profit and loss. The aggregation service, also in Go, consumes bets placed, bets cancelled, market settlements and settlement rollbacks from Kafka, and keeps every user's exposure (the most they can lose) and live profit and loss for each market and outcome. Each accepted bet updates the player's exposure and profit and loss for that market, then rolls up through the partner hierarchy by every level's share of the risk, so each partner sees their own position as well as their players'. Many bets land on the same accounts at once, so concurrent updates can deadlock in the database; the service detects that and retries after a short, growing delay. Money is calculated in exact decimals, never floating point, and after settlement the service records client profit and loss, commission and net profit and loss for reporting.
The service is built to survive bad moments. Messages are processed by concurrent workers in batches, retried with exponential backoff, and moved to a separate failed topic that is reprocessed one message at a time, with a dead-letter queue as the last stop.
Across the other services. The platform's services covered users, accounts, the betting engine, odds aggregation, data streaming, fancy and bookmaker markets, the partner dashboard and sports navigation. I worked across them on the betting engine's fund reservations, accounting and commissions, on casino game integration, and on events between services over Kafka, Amazon SQS, Amazon SNS and AWS EventBridge.
Fixing the gaps between services. Some of the hardest bugs sat between services, where no single service's code looked wrong on its own:
- Missing markets. Some match-result markets never appeared. I traced it to the exchange feed attaching those markets to a competition-level placeholder event rather than to the match. The importer could not find that event, saved the markets without one, and a later repair job skipped them forever. I fixed the import so these markets resolve to the right match.
- Live events that never cleared. Finished events kept showing in players' live lists. When every bet on a market was cancelled, nothing marked the market as finished, and when a settlement message was dropped, the market stayed open. I made cancelling the last bet close the market, made a new bet reopen it, and added a three-layer guard to the query that builds the list.
- The shared data contract. I documented which keys each service writes and reads when a market is published or withdrawn, and the rule that readers validate cached data before trusting it, since partially written records can exist for a moment.
How it works#
Players bet through the market service, which reserves funds under a lock and publishes each bet; the aggregation service turns bets, settlements and rollbacks into live positions for every partner.
The market service is where players place bets, and Kafka is the boundary behind it. That split lets the player-facing path stay fast, doing only the checks and the reservation a bet needs, while the heavier work of updating every partner's position happens asynchronously and can be retried without the player waiting.
Results#
- A player-facing market and bet-placement service I designed and owned, with one module per market source and full request tracing.
- Concurrent bets on the same balance handled one at a time, and blocked while a settlement runs.
- Every bet, cancellation, settlement and rollback reflected in live exposure and profit and loss for each partner in the hierarchy, with failed messages parked for reprocessing rather than lost.
- The missing match markets appear for players, finished events no longer linger in live lists, and the contract between services is written down.
What I learned#
Put the money checks on the synchronous path and everything else behind a queue. A player needs to know the bet was accepted and the funds were held; they do not need to wait while every partner's profit and loss is recalculated.
When money moves through several services, design the failure path first. A reservation, settlement or commission that depends on a message arriving exactly once will, sooner or later, see it arrive twice or not at all, so retries, a failed topic and a dead-letter queue belong in the first version, not the third.
In a system of many services, the bugs live in the gaps between them. Reading another service's writer alongside your reader, key by key, finds problems that tests on either side never will.