Ashok G

System Design

From one request to many machines.

This track starts with what happens when a single web page loads, and builds up from there. The early chapters assume little beyond basic programming. The later ones cover consensus, distributed transactions and overload.

The chapters run in order. 1 to 4 cover a request, a machine, measurement and scaling out. 5 to 8 cover databases, caches, queues and how systems behave under load. 9 to 14 cover partitioning, replication, consensus, storage, distributed transactions and resilience. 15 to 19 cover services, operations, code structure, a full rate limiter and worked designs.

Numbers in tables come from simulations and small programs unless a source is given. The programs are included, so results can be reproduced.

Chapters

  1. 1What happens in a single requestBefore scaling anything: the path of one web request through DNS, TCP, TLS, HTTP, an application and a database.Draft
  2. 2What one machine can doProcesses, threads, memory, disk and network: the hardware limits behind every design, and how much a single server can really handle.Draft
  3. 3Measuring: latency, throughput, availabilityPercentiles and why averages mislead, SLOs and error budgets, the arithmetic of nines, and estimating capacity on the back of an envelope.Draft
  4. 4Scaling out: stateless servers and load balancersFrom one server to many: statelessness, load balancing algorithms, health checks, CDNs and autoscaling.Draft
  5. 5Databases: indexes, transactions and isolationRelational and NoSQL stores, how indexes work, ACID, isolation levels and their anomalies, connection pools, and the N+1 problem.Draft
  6. 6CachingWhy caches work, write patterns, eviction, invalidation, stampedes, leases and the failure modes that come with a cache.Draft
  7. 7Queues and asynchronous workWhy some work shouldn't happen during a request: task queues, log streams, pub/sub, consumer groups, ordering, dead letters and backpressure.Draft
  8. 8Queueing, tail latency and scalability limitsLittle's law, why latency explodes near full load, tail amplification under fan-out, hedged requests, and the Universal Scalability Law.Draft
  9. 9PartitioningSplitting data across machines: range and hash partitioning, consistent hashing with virtual nodes, hot keys, secondary indexes and resharding.Draft
  10. 10Replication and consistencyKeeping copies of data: leaders, followers, replication lag, failover, quorums, CAP, PACELC, consistency models, conflicts and CRDTs.Draft
  11. 11Clocks, consensus and distributed locksWhy time can't be trusted, Lamport and vector clocks, failure detection, Raft, leases, and why distributed locks need fencing tokens.Draft
  12. 12Storage enginesHow data reaches disk: write-ahead logs, B-trees, LSM trees, compaction, Bloom filters, amplification, and object, block and column storage.Draft
  13. 13Delivery guarantees and transactions across servicesAt-least-once delivery, idempotency, the dual write problem, transactional outbox, change data capture, sagas and what exactly-once really means.Draft
  14. 14Resilience: timeouts, retries, circuit breakers and overloadHow systems fail in chains, and the defences: timeouts, retries with jitter, circuit breakers, bulkheads, load shedding, adaptive throttling and metastable failures.Draft
  15. 15Services and APIsMonoliths and microservices, REST, gRPC and GraphQL, pagination, versioning, gateways, service meshes, authentication and authorization.Draft
  16. 16Running it: observability, deployments and regionsMetrics, logs and traces, RED and USE, safe deployments with canaries and feature flags, multi-region failover and incident response.Draft
  17. 17Low-level designStructuring code inside a service: SOLID, hexagonal architecture, design patterns, testing seams, concurrency basics and a thread-safe LRU cache.Draft
  18. 18A rate limiter, end to endOne feature that needs both levels: algorithms, shared state, a tested token bucket, the distributed race and an atomic Redis script.Draft
  19. 19Worked designsA URL shortener, a news feed and a chat system, each worked from requirements to failure modes, plus a design checklist.Draft