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

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.
Start the journey7 sections· Last modified Nov 24, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

If latency budgets leave no room for synchronous retries, never wait for TCP retransmissions on the live market data path; consume dual A/B UDP multicast lines through kernel-bypass NICs and arbitrate on sequence_number.

TL;DR30-second simplified summary
▾

Deterministic feed handlers pair kernel-bypass DMA rings with sequence-number A/B arbitration.

Rare dual-line drops trigger out-of-band TCP replay while fixed-offset ITCH decoders push 64B ticks into lock-free SPSC rings.

Full walkthrough · 7 stages
01
foundation

Why Exchanges Use Dual UDP Multicast.

Why this matters: Understand why TCP head-of-line blocking is unacceptable for market data.

Exchanges fan out ticks to thousands of firms simultaneously.

Unicast TCP would multiply exchange egress by N and stall slow readers during retransmissions.

Feed Redundancy

Dual UDP Multicast A/B Line Arbitration

Exchange Feed A(UDP)Multicast line AExchange Feed B(UDP)Multicast line BA/B Seq ArbitratorDeduplicatorGap DetectorLoss triggerStreams backup copy

1.First-Arrival Wins: Whichever line delivers seq_num N first is processed immediately; the slower twin is dropped.

2.Zero HoL Blocking: UDP multicast delivers every tick without TCP ACK stalls.

Dual-line UDP arbitration combines O(1) multicast fan-out with sub-microsecond failover.

02
foundation

Kernel-Bypass Networking (DPDK & Solarflare).

Why this matters: Eliminate Linux kernel interrupt, context-switch, and sk_buff copy overhead.

Think of Kernel-Bypass Networking (DPDK & Solarflare) as the intuition layer for Multicast Market Data Feed A/B Arbitration & Order Book Reconstruction: Eliminate Linux kernel interrupt, context-switch, and sk_buff copy overhead.

Standard Linux sockets incur ~10–15 microseconds per packet due to hardware interrupts, kernel-to-userspace copies, and scheduler wakeups. Kernel-bypass (Solarflare OpenOnload/ef_vi or DPDK) maps NIC RX ring buffers directly into pinned userspace hugepages polled by a dedicated CPU core.

Zero-Copy NIC

Kernel-Bypass DMA Ring vs Standard Kernel Stack

Solarflare / DPDKNICWire ingressPinned Hugepage RingUserspace memoryIsolated Poll CoreBusy-wait threadITCH Binary DecoderParserReads in <1us

1.Zero Allocations: Pre-allocated hugepage pools prevent malloc/GC pauses on the hot path.

2.Core Pinning: Pinning polling threads to isolated cores eliminates OS context switches.

Kernel-bypass DMA rings cut packet ingress latency from ~15us down to <1us.

Engineering Decision Framework
Problem
How to implement Multicast Market Data Feed A/B Arbitration & Order Book Reconstruction 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
If latency budgets leave no room for synchronous retries, never wait for TCP retransmissions on the live market data path; consume dual A/B UDP multicast lines through kernel-bypass NICs and arbitrate on sequence_number.
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 Multicast Market Data Feed A/B Arbitration & Order Book Reconstruction experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
intermediate

Sequence Gap Detection & TCP Replay Recovery.

Why this matters: Recover lost packets without stalling live market data processing.

Think of Sequence Gap Detection & TCP Replay Recovery as the intuition layer for Multicast Market Data Feed A/B Arbitration & Order Book Reconstruction: Recover lost packets without stalling live market data processing.

If both Feed A and Feed B drop sequence #1042, the Arbitrator buffers packets #1043–#1048 in a bounded reorder ring and fires an async TCP Replay request to the exchange recovery server. Once #1042 arrives (or a 5ms recovery timeout expires), the ring drains in order.

Gap Recovery

Bounded Reorder Ring & Out-of-Band TCP Replay

Gap DetectorLoss sensor1024-Slot ReorderRingJitter bufferOut-of-Band TCPReplayRecovery channelSnapshot ResyncBook integrityRequests seq 1042

1.Micro-Jitter Tolerance: Wait 50us before requesting TCP replay in case Feed B delivers #1042 slightly late.

2.Snapshot Fallback: Massive bursts exceeding 1,024 packets trigger a clean L2/L3 snapshot reload.

A 50us jitter wait plus bounded TCP replay recovers rare dual-line drops cleanly.

04
intermediate

Zero-Copy Binary Decoding (ITCH / SBE).

Why this matters: Parse fixed-width binary exchange protocols in nanoseconds.

