System Design Tutorial
Learn System Design step by step: 65 lessons in 11 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Thinking in Systems
- What Is System Design? Learn what system design means, how high-level and low-level design differ, the design life cycle, and how to sketch a system as boxes and arrows.
- Functional and Non-Functional Requirements Turn a vague idea into testable functional and non-functional requirements: scope, SLOs, constraints and a checklist, with a Python requirement checker.
- Capacity Estimation and Back-of-the-Envelope Math Estimate requests per second, storage, bandwidth and server counts with powers of two, latency numbers and a reusable Python estimator.
- Scalability - Vertical and Horizontal Scaling Compare scaling up and scaling out, learn when each wins, see how auto scaling reacts to load, and simulate both with runnable Python code.
- Latency, Throughput and Bottlenecks Understand latency, throughput, bandwidth and queueing, learn Little's law, and find the bottleneck of a request pipeline with a Python simulation.
- Availability, Reliability and Maintainability Learn the nines of availability, MTBF and MTTR, how redundancy raises uptime in series and parallel systems, and why maintainability matters, with Python.
Building Blocks of the Web Stack
- Communication Protocols in System Design Compare TCP, UDP, HTTP, WebSockets, polling, server-sent events and gRPC, understand round trips and handshakes, and simulate their costs in Python.
- Proxies - Forward and Reverse Understand forward and reverse proxies, what each hides, TLS termination, caching and routing, and build a small routing reverse proxy in Python.
- API Gateway - The Front Door of Your Services Learn what an API gateway does: routing, authentication, rate limiting, aggregation and protocol translation, with a Python gateway simulation.
- Web Servers and Application Servers Learn the difference between web and application servers, how thread pools and event loops handle concurrency, and size a worker pool with Python.
- Stateless vs Stateful Systems Learn the difference between stateless and stateful services, where session state should live, sticky sessions versus shared stores, with a Python demo.
- Monolith vs Microservices Compare monolithic and microservice architectures, modular monoliths, service boundaries, costs of distribution and a migration path, with Python demos.
Load Balancing and Traffic
- Load Balancers and Their Types Learn what a load balancer does, the differences between Layer 4 and Layer 7, hardware, software and cloud options, DNS and global balancing, and sticky sessions.
- Load Balancing Algorithms Compare round robin, weighted round robin, least connections, least response time, IP hash and power of two choices, and simulate them in Python.
- Consistent Hashing Learn how consistent hashing places keys and servers on a ring so adding or removing nodes moves few keys, with virtual nodes and a Python implementation.
- Health Checks and Failover Learn active and passive health checks, liveness vs readiness, active-passive and active-active failover, failure detection and split brain, with simulations.
- Rate Limiting and Its Algorithms Learn why systems limit traffic and how token bucket, leaky bucket, fixed window, sliding window log and sliding window counter work, with Python code.
Caching
- Caching Fundamentals and Strategies Learn what a cache is, where caches live, hit rate math and the cache-aside, read-through, write-through, write-around and write-back strategies, with Python.
- Cache Eviction Policies and LRU Compare FIFO, LRU, LFU, random and TTL eviction, implement an O(1) LRU cache with a hash map and linked list, and measure hit rates on real access patterns.
- Cache Invalidation, TTL and Consistency Learn why cache invalidation is hard, how TTL, explicit deletion, versioned keys, write-through updates and event-driven invalidation work, and the races to avoid.
- Distributed Caches - Redis and Memcached Design a distributed cache: sharding with hash slots, replication, Redis and Memcached compared, data structures, persistence, hot keys, and a Python sharded cache.
- CDN and Edge Caching Learn how a CDN and edge servers cache content close to users, pull vs push CDNs, tiered caching, cache keys, headers, purging and dynamic acceleration.
- Cold and Warm Caches, Stampedes and Warming Understand cold and warm caches, how to pre-warm them, and how to prevent cache stampedes with locks, request coalescing, TTL jitter and early refresh, with Python.
Databases at Scale
- SQL vs NoSQL and Storage Types Choose between relational, document, key-value, wide-column and graph databases, and between block, object and file storage, with runnable Python examples.
- Database Replication Learn database replication for system design: leader-follower, multi-leader and leaderless setups, sync versus async, replication lag and failover, with Python demos.
- Sharding and Partitioning Learn data partitioning and database sharding: range, hash and directory strategies, hot spots, resharding, cross-shard queries and the cost of getting it wrong.
- Consistency Models for Designers Pick the right consistency level in system design: strong, eventual, causal and weak consistency, with quorum math and a runnable stale-read simulation.
- CAP Theorem in Practice Understand the CAP theorem and PACELC for system design interviews and real systems: consistency, availability, partitions, CP vs AP choices and a Python demo.
- CQRS and Database per Service Learn CQRS (command query responsibility segregation) and the database-per-service pattern: separate read and write models, sync strategies and trade-offs, with Python.
Asynchronous Systems
- Message Queues and Asynchronous Processing Learn message queues for system design: producers, consumers, acknowledgements, at-least-once delivery, idempotency, backpressure and scaling workers, with Python demos.
- Publish/Subscribe and Message Brokers Learn the publish/subscribe pattern and message brokers: topics, subscriptions, fan-out, consumer groups, RabbitMQ versus Kafka and delivery trade-offs, with Python.
- Event-Driven Architecture Learn event-driven architecture: events versus commands, choreography versus orchestration, event types, the outbox pattern, and when request-driven design is better.
- Event Sourcing and Event Streaming Learn event sourcing (state as a log of events), snapshots, replay and projections, and how it differs from event streaming platforms like Kafka, with Python demos.
- Saga Pattern: Distributed Transactions Learn the saga pattern for multi-service workflows: local transactions, compensating actions, choreography versus orchestration, idempotency and a runnable Python example.
Reliability and Operations
- High Availability and Failover Learn availability in system design: nines and downtime math, series versus parallel components, redundancy, active-passive and active-active failover, with Python calculators.
- Retries, Timeouts and Dead Letter Queues Build fault-tolerant calls: timeouts, retries with exponential backoff and jitter, idempotency, retry storms and dead letter queues, with runnable Python simulations.
- Circuit Breakers and Bulkheads Stop cascading failures with circuit breakers, bulkheads, timeouts, fallbacks and load shedding. Learn the states and thresholds, with runnable Python simulations.
- Monitoring, Logging and Tracing Learn observability for system design: metrics, structured logs, distributed tracing, SLIs, SLOs and error budgets, percentiles, alerting and the golden signals, with Python.
- Deployments and CI/CD Learn CI/CD pipelines and safe release strategies for system design: rolling, blue-green and canary deploys, feature flags, rollbacks and zero-downtime database migrations.
- Security for System Design Security essentials for system design: authentication versus authorization, tokens, RBAC and ABAC, encryption, secrets, defense in depth and threat modeling, with Python demos.
Core Algorithms and Data Structures for Design
- LSM Trees and B-Trees Understand the storage engines behind databases: B-trees for fast reads, LSM trees for fast writes, write-ahead logs, compaction and amplification, with runnable Python models.
- Bloom Filters Learn Bloom filters for system design: how bits and hashes answer 'definitely not' or 'maybe', sizing for a false-positive rate, uses in databases and caches, with Python.
- Counting at Scale: HyperLogLog and Count-Min Count unique visitors and heavy hitters with tiny memory: HyperLogLog for distinct counts and Count-Min Sketch for frequencies, with runnable Python implementations.
- Geospatial Indexing Learn how systems like Uber and Yelp find nearby points: geohash, quadtrees, S2 and H3 cells, proximity search and boundary pitfalls, with runnable Python examples.
- Tries and Top-K Build search autocomplete and trending lists: tries for prefix lookup, heaps for top-K, Space-Saving heavy hitters and sliding windows, with runnable Python examples.
Case Studies: Classic Designs
- Design a URL Shortener Design a URL shortener step by step: requirements, capacity estimates, base62 IDs, collisions, redirects, caching and sharding, with runnable Python simulations.
- Design a Rate Limiter Design a distributed rate limiter: where it sits, token bucket, fixed and sliding windows, Redis-style counters, race conditions and the headers to return, with Python.
- Design a Distributed Key-Value Store Design a Dynamo-style key-value store: consistent hashing, replication, quorum reads and writes, vector clocks, hinted handoff and anti-entropy, with Python simulations.
- Design a Chat System Design a messaging app: WebSocket connections, message routing, ordering with sequence numbers, offline delivery, group chat fan-out, presence and storage, with Python.
- Design a News Feed Design a social news feed: posting, fan-out on write and on read, the celebrity problem, hybrid feeds, ranking, caching and pagination, with runnable Python models.
- Design a Notification System Design a notification service: channels, templates, user preferences, queues, retries with backoff, deduplication, rate limits and delivery tracking, with Python.
- Design Search Autocomplete Design typeahead suggestions: requirements, a trie with top-K per node, offline aggregation pipeline, caching, sharding, personalization and filtering, with Python.
- Design a Web Crawler Design a web crawler: URL frontier, politeness and robots.txt, DNS and fetch workers, duplicate detection with hashes and Bloom filters, and spider traps, with Python.
- Design a File Storage Service (Dropbox-style) Design a cloud file storage and sync service: chunking, content hashes, deduplication, delta sync, metadata service, conflict handling and sharing, with Python.
- Design a Video Streaming Service Design a video streaming platform: upload pipeline, transcoding into renditions, segments and manifests, adaptive bitrate, CDN caching and cost estimates, with Python.
- Design a Ride-Sharing Service (Uber-style) Design a ride-hailing service: driver location updates, geohash and quadtree indexes, nearest-driver search, matching, trip state machine and surge pricing, with Python.
- Design a Payment System Design a payment service: the payment flow, idempotency keys, a double-entry ledger, state machines, retries, reconciliation and failure handling, with Python simulations.
Projects
- Project: A Load Balancer Simulator Build a load balancer simulator in Python: round robin, least connections, weighted choice, health checks and failover, then measure latency and fairness under load.
- Project: A Sharded Cache with Consistent Hashing Build a distributed cache in Python: an LRU node, a consistent hash ring with virtual nodes, TTL expiry, node failure and rebalancing, and measure hit rates and key movement.
- Project: A Message Queue with Retries and Dead Letters Build a message queue in Python: producers, consumers, acknowledgements, visibility timeouts, retry with backoff, a dead-letter queue and idempotent handlers.
- Project: A Capacity Planner Build a capacity planning calculator in Python: traffic, bandwidth, storage and server counts from a few assumptions, with growth, replication, peaks and a what-if table.
Practice and Interviews
- The System Design Interview Framework A repeatable plan for system design interviews: clarify requirements, estimate, sketch the API and data, draw the high-level design, go deep, and discuss trade-offs and bottlenecks.
- Back-of-Envelope Estimation Practice Practice system design estimation: powers of two, latency numbers, the seconds-per-day trick, and five worked problems for QPS, storage, bandwidth and servers, with Python.
- System Design Trade-offs Cheat Sheet A practical cheat sheet of system design trade-offs: SQL vs NoSQL, push vs pull, cache strategies, consistency levels, sync vs async, monolith vs microservices, with a Python decision helper.
- System Design Practice Questions Twelve system design practice prompts with requirement hints, key challenges and checklists, plus a Python self-scoring tool to review your answers like an interviewer.