High-Throughput Financial ExchangePRODUCTION RETROSPECTIVE

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.

High-Level Architectural Overview

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.

Key Engineering Problems & Trade-Offs

Lock-Free Disruptor Ring Buffers for Market Ticks

Billions of daily stock ticks broadcast with sub-millisecond internal latency
The Scaling Problem

Distributing real-time stock market price updates (ticks) to millions of connected trading terminals during market opening volatility spikes without thread contention.

Engineering Solution

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.

Architectural Trade-Offs

Binary protocol requires client-side deserialization SDKs vs 85%+ reduction in network bandwidth and zero JSON CPU serialization overhead.

How to Say This in an Interview

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.

Curriculum Topics Used in Zerodha Architecture (95)
Full Syllabus
Phase 1#8

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.

8 min readRead Blueprint →
Phase 1#10

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.

9 min readRead Blueprint →
Phase 2#15

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.

9 min readRead Blueprint →
Phase 2#17

Concurrency vs Parallelism

Disentangle structure from execution: Rob Pike's composition model, time slicing on single cores vs simultaneous execution across multi-core CPUs.

8 min readRead Blueprint →
Phase 2#19

Multithreading & Thread Safety

Write correct concurrent programs: Shared mutable state, memory models, volatile variables, atomic operations, and lock-free programming.

9 min readRead Blueprint →
Phase 2#20

Locks, Mutexes, Semaphores, & Spinlocks

Master synchronization primitives: Mutex (Mutual Exclusion), Counting Semaphores (Rate limiting), Read-Write Locks (RWLock), and Spinlocks (Busy-waiting).

9 min readRead Blueprint →
Phase 2#25

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.

9 min readRead Blueprint →
Phase 3#28

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.

9 min readRead Blueprint →
Phase 3#33

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.

9 min readRead Blueprint →
Primary Technical Sources & Published Papers
Trading at Scale: Zerodha Engineering Architecture

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.

Start Free: Topic #1