Stock Exchange Order Matching System Design Template
Exchange core: order book with price-time priority, matching walk-through, sequencer and replicated journal, deterministic engines, risk checks, market data, FIX references
How to use: Use it when designing or interviewing on an exchange or matching venue. Fill the market model (order types, priority, replace rules) and the peak message rate first, then write down the determinism rules. The main pitfall is letting the engine read clocks, random numbers or account state, which breaks replay and failover.
Preview
System Design: [Exchange or matching venue name]
Reference design for the core of an electronic exchange: order entry gateways, pre-trade risk checks, a sequencer that puts every input in one total order, single-threaded deterministic matching engines that keep a limit order book per instrument with price-time priority, and a market data feed. It names the FIX Trading Community specifications that such venues commonly expose (FIX Latest application messages, the FIX session layers and Simple Binary Encoding) as references only, sizes the system with worked numbers, and covers replication, recovery by replay and the failure behaviour of each component. It follows the structure of the System Design Document template, adds a 45-minute interview path, access-pattern and failure-mode tables and a cited "How real systems do it" box, and is pre-filled with a worked design to adapt. Replace every
[bracketed]value and every row marked Example; values marked Example are assumptions, not benchmarks. Market rules and regulation differ by jurisdiction; this is a design format, not legal or regulatory advice, so check the current official texts and qualified counsel.
Document control
| Field | Value |
|---|---|
| Document ID | [SDD-MATCH-001] |
| System / feature | [Continuous trading and order matching] |
| Version | [0.1] |
| Status | [Draft / In review / Approved / Implemented / Superseded] |
| Owner | [@owner] |
| Author(s) | [@author] |
| Reviewers | [@reviewer-1], [@reviewer-2] |
| Last updated | YYYY-MM-DD |
| Classification | [Confidential] |
| Difficulty | Advanced |
| Market model version | [MM-2026-01] |
| Protocols exposed | [FIX Latest over FIX session layer; binary order entry with SBE] |
| Related | [Rulebook], [Clearing interface spec], [ADR: sequencer replication] |
Approvals
| Role | Name | Decision | Date |
|---|---|---|---|
| Head of trading technology | [@name] | [Approved / Changes requested] | YYYY-MM-DD |
| Market operations | [@name] | [Decision] | YYYY-MM-DD |
| Risk management | [@name] | [Decision] | YYYY-MM-DD |
| Compliance | [@name] | [Decision] | YYYY-MM-DD |
| SRE / operations | [@name] | [Decision] | YYYY-MM-DD |
| Security | [@name] | [Decision] | YYYY-MM-DD |
Revision history
| Version | Date | Author | Change summary |
|---|---|---|---|
| 0.1 | YYYY-MM-DD | [@name] | First draft for design review |
| 0.2 | YYYY-MM-DD | [@name] | Example: Moved risk checks before the sequencer to keep the engine free of account state |
| 0.3 | YYYY-MM-DD | [@name] | Example: Added snapshots every 5 minutes to cap replay time at 60 s |
| 1.0 | YYYY-MM-DD | [@name] | Example: Approved |
Contents
1. Overview
1.1 Problem statement
[Example: The venue's current matching platform runs on a shared relational database with row locks per order book. At the market open, order acknowledgements reach 40 ms at p99, two members reported executions in a different order from their submissions, and recovering from a node failure took 25 minutes of manual reconciliation. The venue plans to list 10 000 instruments and must handle a peak of 1 million order messages per second.]
1.2 Proposed solution
[Example: Members connect to order entry gateways that authenticate, decode and run pre-trade risk checks. Accepted messages go to a sequencer that stamps each with a 64-bit sequence number and a timestamp, writes it to a replicated journal and only then releases it to the matching engines. Each engine owns a partition of instruments, runs on one thread, keeps the order books in memory and is fully deterministic, so a primary and a hot standby that read the same sequence produce the same executions. Engine output feeds execution reports to members, a multicast market data feed and the clearing interface. Recovery is snapshot plus replay of the journal.]
1.3 Decisions requested from reviewers
| ID | Question | Recommended option | Section |
|---|---|---|---|
| Q-01 | Example: Where are pre-trade risk checks? | In the gateway tier, before the sequencer | 7.4 |
| Q-02 | Example: How is the journal made durable? | Quorum of 3 sequencer nodes in the primary site, asynchronous copy to the DR site | 7.3 |
| Q-03 | Example: How do engines fail over? | Hot standby engines replaying the same sequence; output compared by hash | 7.3 |
| Q-04 | Example: What does a replace do to priority? | Keeps priority only for a quantity decrease at the same price | 7.1 |
| [Q-nn] | [Question] | [Option] | [Section] |
1.4 45-minute interview path
Use this order when the document serves an interview or a short design review. The written sections below are the long form of each step.
| Minutes | Cover | Output on the whiteboard |
|---|---|---|
| 0 to 5 | Scope: limit and market orders, cancel and replace, executions, market data; below-the-line items (2.3) | Order types and the priority rule |
| 5 to 10 | Estimates: peak messages per second, hot instrument rate, book size, journal size (section 3) | "Book fits in memory, one thread per partition" consequence |
| 10 to 15 | Interface: new order, cancel, execution report, market data message (section 4) | Four messages |
| 15 to 25 | High-level design: gateway, risk, sequencer, engine, market data (section 6) | One diagram |
| 25 to 40 | One deep dive: the order book and matching (default, 7.1 and 7.2), or determinism and recovery (7.3), or market data (7.5) | Options, choice, reason |
| 40 to 45 | Failures (engine crash, sequencer failover, feed gap), the 10x row in section 10 | Two failure rows |
Start the default deep dive by drawing a small book: two sides, price levels sorted best first, a first-in first-out queue of orders at each level. Walk one aggressive order through it (7.2) and then ask what would happen if two threads matched the same book at once. That leads to the single-writer engine and the sequencer.
2. Requirements
2.1 Core functional requirements
| ID | Requirement | Priority |
|---|---|---|
| FR-01 | Example: Accept limit and market orders, buy or sell, with time in force Day, IOC (immediate or cancel) and FOK (fill or kill) | Must |
| FR-02 | Example: Cancel and replace resting orders | Must |
| FR-03 | Example: Match continuously by price-time priority; trade at the resting order's price | Must |
| FR-04 | Example: Send an execution report for every accept, reject, fill, partial fill and cancel | Must |
| FR-05 | Example: Publish order-by-order market data and periodic book snapshots | Must |
| FR-06 | Example: Pre-trade risk: credit limit per member, maximum order size, price collar around a reference price | Must |
| FR-07 | Example: Halt and resume trading per instrument; mass cancel per member on request or on disconnect | Must |
| FR-08 | Example: Self-trade prevention by member-supplied group ID | Should |
| FR-09 | Example: Post-only orders that are rejected if they would trade on arrival | Should |
| [FR-nn] | [Requirement] | [Must / Should / Could] |
2.2 Non-functional requirements
| ID | Quality | Target | Measured as |
|---|---|---|---|
| NFR-01 | Latency | Example: order in to acknowledgement out, p50 20 µs, p99 100 µs at the gateway network ports | Hardware timestamps on capture taps |
| NFR-02 | Throughput | Example: 1 million order messages/s sustained for 60 s | Replay of a recorded open at 2x speed |
| NFR-03 | Fairness | Example: Matching order equals sequencer order for 100% of messages | Replay comparison |
| NFR-04 | Determinism | Example: Primary and standby output hashes equal at every checkpoint | Continuous hash comparison |
| NFR-05 | Durability | Example: No acknowledged order or execution lost on any single node failure | Chaos test |
| NFR-06 | Recovery | Example: Engine failover under 1 s; cold restart under 5 min | Quarterly failover drill |
| NFR-07 | Time accuracy | Example: Event timestamps traceable to UTC within the tolerance set by the applicable rules | Clock monitoring |
| [NFR-nn] | [Quality] | [Target] | [Measurement] |
2.3 Below the line (out of scope)
Name these explicitly so reviewers and interviewers do not pull the design toward them.
- [Example: opening and closing call auctions (a later release; same engine, different matching phase)]
- [Example: clearing, settlement and margin (the clearing house receives a trade feed)]
- [Example: options, multi-leg and implied orders]
- [Example: member onboarding, billing and surveillance analytics (consume the journal offline)]
- [Item deferred, with the release that will take it]
3. Capacity estimation
3.1 Assumptions
| Input | Symbol | Value | Source |
|---|---|---|---|
| Instruments | Example: 10 000 | Listing plan | |
| Trading day (continuous session) | Example: 6.5 h = 23 400 s | Rulebook | |
| Average order messages per second | Example: 50 000 | Comparable venues, member forecasts | |
| Peak order messages per second | Example: 1 000 000 (20x average) | Recorded opens | |
| Share of peak in the busiest instrument | Example: 5% | Concentration analysis | |
| Trades per day | Example: 25 million | Forecast | |
| Inbound message size, binary | Example: 64 B | SBE schema draft | |
| Market data message size | Example: 40 B | Feed schema draft | |
| Resting orders at peak | Example: 5 million | Member forecasts | |
| Memory per resting order incl. indexes | Example: 128 B | Prototype measurement | |
| Messages one engine core handles with journaling | Example: 500 000/s | Prototype benchmark | |
| Replay speed from journal | Example: 5 million messages/s | Prototype benchmark |
3.2 Message rates
Trades: per second on average, about 2% of messages. Most traffic is new orders and cancels that never trade, so the engine is optimised for insert and cancel, not only for matching.
Busiest instrument at peak: messages/s, so one thread has per message for that instrument. One core per instrument partition is enough as long as matching takes a few microseconds; no instrument needs to be split across threads.
3.3 Engines
The 0.5 factor keeps engines at or below 50% busy at peak so queues stay short. The design uses 8 partitions so the hottest instruments can be spread and a partition can move without overloading another.
3.4 Memory, journal and market data
Order books: across all partitions, so every book lives in memory with room to spare.
Journal: , about 225 GB/day with three copies, and about 18.9 TB per year of 252 trading days for one copy. Retention follows the venue's record-keeping rules.
Market data: . At peak, per feed, 640 Mbit/s for the A and B copies. Multicast makes this independent of the number of subscribers.
3.5 Recovery time
A full-day replay takes s. With a snapshot every 5 minutes, the worst case is 5 minutes of peak traffic, s of replay, which meets the cold restart target. Hot standbys do not replay at all; they are already current.
A 64-bit sequence number at messages per second lasts about 585 000 years unsigned (about 292 000 years as a signed 64-bit integer), so it never wraps.
3.6 Summary
| Quantity | Estimate | Design consequence |
|---|---|---|
| Peak messages | 1 million/s | Binary protocol, kernel-bypass networking, no database on the hot path |
| Busiest instrument | 50 000 messages/s | One thread per partition is enough; never split one book |
| Engines | 4 minimum, 8 partitions chosen | Partition by instrument, with headroom for hot names |
| Book memory | ~0.64 GB | All books in memory, snapshots to disk |
| Journal | ~75 GB/day per copy | Sequential append on local NVMe, replicated |
| Market data | 320 Mbit/s peak per feed | Multicast A/B feeds plus retransmission service |
| Replay | 60 s worst case with 5-minute snapshots | Cold restart inside 5 minutes |
4. API design
4.1 Interfaces
| Interface | Protocol | Purpose |
|---|---|---|
| Order entry (FIX) | FIX Latest application messages over the FIX session layer, TLS (FIXS) where required | Members with standard FIX engines |
| Order entry (binary) | SBE-encoded messages over a FIXP-style session | Latency-sensitive members |
| Drop copy | FIX execution reports | Member risk and back-office systems |
| Market data | Multicast UDP, A and B feeds, plus TCP retransmission and snapshot channels | Public order-by-order data |
| Clearing feed | Trade messages in sequence | Clearing house |
| Admin | Authenticated internal API | Halts, instrument setup, member limits |
FIX message types named for orientation (check the FIX Latest definitions before implementing):
| Purpose | FIX message | MsgType (tag 35) |
|---|---|---|
| New order | NewOrderSingle | D |
| Cancel | OrderCancelRequest | F |
| Cancel and replace | OrderCancelReplaceRequest | G |
| Acknowledgement, fill, reject, cancel confirm | ExecutionReport | 8 |
4.2 Internal message after the gateway
Gateways convert both protocols to one internal fixed-size message. Prices are integers in ticks; floating point is never used for prices or quantities.
{"seq": 418220931, "ts_ns": 1793433600123456789, "type": "new", "member": "MBR-0042", "client_order_id": "c-77120", "instrument": 1207, "side": "buy", "ord_type": "limit", "tif": "day", "price_ticks": 1003, "qty": 400, "stp_group": "G-3"}
4.3 Rejects and idempotency
| Case | Where rejected | Response |
|---|---|---|
| Malformed or unauthenticated message | Gateway | Session-level reject |
| Credit limit, size or price collar breach | Gateway risk check | ExecutionReport with reject reason |
Duplicate client_order_id in the session | Gateway | Reject as duplicate; original state unchanged |
| Instrument halted | Engine | ExecutionReport reject; market data shows halt |
| Cancel of an unknown or filled order | Engine | Cancel reject |
The member's client_order_id is unique per session and day, which makes
resends after a reconnect safe.
5. Data model
5.1 Entities
The journal of sequenced inputs is the source of truth; books, executions and market data are all derived from it by the deterministic engine.
5.2 Storage choices
| Data | Store | Key | Main queries | Why |
|---|---|---|---|---|
| Order books | Engine memory | Instrument, side, price level, FIFO queue | Best price, walk levels, cancel by order ID | Microsecond access; single writer |
| Order lookup | Engine memory hash map | order_id | Cancel and replace in O(1) | Avoid scanning a level |
| Journal | Append-only files on local NVMe, replicated to 2 peers | seq | Replay from a sequence number | Sequential writes, total order |
| Snapshots | Files per partition, copied to object storage | Partition, seq | Restore books, then replay | Caps replay time (3.5) |
| Executions and orders for members | Downstream database fed from engine output | member_id, date | Drop copy, end-of-day reports | Never on the hot path |
5.3 Access patterns
| Access pattern | Frequency | Key or index that serves it | Partition key rationale |
|---|---|---|---|
| Match an incoming order | Up to 1 million/s at peak | Best opposite price level, then FIFO queue | Partition by instrument: one book is touched by one thread only |
| Cancel or replace | Most of the traffic | order_id hash map to the order node | Same instrument partition; O(1) unlink from the level |
| Publish book change | Every book change | Sequenced output event | Output keeps engine order per partition |
| Replay after failure | Rare | Journal from snapshot seq | Partition journals can replay in parallel |
| Member asks for order status | Occasional | Downstream database by member_id and client_order_id | Keeps queries off the engine |
6. High-level design
| Component | Responsibility | Scales by |
|---|---|---|
| Order entry gateways | Sessions, decode, throttle, duplicate check | Members per gateway |
| Pre-trade risk | Credit, size and price collar checks per member | With gateways (member state is local to its gateway) |
| Sequencer | Total order, timestamps, journal, replication | Vertical; one leader with quorum replicas |
| Matching engine | Books, matching, deterministic output | Instrument partitions |
| Output sequencer | Merge partition outputs with their sequence numbers | Vertical |
| Market data publisher | Encode and multicast, snapshots, retransmission | Feed channels |
7. Detailed design
The deep dives in this section, each with options, choice and reason:
| Deep dive | Options considered | Choice | Reason | Section |
|---|---|---|---|---|
| Order book structure | Sorted tree of levels, array indexed by tick, skip list | Array of levels around the reference price with a tree fallback, FIFO list per level, order ID map | O(1) for best price, insert and cancel in the common range | 7.1 |
| Concurrency | Locks per book, actor per instrument, single thread per partition | Single thread per partition fed by the sequencer | No locks, deterministic, cache friendly | 7.2, 7.3 |
| Durability and failover | Database commit, local journal only, replicated journal with standbys | Quorum-replicated journal, hot standby engines | No acknowledged input lost; sub-second failover | 7.3 |
| Risk checks | In the engine, in the gateway, separate service | In the gateway, before the sequencer | Keeps the engine free of account state | 7.4 |
| Market data | TCP per subscriber, multicast with recovery | Multicast A/B with sequence numbers, snapshots, retransmission | Fair, scalable, recoverable | 7.5 |
7.1 Order book and market model
- Priority: best price first; at the same price, earliest sequence number first (price-time priority).
- Trade price: the price of the resting (passive) order.
- Replace: a quantity decrease at the same price keeps priority; a price change or a quantity increase takes a new priority sequence.
- Structure per instrument and side: price levels in an array indexed
by
price_ticks - base, sized to cover the price collar, with a sorted tree for the rare level outside it; each level holds a doubly linked FIFO list and its total quantity; a hash map fromorder_idto the list node gives O(1) cancel. - Best price is cached and updated on insert, fill and cancel.
7.2 Matching walk-through
Example: sell side of instrument 1207 before the order arrives (tick size 0.01, prices shown in currency units):
| Order | Side | Price | Quantity | Priority seq |
|---|---|---|---|---|
| S-1 | Sell | 10.02 | 100 | 1001 |
| S-2 | Sell | 10.02 | 200 | 1005 |
| S-3 | Sell | 10.03 | 300 | 1002 |
Incoming B-9: buy limit 400 at 10.03, Day.
| Step | Resting order | Fill quantity | Fill price | B-9 remaining |
|---|---|---|---|---|
| 1 | S-1 (best price, earliest) | 100 | 10.02 | 300 |
| 2 | S-2 (same price, later) | 200 | 10.02 | 100 |
| 3 | S-3 (next level) | 100 | 10.03 | 0 |
B-9 is fully filled: 400 shares, notional 4 009.00, average price 10.0225. S-3 rests with 200 at 10.03 and keeps its original priority. S-3 has an earlier sequence than S-2 but trades later, because price beats time. The engine emits three executions, each with a fill report to both sides, and order-by-order market data for each change.
7.3 Determinism, sequencing and recovery
The engine is a state machine: next state and output depend only on the current state and the next sequenced input. To keep that true:
| Rule | Why |
|---|---|
| No wall-clock reads; use the sequencer timestamp in the message | Replicas would otherwise see different times |
| No randomness; any tie-break uses sequence numbers | Same input, same output |
| No floating point for prices or quantities | Rounding can differ between builds and hardware |
| No iteration over hash maps where order affects output | Iteration order can differ between runs |
| No I/O inside matching; output goes to a ring buffer | Keeps timing out of the logic |
| Engine version and configuration are part of the snapshot | Replay with the wrong build gives wrong results |
Sequencer: one leader and two followers in the primary site. The leader
assigns the sequence number, appends to its journal and forwards to the
followers; a message is released to the engines once a majority (2 of 3)
has it on disk. A copy streams asynchronously to the DR site; the DR
recovery point is the replication lag, stated in the business continuity
plan. Leader election uses a consensus protocol (see
system-design/design-distributed-lock-coordination).
Engines: each partition has a primary and a hot standby reading the same sequence. Both hash their output every 10 000 messages; a mismatch halts the partition for investigation rather than risking a wrong trade. Failover promotes the standby, which is already current; members see a short pause, not lost orders.
Cold restart: load the latest snapshot of the partition, replay the journal from its sequence number (3.5), compare the output hash with the recorded one and resume.
7.4 Pre-trade risk and market controls
| Control | Where | Example setting |
|---|---|---|
| Credit limit per member | Gateway, member state local to the gateway | Open buy notional at or below the limit set by the clearing member |
| Maximum order size | Gateway | 100 000 shares or 5 million notional |
| Price collar | Gateway, reference price pushed from the engine | Reject limit prices more than 10% from the last trade |
| Message throttle | Gateway | 2 000 messages/s per session |
| Instrument halt and volatility interruption | Engine, triggered by price moves or operations | Halt when the price moves 10% within 5 minutes |
| Mass cancel on disconnect | Gateway sends a sequenced mass cancel | Optional per session |
| Kill switch per member | Operations console, sequenced | Cancels all orders and blocks new ones |
Each member is pinned to one gateway pair, so credit state has a single writer. Fills flow back to the gateway and release or consume credit.
7.5 Market data
- Every output event carries the partition sequence number; the feed carries a channel sequence number so subscribers detect gaps.
- Two identical multicast feeds (A and B) travel on separate networks; subscribers take the first copy of each sequence number.
- A subscriber that detects a gap requests the missing range from the TCP retransmission service, or, after a long outage, joins the snapshot channel and then applies incremental messages after the snapshot's sequence number.
- Public data never contains member identities.
7.6 How real systems do it
How real systems do it (paraphrased, not copied). Martin Fowler's article "The LMAX Architecture" (12 July 2011) describes the retail trading platform built by LMAX. All business logic runs on a single Java thread with every object in memory and no database; the article reports around 6 million orders per second from that one thread on one commodity server. Input events pass through a ring buffer (the Disruptor) where separate consumers unmarshal, write the journal and replicate the events before the business logic sees them, and output goes through further ring buffers. Because state is rebuilt by replaying the durable input events (event sourcing) from a nightly snapshot, a full restart took under a minute, and replicas fed the same input in the same order can take over quickly. The same three ideas drive 7.3: a single writer per partition, a journal of inputs before processing, and determinism so replicas agree. Read the original in 12.3; this box keeps only the general idea.
8. Scalability and performance
| Concern | Approach | Limit before redesign |
|---|---|---|
| Message rate | Partitions by instrument, one core each | Example: about 250 000 messages/s per partition at 50% busy |
| Hot instrument | Move it to its own partition | One instrument's rate above one core's capacity |
| Sequencer | Batching of journal writes and replication | Example: a few million messages/s on one leader; then sequence per partition group |
| Gateways | Members spread across gateway pairs | Network ports per server |
| Market data | Channels per instrument group | Subscriber line capacity, not the venue |
Latency budget, order in to acknowledgement out (target p99 100 µs):
| Step | Budget |
|---|---|
| Network in and gateway decode | 10 µs |
| Pre-trade risk check | 10 µs |
| Sequencer, journal append, quorum replication | 30 µs |
| Matching | 5 µs |
| Output, execution report encode, network out | 25 µs |
| Headroom (jitter, bursts) | 20 µs |
Keep the hot path free of memory allocation, system calls and locks; pin threads to cores; use kernel-bypass networking. Measure with hardware timestamps at the network edge, not with application clocks.
9. Reliability, security and operations
9.1 Failure modes
| Component | Failure | Detection | Blast radius | Mitigation | RTO |
|---|---|---|---|---|---|
| Matching engine primary | Crash | Heartbeat from the sequencer | Instruments of one partition pause | Promote hot standby | Example: under 1 s |
| Engine replicas | Output hash mismatch | Hash comparison every 10 000 messages | One partition | Halt partition, investigate, restart from snapshot and replay | Example: 15 min |
| Sequencer leader | Crash | Consensus heartbeat | Whole venue pauses | Elect follower; unacknowledged inputs are resent by gateways | Example: under 2 s |
| Gateway | Crash | Session drop | Members on that gateway | Members reconnect to the pair; optional mass cancel; credit state restored from the sequenced fill stream | Example: 30 s |
| Market data feed A | Packet loss | Gap detection | Subscribers on feed A | Feed B arbitration; retransmission service | Example: none visible |
| Primary site | Loss | Site monitoring | Whole venue | Controlled failover to DR after operations decision; recovery point equals replication lag | Example: 2 h |
| Clock source | Drift beyond tolerance | Clock monitoring | Timestamp accuracy | Alarm, switch source, record the incident for regulators | Example: 5 min |
| [Component] | [Failure] | [Signal] | [Scope] | [Mitigation] | [Time] |
9.2 Security and integrity
| Threat | Control |
|---|---|
| Unauthorised order entry | Per-session credentials, IP allow lists, TLS where offered, certificate-based admin access |
| Insider changing the book or sequence | No write path except sequenced inputs; journal hash chain; four-eyes for admin commands |
| Information leakage between members | Execution reports only to the owning session; public data anonymous |
| Unfair access to market data | Same multicast for all; member-specific latency tiers disclosed in the rulebook |
| Runaway algorithm | Throttles, kill switch, price collars (7.4) |
| [Threat] | [Control] |
9.3 Observability and regulatory records
| Signal | Metric or log | Alert threshold |
|---|---|---|
| Latency | p99 order to acknowledgement from network taps | Above 100 µs for 1 min |
| Engine busy | Share of time processing per partition | Above 50% |
| Replication | Follower lag in messages | Above 1 000 |
| Market data | Gaps detected by an internal subscriber | Any |
| Clock | Offset from the reference source | Above the venue's tolerance |
Trading venues are usually subject to rules on clock synchronisation, record keeping and market controls. In the EU, for example, Commission Delegated Regulation (EU) 2017/574 sets clock-synchronisation requirements under MiFID II; the UK and US have their own regimes. Confirm the rules that apply to the venue and their current text with compliance before setting NFR-07 and retention. This template does not state the legal requirements.
9.4 Cost estimate
| Item | Unit cost | Quantity | Monthly cost |
|---|---|---|---|
| Matching servers (primary and standby) | [$/server-month] | Example: 16 | [$] |
| Sequencer nodes | [$/server-month] | Example: 3 primary site, 1 DR | [$] |
| Gateways | [$/server-month] | [Pairs] | [$] |
| Low-latency network and clock sources | [$/month] | [Units] | [$] |
| Journal storage | [$/TB-month] | Example: 18.9 TB per year per copy | [$] |
| Total | [$] |
10. Trade-offs and alternatives
| Decision | Options | Chosen | Why | What we give up |
|---|---|---|---|---|
| Concurrency | Locks per book; single thread per partition | Single thread per partition | Deterministic, no lock contention | One hot instrument cannot use two cores |
| Durability | Database commit; replicated journal | Quorum-replicated journal before matching | Microseconds instead of milliseconds | Custom replication code to maintain |
| Failover | Cold restart; hot standby | Hot standby plus snapshots | Sub-second failover | Double the engine hardware |
| Risk placement | In engine; in gateway | In gateway | Engine stays small and fast | Credit state per gateway; members pinned |
| Market data | TCP fan-out; multicast | Multicast A/B with recovery | Same data at the same time for all | Subscribers must handle gaps |
| What changes at 10x / 0.1x | 10x (10 million messages/s): about 40 engines by the 3.3 formula, a sequencer per partition group with cross-group ordering only where a rule needs it (for example a mass cancel), and FPGA or kernel-bypass gateways. 0.1x (100 000 messages/s): one engine partition with a standby and a single sequencer node with a synchronous follower is enough | Review at each doubling of peak messages | The single sequencer, not the engines, limits first | [Note] |
| [Decision] | [Options] | [Chosen] | [Why] | [Cost] |
11. Delivery plan and risks
11.1 Milestones
| Milestone | Scope | Exit criterion | Target date |
|---|---|---|---|
| M1 | Engine and book with replay harness | Recorded day replays with identical output twice | YYYY-MM-DD |
| M2 | Sequencer with quorum journal, hot standby | Failover drill under 1 s with no lost acknowledged input | YYYY-MM-DD |
| M3 | Gateways, risk checks, market data, member test environment | Member certification tests pass | YYYY-MM-DD |
| M4 | Parallel run against the current platform | Executions identical for 20 trading days | YYYY-MM-DD |
| M5 | Go-live by instrument group | No severity 1 incident for 30 days | YYYY-MM-DD |
11.2 Rollout and rollback
[Example: Instruments move to the new platform in groups over a weekend with no open orders carried across (Day orders only during migration). Rollback moves the group back before the next session; the old platform stays warm until M5 plus 60 days.]
11.3 Risks
| ID | Risk | Likelihood | Impact | Mitigation | Owner |
|---|---|---|---|---|---|
| R-01 | Example: Hidden non-determinism found in production | Medium | High | Continuous hash comparison, replay of every day in test | [@name] |
| R-02 | Example: Members fail certification in time | Medium | High | Early test environment, protocol simulators | [@name] |
| R-03 | Example: Regulatory requirement missed | Low | High | Compliance review of NFR-07 and record keeping before M3 | [@name] |
| [R-nn] | [Risk] | [L / M / H] | [L / M / H] | [Mitigation] | [@name] |
12. Appendices
12.1 Open questions
| ID | Question | Owner | Due |
|---|---|---|---|
| OQ-01 | Example: Do we offer iceberg (reserve) orders in release 1? | [@name] | YYYY-MM-DD |
| OQ-02 | Example: Which clock tolerance and retention apply in each jurisdiction we serve? | [@name] | YYYY-MM-DD |
| [OQ-nn] | [Question] | [@name] | YYYY-MM-DD |
12.2 Glossary
| Term | Meaning |
|---|---|
| Order book | All resting buy and sell orders for one instrument, grouped by price level |
| Price-time priority | Better price first; at equal price, earlier arrival first |
| Aggressive order | An order that trades on arrival against resting orders |
| Sequencer | Component that gives every input one position in a total order |
| Hot standby | A replica that processes the same inputs and can take over at once |
| IOC / FOK | Immediate or cancel: fill what you can now, cancel the rest. Fill or kill: fill all now or nothing |
| Tick | Minimum price increment |
| [Term] | [Meaning] |
12.3 References
| Reference | Use |
|---|---|
| FIX Trading Community, "FIX Protocol" (FIX Latest with extension packs) | Application messages in 4.1; check definitions in the FIX tools |
| FIX Trading Community, "Technical Standards" (session layer, FIXP, FIXS, SBE, SOFH) | Protocols in 4.1 |
| FIX Trading Community, "Simple Binary Encoding" (version 1.0 final; version 2.0 at release candidate stage as of October 2026); also published as ISO/IEC 25390:2025, ISO catalogue | Binary encoding of order entry |
| Fowler, "The LMAX Architecture", 12 July 2011 | 7.6 |
| Commission Delegated Regulation (EU) 2017/574 (clock synchronisation under MiFID II), EUR-Lex | Example of a regulatory requirement in 9.3 |
Payment Ledger System Design (system-design/design-payment-ledger) | Downstream money movement |
Message Queue System Design (system-design/design-message-queue) | Log replication concepts |
Distributed Lock and Coordination System Design (system-design/design-distributed-lock-coordination) | Leader election for the sequencer |
Unique ID Generator System Design (system-design/design-unique-id-generator) | Order and execution IDs |
Back-of-Envelope Estimation and Capacity Model (system-design/back-of-envelope-estimation) | Method for section 3 |
Standard and licence note
Based on common industry practice for electronic matching venues. FIX specifications are published by the FIX Trading Community; they are named here for reference only, message type codes are quoted for orientation and no specification text was copied. Official text: FIX Trading Community, access under its terms at https://www.fixtrading.org/standards/. ISO/IEC 25390:2025 (SBE) is a paid standard and is named only; official text: ISO, purchase or licensed access at https://www.iso.org/standard/90107.html. The LMAX article is paraphrased in 7.6 only. Regulatory items are examples, dated October 2026; this is not legal or regulatory advice, so check the current official text and a qualified professional. All capacity numbers are illustrative examples. Original text written for this collection. Template licence: MIT.
Related templates
Ride-Hailing Dispatch System Design Template (Reference Design)
Ride matching: location ingestion, H3/geohash index, batched matching, ETA, trip state machine, single assignment, surge note
System DesignAd Click Aggregation System Design Template (Reference Design)
45-minute path, click dedupe, event-time windows, exactly-once counting, exact and Count-Min top-K, batch reconciliation for billing, failure modes, 10x row
System DesignZanzibar-Style Authorization Service System Design Template
Relationship-based authorization service: relation tuples, namespace config, Check/Expand/List/Watch APIs, consistency tokens, caching, sharding, failure modes