Book a free call

How Microservices Shape a Bitcoin Exchange Build

A bitcoin exchange on microservices splits trading, wallets, accounts and compliance into separate services, so one failure never stops the whole platform.

Hertiv engineering teamReviewed by a senior engineer
5 min read
How Microservices Shape a Bitcoin Exchange Build
On this page

Short answer

A bitcoin exchange built on microservices splits the platform into small services that each own one job: matching trades, holding wallets, checking identity, moving money and watching for fraud. Each service can be released, scaled and fixed on its own, so a wallet upgrade never takes trading offline and a traffic spike only scales the services under load.

What is a microservices bitcoin exchange?

A microservices bitcoin exchange is an exchange where the trading platform is built from many small services instead of one large application. Each service owns one job, keeps its own data, and talks to the others through defined interfaces.

The split matters because an exchange has jobs with very different needs. The matching engine must be fast and never lose an order, the wallet service must be slow and careful, and the sign-up flow must handle bursts of new users. One codebase cannot serve all three well.

Microservices let each team work on one service without waiting for the others. A release to the wallet service does not need a release of the whole exchange, and a bug in the reporting service cannot crash trading. For the basics, see what microservices are.

Which services does a bitcoin exchange need?

Most bitcoin exchanges split into the same core services, even when the names differ. The table shows the usual split and what each service owns.

ServiceOwnsWhy it is separate
Matching engineOrder book, tradesNeeds the lowest latency
Wallet serviceKeys, deposits, withdrawalsNeeds the strictest security
Accounts serviceUsers, balances, settingsChanges often, low risk
Compliance serviceIdentity checks, screeningRules change by country
Payments serviceBank transfers, cardsDepends on outside providers
Market data servicePrices, charts, feedsRead-heavy, easy to scale
Risk serviceLimits, fraud checksMust run before every trade

The matching engine is usually kept apart from everything else, sometimes on its own hardware, because a slow trade is a lost trade. For the wider build steps, see the crypto exchange development process.

How does the matching engine stay fast?

The matching engine stays fast by doing as little as possible. It holds the order book in memory, matches orders in price-time order, and writes results to a log that other services read later.

It does not call the wallet service or the compliance service while matching. Those checks happen before an order reaches the engine, or after the trade is done. A single network call inside the match loop would slow every trade, so the engine is kept free of them.

Most teams run one matching engine per trading pair, so a surge in one pair cannot slow the others. If the engine stops, trading pauses rather than producing wrong trades, and the log lets it rebuild the book when it restarts.

How do wallets and custody fit in?

Wallets and custody sit behind the strictest service in the exchange. The wallet service holds keys, signs withdrawals and tracks deposits, and it is the only service that can move bitcoin.

Hot wallets hold the small working balance that users withdraw from day to day, while cold wallets hold the bulk of funds offline. Moving funds between them is a manual or heavily gated process, not something any service can trigger on its own.

The wallet service talks to the rest of the exchange through signed requests, and every withdrawal passes a limit check and a second approval for large amounts. A bug in the accounts service or the market data service cannot reach the keys, because those services have no path to them.

How do services talk to each other?

Services talk to each other through two patterns: direct calls for things that need an answer now, and events for things that can wait. A trade needs a direct answer, so the matching engine calls the risk service synchronously. A deposit notification can wait, so the wallet service publishes an event that the accounts service picks up.

Events are recorded in a log that other services replay when they restart. If the accounts service goes down for ten minutes, it catches up from the log instead of losing deposits. This is what makes the platform survive a single service failing.

Each service keeps its own database, so a slow query in reporting cannot lock the trading tables. The trade-off is that a balance shown to a user may lag the real balance by seconds, which the interface should say plainly.

How to build it in six steps

Building a microservices bitcoin exchange starts with the boundaries, not the code. The steps below keep the split clean.

  1. Draw the service map. List the jobs, then draw a line where one job ends and the next begins.
  2. Build the matching engine first. It is the hardest part, so prove it works before building around it.
  3. Isolate the wallet service. Give it its own network, its own database and the strictest access rules.
  4. Define the events. Agree on the event names and fields before services start publishing them.
  5. Add compliance early. Identity checks and screening are harder to bolt on after launch.
  6. Test failure, not just success. Kill each service in turn and check that trading degrades safely.

Microservices suit a team that can run many services, with monitoring and deployment for each one. A small team may be better off starting with fewer, larger services and splitting later. For the architecture choice itself, see microservices vs monolithic architecture.

Example (hypothetical): a small exchange handles a surge

Example (hypothetical): a small bitcoin exchange normally handles 2,000 orders a minute. During a sharp price move, orders jump to 12,000 a minute for half an hour, and sign-ups triple at the same time.

The matching engine scales to six copies, one per pair, and keeps matching without slowing. The market data service scales too, so price feeds stay live. The wallet service does not scale, because withdrawals stay at their normal pace and the hot wallet balance covers them.

The arithmetic: 12,000 orders a minute for 30 minutes is 360,000 orders. If each matching engine copy handles 2,500 orders a minute, six copies handle 15,000, leaving headroom. The accounts service queues new sign-ups and works through them over the next hour, so nobody is turned away.

What are the common mistakes?

The most common microservices mistakes in an exchange are splitting too early, sharing databases between services, and letting the matching engine call other services. Each one is avoidable.

  • Splitting too early. A team of three cannot run twelve services well; start with fewer services and split as the team grows.
  • Sharing a database. Two services writing to the same tables recreates the monolith with extra network calls.
  • Calls inside the match loop. Any network call in the matching engine slows every trade.
  • No event log. Without a replayable log, a restarted service cannot catch up on missed deposits.
  • Weak wallet isolation. If any service can reach the keys, the custody model is already broken.

Key takeaways

  • Split the exchange by job: matching, wallets, accounts, compliance and payments
  • The matching engine must never call other services while it matches
  • Wallets stay behind the strictest service, with hot and cold balances separate
  • Events and a replayable log let services recover without losing deposits
  • Start with fewer services and split as the team grows

Frequently asked questions

Why use microservices for a bitcoin exchange?

Because the jobs have different needs: matching must be fast, wallets must be careful, and sign-ups must absorb bursts. Microservices let each job scale and release on its own, so a wallet upgrade never takes trading offline and a traffic spike only scales the services under load.

Is the matching engine a microservice?

It is usually run as its own service, often one copy per trading pair, and it is kept apart from everything else. It holds the order book in memory, matches in price-time order, and writes results to a log that other services read later.

How do microservices make an exchange safer?

They help only if the wallet service is isolated: it holds the keys, signs withdrawals, and no other service can reach them. Safety comes from that isolation plus approval rules and audit trails, not from the number of services.

What is the hardest part of the split?

Drawing the boundaries. If two services share a database or call each other in a loop, the split has failed. Agree on the service map and the event names before writing code, and test what happens when each service stops.

Should a small team start with microservices?

Usually not with a full split. A small team is better off with fewer, larger services and splitting as the team grows, because every service needs monitoring, deployment and on-call cover. The matching engine and the wallet service are the first two worth separating.

How do services stay in sync without a shared database?

Through events and a replayable log. When a deposit arrives, the wallet service publishes an event, and the accounts service updates the balance from it. If a service restarts, it replays the log to catch up instead of losing data.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: blockchain systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a crypto exchange and need the architecture right? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Crypto Exchange service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call