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.
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.
10M msgs/sec (5.12 Gbps) Multi-Tier Fan-Out
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.
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.
Disruptor 3-Consumer Fan-Out
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.
- 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.
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?
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.
Mmap Wire-Log Decoupling for Slow DB Consumers
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.
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.
Columnar Delta+ZSTD Tick Compression
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.
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.
NUMA-Local NIC -> Ring -> Strategy Pinning
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.
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.
Aeron/Chronicle Bit-Exact Simulation Loop
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.
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.
NIC Drop Counter & Stale-Book Kill-Switch
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: Make the trade-off yourself.
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?