Zerodha: LMAX Disruptor Lock-Free Ring Buffers & Binary WebSockets
How India’s largest stock broker processes billions in daily trades with minimalist, high-performance Go and Python infrastructure: LMAX Disruptor patterns and packed binary WebSockets.
Zerodha processes 15%+ of all Indian retail stock exchange volume. By strictly adopting single-responsibility Go services, lock-free LMAX Disruptor ring buffers, and packed binary WebSocket tick packets (Kite Ticker), Zerodha handles massive market opening traffic spikes with minimal server footprint.
Lock-Free Disruptor Ring Buffers for Market Ticks
Billions of daily stock ticks broadcast with sub-millisecond internal latencyDistributing real-time stock market price updates (ticks) to millions of connected trading terminals during market opening volatility spikes without thread contention.
LMAX Disruptor lock-free ring buffers with CPU cache-line padding to eliminate false sharing. Ticks are packed into compact binary byte buffers (instead of JSON) before broadcasting over WebSockets.
Binary protocol requires client-side deserialization SDKs vs 85%+ reduction in network bandwidth and zero JSON CPU serialization overhead.
Explain why binary WebSockets beat JSON in high-frequency trading: JSON string parsing overhead and memory allocations cause GC latency spikes; binary byte structs unpack in nanoseconds.
TCP vs UDP Tradeoffs
Compare reliable byte streams against lightweight datagrams: flow control, congestion avoidance, head-of-line blocking, and when to pick UDP for real-time scale.
TLS/SSL Handshake & Encryption Basics
Understand asymmetric vs symmetric cryptography, Diffie-Hellman Ephemeral key exchange, X.509 Certificate Authorities, and TLS 1.2 vs TLS 1.3 1-RTT/0-RTT speedups.
Latency Numbers Every Programmer Should Know
Master the iconic back-of-the-envelope latency benchmarks compiled by Jeff Dean: Scale hardware nanoseconds into human intuitive time scales.
Concurrency vs Parallelism
Disentangle structure from execution: Rob Pike's composition model, time slicing on single cores vs simultaneous execution across multi-core CPUs.
Multithreading & Thread Safety
Write correct concurrent programs: Shared mutable state, memory models, volatile variables, atomic operations, and lock-free programming.
Locks, Mutexes, Semaphores, & Spinlocks
Master synchronization primitives: Mutex (Mutual Exclusion), Counting Semaphores (Rate limiting), Read-Write Locks (RWLock), and Spinlocks (Busy-waiting).
Virtualization vs Containers (Conceptual Intro)
Demystify cloud infrastructure: Type 1/2 Hypervisors vs Linux Namespaces, cgroups (Control Groups), chroot, Union File Systems (OverlayFS), and startup latencies.
Load Balancing Algorithms (Round Robin, Least Connections, Hash, Weighted)
Deep dive into traffic distribution algorithms: Static vs Dynamic scheduling, Consistent Hashing, Maglev, Weighted Least Connections, and Peak EWMA.
WebSockets & Full-Duplex Communication
Master real-time bidirectional communication: The HTTP 101 Switching Protocols upgrade, framed binary/text transport, connection scaling, and Redis Pub/Sub backplanes.
Kailash Nadh, Zerodha Tech Blog • 2023
Ready to Practice Zerodha-Style Systems?
Start with foundational networking, compute, and storage, and build up to complex distributed consensus.