Distributed systems
Explain what a database or a distributed system does under load and under failure well enough to defend a design choice from first principles, not from a diagram you memorised.
- 11 lessons, about 340 minutes
- 45 self-check questions with answers
- 16 diagrams
- 77 code samples, compiled and tested
- Interactive companion
- Free, no sign-up
Course content
Read the lessons in order. Each one builds on the one before.
Storage and transactions
How data is laid out on disk, found again quickly, and changed safely by many users at once.
- Concept45 minStorage engines and indexesHow a database keeps data on disk and finds it again. B-trees and LSM trees, the write-ahead log, fsync and group commit, read and write amplification, and how to design the indexes you add.HLDLLDSenior depth1 architecture diagram1 sequence flow9 code samples9 interviewer follow-ups
- Concept23 minErasure coding, replication and durabilityHow storage survives failures for less than three copies: a Reed-Solomon coder built and tested in C#, the cost of repair, durability computed from failure and repair rates, and reading the first k fragments to cut the tail.HLDLLDSenior depth5 code samples6 interviewer follow-ups
- Concept27 minTime-series databasesHow a database for metrics and sensor data takes millions of samples a second: chunks compressed with delta-of-delta and XOR (built and measured in C#), a label index of postings lists, and rollups that can be re-aggregated.HLDLLDSenior depth5 code samples5 interviewer follow-ups
- Concept31 minTransactions and isolation levelsWhat ACID really promises, the anomalies that appear when transactions overlap, how locking and MVCC implement each isolation level, and the patterns (atomic updates, locks, constraints, retries) that keep concurrent code correct.HLDLLDSenior depth1 sequence flow9 code samples8 interviewer follow-ups
Time, agreement and coordination
What changes when the data lives on many machines that disagree about the time, fail separately and still have to agree.
- Concept28 minTime, clocks and orderingWhy you cannot trust timestamps from different machines, and what to use instead. Happens-before, Lamport and vector clocks, hybrid logical clocks, TrueTime and commit wait, and the places where clocks quietly break real systems.HLDLLDSenior depth2 sequence flows5 code samples8 interviewer follow-ups
- Concept35 minConsensus, leader election and distributed locksHow a group of machines agrees on one order of events when some of them crash. Quorums, Raft leader election and log replication in a tested simulation, then leases and the fencing tokens that make a distributed lock safe.HLDLLDSenior depth1 architecture diagram2 sequence flows7 code samples9 interviewer follow-ups
- Concept29 minDistributed transactions, two-phase commit and sagasWhat to do when one business action touches two databases or services. Two-phase commit and its blocking problem, sagas and compensation, the outbox and inbox that make messages reliable, and why exactly-once is really effectively-once.HLDLLDSenior depth2 sequence flows6 code samples9 interviewer follow-ups
Streams, sketches and search
Logs that many readers share, summaries that answer questions about huge data in small memory, and the index behind search.
- Concept31 minLogs, streams and KafkaThe append-only log behind Kafka and change data capture: partitions, consumer groups, delivery semantics, the settings that decide whether acknowledged data survives, compaction, and event-time windows with watermarks.HLDLLDSenior depth1 architecture diagram8 code samples9 interviewer follow-ups
- Concept30 minProbabilistic data structures and sketchesAnswer questions about huge data in a few kilobytes: Bloom filters for membership, HyperLogLog for distinct counts, Count-Min for frequencies, quantile sketches for percentiles, reservoir sampling and MinHash, with error bounds.HLDLLDSenior depth11 code samples8 interviewer follow-ups
- Concept32 minSearch and inverted indexesHow full-text search works: analysis, the inverted index and posting lists, BM25 ranking, measuring relevance, immutable segments with refresh and merge, sharded search with global statistics, and keeping the index in sync.HLDLLDSenior depth1 architecture diagram1 sequence flow8 code samples9 interviewer follow-ups
- Concept30 minNear-duplicates and freshnessHow to find pages that are almost the same and decide when to look at a page again: simhash fingerprints and block tables for near-duplicates, and a freshness model, refresh policies and change-rate estimates for revisits, with tested C#.HLDLLDSenior depth7 code samples6 interviewer follow-ups1 decision checkpoint
Start with storage engines and indexes, then erasure coding and durability (how data survives disk failures for less than three copies) and time-series databases (compressing and indexing millions of samples a second), then transactions: how one database keeps data fast to find and safe to change. Then time and ordering: what changes when the data lives on many machines that disagree about the time and fail separately. Consensus and distributed transactions come next. The last section covers logs and streams (Kafka, delivery guarantees, change data capture), the sketches that answer questions about huge data in small memory, the inverted index behind search, and near-duplicate detection and page freshness (finding pages that are almost the same, and deciding when to look at a copy again).
After each lesson, close it and draw the mechanism from memory: the data structure, one write and one failure travelling through it, and what it costs. If you cannot draw it, you cannot defend it in a design review.
Mechanisms, not products: each lesson explains the idea and names the real systems that use it. Behaviour that differs by version or vendor is flagged as something to check, and all code is C# that the site's tests compile and run.