Skip to main content
← PROBLEMS / SYSTEM-DESIGN
An end-to-end domain learning journey

Design a High-Frequency Stock Market
Data Ingestion System (10M+ msgs/sec).

Design a High-Frequency Stock Market Data Ingestion pipeline sustaining 10M+ messages/sec bursts under <10us hot-path latency while durably archiving every tick to kdb+/ClickHouse.
Start the journey7 stages· Last modified Nov 24, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When traffic spikes expose hidden coupling, use a Disruptor Ring Buffer to fan out arbitrated, PTP-stamped ticks to three isolated consumers: Strategy Engine (ultra-low latency), Aeron Wire Log (durable), and kdb+/ClickHouse (analytics).

TL;DR30-second simplified summary
▾

To sustain 10M msgs/sec under 10us, decode once into a 256 MB Disruptor ring, let ClickHouse tail the NVMe Chronicle mmap log in 100K-row batches, and pin NICs and threads to the same NUMA socket.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Multicast Market Data Feed A/B Arbitration & Order Book Reconstruction
Multicast Market Data Feed A/B Arbitration ingests dual redundant UDP exchange feeds via kernel-bypass NICs, deduplicates by sequence number, fills packet gaps via TCP replay, and reconstructs L2/L3 order books in single-digit microseconds.
Full walkthrough · 7 stages
01
foundation

10M+ msgs/sec Burst Math & Latency Tiers.

Why this matters: Quantify peak bandwidth, packet rates, and asymmetric consumer SLAs.

Think of 10M+ msgs/sec Burst Math & Latency Tiers as the intuition layer for Design a High-Frequency Stock Market Data Ingestion System (10M+ msgs/sec): Quantify peak bandwidth, packet rates, and asymmetric consumer SLAs.

At 10M msgs/sec peak with ~64 bytes per normalized tick, internal throughput is 640 MB/s (~5.1 Gbps). While the Strategy Engine demands <10us deterministic latency, the kdb+/ClickHouse analytical store only needs <1s freshness via 100K-row micro-batches.

Burst Sizing

10M msgs/sec (5.12 Gbps) Multi-Tier Fan-Out

Exchange Burst(10M/s)Peak ingressKernel-BypassHandler<2us ingestDisruptor RingBufferZero-GC bus3-Tier ConsumersIsolated speedsPublishes 64B ticks

1.Asymmetric SLAs: Never let disk I/O in ClickHouse backpressure the <10us Strategy Engine.

2.4M-Slot Ring: 4M x 64B = 256 MB ring buffer absorbs 400ms of burst without wrapping.

A 256 MB Disruptor ring absorbs 10M/s bursts while decoupling fast strategy reads from disk writes.

02
foundation

Three-Way Disruptor Fan-Out Topology.

Why this matters: Feed Strategy, Durable Wire Log, and Time-Series DB from one normalized stream.

Think of Three-Way Disruptor Fan-Out Topology as the intuition layer for Design a High-Frequency Stock Market Data Ingestion System (10M+ msgs/sec): Feed Strategy, Durable Wire Log, and Time-Series DB from one normalized stream.

Decoding ITCH/FIX once in the Feed Handler and writing to a Disruptor Ring Buffer allows three independent consumers to read the same memory-mapped slots: (1) Strategy Execution Engine, (2) Aeron/Chronicle Wire Log, and (3) kdb+/ClickHouse Batch Loader.

Fan-Out Architecture

Disruptor 3-Consumer Fan-Out

Feed Handler + PTPSingle producerDisruptor RingShared busStrategy EngineAlpha executionAeron Log + kdb+/CHDurable archiveReads <10us

1.Decode Once: Normalizing binary exchange formats once saves 3x CPU across consumers.

2.Zero-Copy Mmap: Chronicle/Aeron appends ticks to page-cache mmap files in <200ns.

Single-producer Disruptor fan-out eliminates duplicate parsing and network hops.

Engineering Decision Framework
Problem
How to implement Design a High-Frequency Stock Market Data Ingestion System (10M+ msgs/sec) without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
When traffic spikes expose hidden coupling, use a Disruptor Ring Buffer to fan out arbitrated, PTP-stamped ticks to three isolated consumers: Strategy Engine (ultra-low latency), Aeron Wire Log (durable), and kdb+/ClickHouse (analytics).
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Design a High-Frequency Stock Market Data Ingestion System (10M+ msgs/sec) experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
intermediate

Protecting Strategy Latency from Slow Consumers.

Why this matters: Prevent a stalled database writer from wrapping or blocking the Disruptor ring.

Think of Protecting Strategy Latency from Slow Consumers as the intuition layer for Design a High-Frequency Stock Market Data Ingestion System (10M+ msgs/sec): Prevent a stalled database writer from wrapping or blocking the Disruptor ring.

If ClickHouse experiences a merge pause, a naive Disruptor consumer barrier blocks the producer, stalling live trading! We isolate the Strategy Engine on a non-blocking primary cursor while the Wire Log acts as a multi-gigabyte disk-backed buffer that the ClickHouse loader tails independently.

Backpressure Isolation

Mmap Wire-Log Decoupling for Slow DB Consumers

Disruptor RingHot ringStrategy EngineCritical consumerChronicle Mmap LogShock absorberClickHouse LoaderAsync sinkAppends to NVMe mmap

1.NVMe Shock Absorber: A 100 GB NVMe mmap log absorbs hours of downstream DB maintenance.