Think of Zero-Copy Binary Decoding (ITCH / SBE) as the intuition layer for Multicast Market Data Feed A/B Arbitration & Order Book Reconstruction: Parse fixed-width binary exchange protocols in nanoseconds.

Exchanges avoid text JSON/XML on fast feeds, using fixed-offset binary protocols like NASDAQ ITCH 5.0 or CME SBE (Simple Binary Encoding). By mapping wire structs directly in little-endian/big-endian C++ or Rust, fields like price, qty, and side are read via pointer offsets with zero heap allocation.

Wire Protocol

Fixed-Offset ITCH / SBE Binary Cast

UDP Payload FrameWire bytesMessage Type SwitchO(1) dispatchZero-Copy FieldCastNanosecond parseCache-Aligned EventNormalized tickSelects struct layout

1.Integer Fixed-Point: Prices travel as scaled integers (1e-4) to avoid floating-point rounding drift.

2.64B Cache Alignment: Packing normalized ticks into 64 bytes prevents CPU cache-line splits.

Fixed-offset binary casting parses market messages in tens of nanoseconds with zero allocations.

05
intermediate

Lock-Free SPSC Ring Buffer & Cache Padding.

Why this matters: Pass decoded ticks between the feed handler and strategy engine without mutexes.

Think of Lock-Free SPSC Ring Buffer & Cache Padding as the intuition layer for Multicast Market Data Feed A/B Arbitration & Order Book Reconstruction: Pass decoded ticks between the feed handler and strategy engine without mutexes.

Mutexes trigger OS context switches (~5us). A Single-Producer Single-Consumer (SPSC) lock-free ring buffer uses atomic acquire/release memory barriers on head and tail indices, padded to separate 64-byte CPU cache lines to prevent false sharing.

Lock-Free IPC

Cache-Padded SPSC Ring Buffer

Feed Handler ThreadSingle producerPower-of-2 RingArrayShared memory64B Cache-Line PadCPU L1 guardOrder Book ThreadSingle consumerIsolates cursor lines

1.False-Sharing Guard: Separating head and tail by 64 bytes stops L1/L2 cache-coherency ping-pong.

2.Bitwise Masking: Power-of-2 capacity replaces slow integer modulo (%) with fast bitwise AND (&).

Cache-padded SPSC ring buffers transfer ticks between threads in ~20 nanoseconds.

06
advanced

L2/L3 Order Book Reconstruction Data Structures.

Why this matters: Maintain real-time Bid/Ask depth with O(1) order cancel and modify.

L3 order books track every individual resting order ID.

Cancels and executions dominate exchange traffic (>85% of messages).

Order Book Engine

O(1) Hash Map + Price-Level Linked List

Flat Order Hash MapO(1) lookupSorted Bid LevelsBuy depthSorted Ask LevelsSell depthTop-of-Book (BBO)Strategy signalO(1) cancel/modify

1.85%+ Cancels: Optimizing order_id lookup for O(1) cancels is the #1 book performance lever.

2.Contiguous BBO: Keeping the top 10 price levels in flat arrays maximizes CPU cache hits.

A flat order_id map linked to price-level lists handles >85% cancel traffic in O(1) time.

07
advanced

PTP Nanosecond Clock Sync & Cross-Feed Skew.

Why this matters: Order events accurately across multiple exchanges using IEEE 1588 PTP.

Think of PTP Nanosecond Clock Sync & Cross-Feed Skew as the intuition layer for Multicast Market Data Feed A/B Arbitration & Order Book Reconstruction: Order events accurately across multiple exchanges using IEEE 1588 PTP.

NTP drifts by milliseconds, making cross-exchange arbitrage timestamps meaningless. IEEE 1588 Precision Time Protocol (PTP) with hardware NIC timestamping synchronizes server clocks to grandmaster GPS/atomic clocks within <100 nanoseconds.

Time Synchronization

IEEE 1588 PTP Hardware Timestamping

GPS GrandmasterClockTime sourcePTP Boundary SwitchNetwork syncNIC PHC HardwareClockPacket stamperMiFID / CAT AuditLogRegulatory traceDisciplines NIC PHC

1.Hardware Stamping: Stamping packets at the NIC PHY avoids OS scheduling jitter.

2.Regulatory Mandate: MiFID II and FINRA CAT require synchronized microsecond/nanosecond timestamps.

PTP hardware timestamping keeps multi-exchange tick logs accurate within 100 nanoseconds.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why do financial exchanges broadcast live market data over dual UDP multicast lines instead of TCP?

Recommended Learning Flow