Microseconds matter: an architecturechecklist for trading systems

A trading system is judged on a bad day, not an average one. Seven questions we ask on every engagement that touches market data, order routing or execution, and the diagrams we draw to answer them.

Published
Updated
Read
11 min
Topic
TRADING SYSTEMS
A latency histogram with a tight tail, the shape every trading desk wants
A latency histogram with a tight tail, the shape every trading desk wants

A trading system is judged on a bad day, not an average one. The day the venue's feed hiccups, the day volatility triples, the day someone fat-fingers a quantity. Everything below is a question we ask on every engagement that touches market data, order routing or execution, whether the venue is an exchange, a crypto venue or an in-house matching engine. Most of them are cheap to answer early and ruinous to answer late.

I've written this as a checklist because that's how we use it. Draw the diagrams, answer the questions, and you will have found most of the problems before the first line of strategy code.

1. Where does the hot path actually run?

Draw the path from a market data packet arriving at the NIC to an order leaving it. Every hop is a cost, and every cost needs a name.

NIC inhw timestampDecodepinned coreStrategypure functionRiskpre-computed stateGatewaypinned coreNIC outhw timestampLatency budget (illustrative, total ≈ 30 µs)NIC in 2µsDecode 6µsStrategy 10µsRisk 4µsGateway 6µsNIC out 2µsNo allocations, no locks, no wall-clock reads between NIC in and NIC out.
Figure The hot path and an illustrative budget. Strategy and risk get most of the microseconds; everything else is plumbing that should barely register.
  • Kernel bypass or not. For sub-50 microsecond targets, user-space networking (DPDK, OpenOnload, a vendor stack) is table stakes. For a few hundred microseconds, a tuned kernel with busy polling is fine and far simpler to operate. Decide by target, not by fashion.
  • One core per role. Market data decoding, strategy, order gateway: each pinned to its own isolated core, with interrupts steered away. Shared cores are where jitter comes from.
  • No allocations on the hot path. Pre-allocated pools, fixed-size messages, arena allocators. A garbage collector or a surprise malloc is a hundred-microsecond stall waiting for the worst moment.
  • Lock-free queues between stages. Single-producer, single-consumer ring buffers, cache-line padded. A mutex on the hot path is a design error, not a tuning problem.

2. Is it deterministic?

If you cannot replay yesterday's tape and get yesterday's orders, you cannot debug a loss, prove best execution, or satisfy an auditor. This is the single highest-leverage property in the system, and the one teams most often skip because it feels like overhead.

Market dataTimersOperator cmdsSequencerone number per eventStrategypure · no clocks · no I/OOrderssequence-stampedJournal (immutable)replay harness → assert identical orders, in CI
Figure Sequence everything before the strategy sees it. The journal is the system of record; the replay harness proves the binary is honest.
  • Every input, whether market data, a timer or an operator command, is sequenced and logged before it is processed.
  • The strategy is a pure function of the sequenced inputs. No wall-clock reads, no random numbers, no reaching into a database mid-decision.
  • A replay harness runs the same binary against a recorded day and asserts identical output. It runs in CI, on every change.

Teams that skip this spend their nights reconstructing what happened from logs. Teams that have it run the replay and go home.

3. Where are the risk checks, and can they be bypassed?

Pre-trade risk lives between strategy and gateway, and nothing goes to the venue without passing through it:

  • Order size, notional, position and rate limits, per instrument and per strategy.
  • A kill switch any operator can hit and the strategy cannot override.
  • Fat-finger bands against the last traded price.
  • Checks that cost nanoseconds because they read pre-computed state, never a database.

The regulator's question is not "do you have risk checks". It's "show me the code path where an order could skip them". The answer should be that there isn't one.

4. Whose clock is it?

Latency numbers are meaningless without synchronised clocks, and an audit trail is inadmissible without them.

  • PTP (IEEE 1588) with hardware timestamping on the NIC, disciplined to a GPS or venue reference. NTP is for office laptops.
  • Timestamps at ingress and egress, in the packet path, not in application code that runs later.
  • Monotonic clocks for intervals, wall clocks for records. Never mix them. We have seen a negative latency in a report because someone did.

5. What does the data path look like after the trade?

The hot path is small. Everything around it is where the engineering hours go.

  • Market data capture to durable storage, with a schema that survives venue protocol changes.
  • Order and fill records written once, immutable, with the sequence numbers that tie them back to the inputs.
  • A time-series store for positions, PnL and latency histograms, queryable without touching production.
  • Reconciliation against venue drop copies, daily, automated, with a human on the exceptions and nowhere else.

6. How do you know it is slow?

Latency is a distribution. The average is a vanity metric.

Per-stage latency over a session, µsIllustrative
  • p99.9
  • p50
09:1510:0011:0012:0013:0014:0014:3015:0015:1515:3016:0016:30
Per-stage latency over a session, µs
Periodp99.9p50
09:1538µs18µs
10:0039µs18µs
11:0041µs19µs
12:0040µs18µs
13:0044µs19µs
14:0058µs20µs
14:3071µs21µs
15:0069µs21µs
15:1552µs20µs
15:3042µs19µs
16:0040µs18µs
16:3039µs18µs
Figure Alert on the tail. A p99.9 that doubles is the early warning; the mean will still look fine while customers are already losing.
  • Histograms per stage (decode, strategy, risk, gateway) with p50, p99 and p99.9, exported continuously.
  • Alerting on the tail, not the mean.
  • A latency budget per stage, written down, reviewed whenever it is breached.

7. Who can change it, and how?

Change management is where trading systems and compliance meet, and it is usually the last thing anyone designs.

  • Strategy parameters change through a reviewed, logged configuration path with limits. Never a hot edit on the box.
  • Binary releases are reproducible builds, deployed to a shadow instance against live data before promotion.
  • Every change traces to a ticket, a review and a replay run.

The checklist, compressed

  1. Hot path drawn, every hop costed, cores pinned, no allocations, no locks.
  2. Sequenced inputs, pure strategy, replay harness in CI.
  3. Pre-trade risk in the path with no bypass; a kill switch the strategy cannot override.
  4. PTP, hardware timestamps, monotonic clocks for intervals.
  5. Immutable records, a time-series store, daily reconciliation.
  6. Per-stage histograms, alerts on the tail, written latency budgets.
  7. Reviewed config path, reproducible builds, shadow deploys.

None of this needs exotic hardware. It needs a decision, taken before the first line of strategy code, that correctness and auditability are features with the same priority as speed. The systems built that way are the ones still running when the day gets interesting. If you're designing one, or inheriting one, our advisory engagements start with exactly this list.

TRADING SYSTEMSlow latency tradingHFT architecturekernel bypassdeterministic replaypre-trade riskPTP clock syncmarket dataorder management system

Start a project

Working onsomething similar?

Tell us what you are building. We reply within two working days with a point of view, not a sales deck.