2.Zero GC Stalls: Strategy threads never wait on ClickHouse network or disk flushes.

Tailing the NVMe mmap wire log ensures slow analytical stores never stall live trading.

04
intermediate

kdb+ / ClickHouse Time-Series Partitioning & Compression.

Why this matters: Store 100B+ daily ticks efficiently for millisecond quant backtests.

Think of kdb+ / ClickHouse Time-Series Partitioning & Compression as the intuition layer for Design a High-Frequency Stock Market Data Ingestion System (10M+ msgs/sec): Store 100B+ daily ticks efficiently for millisecond quant backtests.

Storing 10M msgs/sec for a 6.5-hour trading day produces ~50B–100B rows (~3 TB raw). Partitioning ClickHouse/kdb+ by (trade_date, symbol_bucket) and sorting by (symbol, exchange_ts_ns) with Delta+ZSTD codec achieves 8:1 compression and sub-second symbol range scans.

Tick Storage

Columnar Delta+ZSTD Tick Compression

100K-RowMicro-BatchWrite coalescerDate + SymbolPartitionRange pruningDelta + ZSTD CodecStorage saverQuant Backtest APIResearch consumerCompresses monotonically

1.Delta Encoding: Consecutive stock prices and timestamps change by tiny deltas, compressing 8x.

2.Large Batches: Flushing 100K rows/insert avoids ClickHouse 'Too many parts' errors.

Sorted MergeTree tables with Delta+ZSTD codecs shrink daily terabytes of ticks by 8x.

05
intermediate

Symbol Sharding & NUMA-Aware Core Pinning.

Why this matters: Scale across 64-core servers without cross-socket QPI/UPI memory penalties.

Think of Symbol Sharding & NUMA-Aware Core Pinning as the intuition layer for Design a High-Frequency Stock Market Data Ingestion System (10M+ msgs/sec): Scale across 64-core servers without cross-socket QPI/UPI memory penalties.

Dual-socket servers suffer ~40ns extra latency when a thread on Socket 0 reads memory allocated on Socket 1. We shard exchange multicast groups by symbol range across NUMA nodes, pinning the NIC IRQ/poll thread, Disruptor ring, and Strategy thread onto the same physical NUMA socket.

Hardware Affinity

NUMA-Local NIC -> Ring -> Strategy Pinning

NUMA Socket 0(AAPL-MSFT)Local memoryNUMA Socket 1(NVDA-TSLA)Local memoryShared L3 CacheFast handoffStartup NUMA GuardOps safetyKeeps ticks local

1.Zero Cross-Socket: Keeping NIC, ring buffer, and strategy on one NUMA node cuts jitter by 40%.

2.Multicast Sharding: Exchanges split symbols across 4-8 multicast channels for easy horizontal sharding.

NUMA-local sharding eliminates cross-socket interconnect latency on high-core servers.

06
advanced

Deterministic Replay & Bit-Exact Backtesting.

Why this matters: Replay production wire logs through strategy code to reproduce bugs bit-for-bit.

Think of Deterministic Replay & Bit-Exact Backtesting as the intuition layer for Design a High-Frequency Stock Market Data Ingestion System (10M+ msgs/sec): Replay production wire logs through strategy code to reproduce bugs bit-for-bit.

Because the Aeron/Chronicle Wire Log records every arbitrated tick with its exact hardware PTP timestamp, quant engineers can replay a full trading day into the Strategy Engine in simulation mode, verifying deterministic state transitions without external network I/O.

Deterministic Replay

Aeron/Chronicle Bit-Exact Simulation Loop

Chronicle Wire LogImmutable tapeVirtual Clock DriverDeterministic timeStrategy EngineSystem under testOrder Diff VerifierRegression gateFeeds ticks in order

1.No Wall-Clock Calls: Strategies must read time from the tick's PTP timestamp for bit-exact replay.

2.CI Regression Gate: Replay crash days in CI before deploying any strategy change.

Driving strategies with PTP-stamped wire logs enables bit-exact production replay.

07
advanced

Market-Open Burst Cushioning & Drop Alerts.

Why this matters: Detect silent NIC ring drops or micro-bursts before strategies trade on stale books.

Think of Market-Open Burst Cushioning & Drop Alerts as the intuition layer for Design a High-Frequency Stock Market Data Ingestion System (10M+ msgs/sec): Detect silent NIC ring drops or micro-bursts before strategies trade on stale books.

If a 10M/s micro-burst overflows the NIC RX ring, the hardware rx_dropped counter increments. A dedicated Telemetry Watcher polls NIC ethtool counters every 10ms; any drop or sequence gap >5ms automatically halts quoting on affected symbols to prevent trading on stale prices.

Safety Kill-Switch

NIC Drop Counter & Stale-Book Kill-Switch

NIC rx_droppedCounterHardware sensorUnresolved Gap TimerBook stalenessStrategyKill-SwitchRisk guardSnapshot ResyncAuto-recoveryTrips on >5ms gap

1.Never Trade Stale: Quoting on a book missing even 1 cancel message can cause instant adverse fills.

2.Auto-Resume: Re-enable quoting only after a full TCP snapshot verifies sequence parity.

Hardware NIC drop monitoring and 5ms gap timers trigger instant quote cancellation on stale books.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

In a 3-consumer Disruptor fan-out (Strategy Engine, Chronicle Wire Log, ClickHouse Batcher), how do you prevent a slow ClickHouse disk flush from blocking the <10us Strategy Engine?

Recommended Learning Flow