Home/Labs/Disruptor Ticker Ring
All 280 Labs
INTERACTIVE LAB📈

LMAX Disruptor Market Ticker Lab (Interactive)

Pour millions of exchange ticks into a lock-free ring and bill JSON versus binary fan-out. Model Zerodha-style tick ingestion: producers and consumers race around a power-of-two ring buffer, stale ticks vanish on wrap, and 28-byte binary packets cut WebSocket egress more than 85% versus JSON.

Disruptor Ring Buffer & Tick Fan-Out Lab

Exchange UDP multicast pours millions of ticks per second into a lock-free ring. Outrun the consumers and watch it wrap; then bill the WebSocket fleet's egress in binary vs JSON.

Ring slots (power of 2)65,536
Bitwise index maskseq & 65,535
Producer − consumer gap+200,000 ticks/s backlog
Ring wrapsevery 0.3 s
Stale ticks overwritten/s200,000
Fan-out egress (current format)56.0 Gbps
JSON vs binary billJSON 400 Gbps vs binary 56.0 Gbps (−86%)
Consumers fall 200,000 ticks/s behind: the ring wraps every 0.3 s and overwrites stale quotes. Harmless for latest-wins market data, fatal if this buffer carried order events — pad cache lines, add consumer cores, or grow 2^16.

How It Works Under the Hood

At 9:15 AM the exchange multicasts over five million binary ticks per second, and logging them to disk would destroy SSDs — so trading platforms process ticks entirely in memory. The LMAX Disruptor replaces mutex queues with a pre-allocated ring buffer whose size is a power of two, indexing by sequence bitwise-AND mask, with 64-byte cache-line padding isolating atomic pointers from false sharing and lock-free CAS delivering sub-microsecond handoff at six million messages per second per core. On the edge, Zerodha's Kite Ticker ships 28-byte packed binary slices instead of 200-byte JSON to millions of screens.

Core Architectural Principles

  • Ring mechanics: index = sequence & (2^n - 1); when producers outrun consumers the ring wraps and silently overwrites stale ticks.
  • False-sharing defense: cache-line padding around cursor pointers keeps cores from invalidating each other's L1 lines.
  • Protocol bandwidth: 28-byte binary versus 200-byte JSON per tick, multiplied by subscribers times update rate, is the entire egress bill.
Interview Round Script

For live-market-data designs, name the pattern: "Disruptor-style lock-free ring, power-of-two size, sequence-mask indexing, cache-line padded." Explain why latest-wins semantics make tick dropping acceptable while order events need durability. Then price the wire: 50 ticks per second per user across millions of subscribers is hundreds of gigabits in JSON and under sixty in packed binary — an 85% cut that is pure margin.

Key Trade-Offs

Lock-free rings and binary protocols deliver sub-microsecond, low-bandwidth fan-out but sacrifice durability and require bespoke serialization on every client.

Related Curriculum Chapter

Trading Platforms (Zerodha / Robinhood): Real-Time Market Tickers at Scale

Read Full Chapter Blueprint

Explore More Interactive Labs

View All 280 Labs