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.
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.
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.
Lock-free rings and binary protocols deliver sub-microsecond, low-bandwidth fan-out but sacrifice durability and require bespoke serialization on every client.