Home›Learn›The course

The course: from one database to millions of users

Where do I start, and what comes next?

33 lessons in 8 modules, or a short path for your goal. Free, no account, progress saved in this browser.

System design courses treat the database as one box. This course opens it: each module follows the same data further, from one query on one server to many servers in many regions.

0 of 33 lessons read. Start: Start here →

Module 1 · 0 of 4 read

Foundations

The words, and one query followed from your app to the disk and back.

  1. 1Start hereThe basics: a row, a page, a commit
  2. 2Ten conceptsIndex, transaction, replication and the rest, in a library
  3. 3How a query travelsOne UPDATE, ten steps, with and without an index
  4. 4Database napkin mathRows per page, index size, WAL per second, restore time
Module 3 · 0 of 2 read

Transactions

What a commit promises, and what two sessions at once can break.

  1. 11Lost updates and write skew
  2. 12What a commit waits for
Module 4 · 0 of 5 read

Scale

More traffic: connections, caches, replicas, and when one server is not enough.

  1. 13System design, from one serverWhat it is, what you trade, and what to add first
  2. 14System design, at the database25 ideas, each followed into the database
  3. 15Connection pooling
  4. 16Redis, the cache in front
  5. 17Engines side by sideReplica lag and five other scenarios
Module 5 · 0 of 4 read

Spread the data

Splitting data across servers, and the keys that decide where rows go.

  1. 18Unique IDs at scale
  2. 19Consistent hashing at the database
  3. 20Cassandra, built to spread
  4. 21Multi-tenant SaaSSharding by tenant
Module 6 · 0 of 4 read

Stay up

Failures, elections, backups, and what each one loses.

  1. 22CAP as settings you choose
  2. 23Consensus and leaders
  3. 24Backups and restore time
  4. 25Lab notebooksMeasured: commits, indexes, failures
Module 7 · 0 of 4 read

Architecture

Many services, one truth: events, migrations, upgrades and access.

  1. 26Sagas and the outbox
  2. 27Migration playbooks
  3. 28Major version upgrades
  4. 29Database security
Module 8 · 0 of 4 read

Whole systems

Everything together, in designs you can copy.

  1. 30Design a URL shortener
  2. 31Chat and messaging
  3. 32Social feed and timelines
  4. 33Online store: orders and inventory

Going for a staff role? The staff deep dive goes further on every topic.

How it works

Go deeper

Each lesson is a page on this site, in an order that builds: one query first, then one server, then many servers, then whole systems. A bar under the breadcrumb on every lesson shows where you are and links to the next one.

A lesson is marked read when you reach the end of it. That progress lives in this browser only. Nothing is sent anywhere, and there is no account.

Or follow a goal

Here for something specific?

Each path is a short ordered list of pages for one goal, with a line on why each one is there.

Path 1

I have a database interview

Aim to be able to draw each step on a whiteboard and say what the file is called. That is the level these loops ask for.

  1. Three rules that run every databaseDurability, pages and the log. Everything else hangs off these three.
  2. Follow one insert, end to endThe story you will tell in the first five minutes of any internals question.
  3. Engines side by sideA write, a crash, a lagging replica and a long transaction. These four come up in almost every loop.
  4. Break a database in the crash labSay what recovery replays, and why a checkpoint shortens it.
  5. The MVCC timeline and the B+ treeSnapshots, row versions, page splits and why index depth stays small.
  6. What a commit waits forThe sync and async trade-off, with the price of each.
  7. Nineteen real failuresPick three. Be ready to say what broke, what fixed it and what you would check first.
  8. Lost updates and write skewIsolation levels, watched instead of memorized. A favourite interview question.
  9. Lab notebooksReal numbers you can quote: what an index, a durable commit and a long transaction cost.
Path 2

I have a system design interview

The database part of a design loop asks three things: which store for which data and why, the numbers that justify it, and what breaks first as it grows. Read these in order, then practise on the prompts below.

  1. Application designs: what goes whereThe core skill: name the kinds of data in the system and put each one in the right store, with a reason.
  2. Database familiesKnow one sentence for each family: what it is good at and what hurts it.
  3. Redis, Cassandra and vector search, side by sideMost designs put one of these next to the main database. Say what each one is for and what it gives up.
  4. Estimate it, on any design docTurn users into writes a second, storage per year and memory. Interviewers want the arithmetic said out loud.
  5. Scale it, on any design docMultiply the load by ten and say which part breaks first. This is where senior answers are separated.
  6. What a commit waits forDurability and failover trade-offs, with the price of each choice.
  7. Lost updates and write skewDouble booking and overselling: the concurrency bugs every design question hides.
  8. Anti-patternsThe answers that sound fine and fail in production. Say why before the interviewer does.

Practise: eight prompts, ten minutes each

Start the timer and answer out loud or on paper: the kinds of data, where each one lives, the key you would use, the numbers (writes a second, storage per year), what breaks first at ten times the load, and one trade-off you are accepting. Then check yourself against the design doc.

1. A chat app for 50 million users. Each conversation shows its latest 50 messages, and history is kept forever.

2. A wallet where money must never be lost or counted twice, with balances shown instantly.

3. A live leaderboard for 10 million players, updated on every game, with each player's rank.

4. Ticket sales for a concert: 50,000 seats, 500,000 people at the moment sales open, no seat sold twice.

5. A home timeline for a social app: people follow others and see their posts newest first.

6. 100,000 devices each send a reading every 10 seconds. Dashboards show the last day; raw data is kept 90 days.

7. Search and AI answers over 20 million documents, where each user may only see the documents they are allowed to.

8. Memory for AI agents: each agent remembers facts and past conversations across sessions, for thousands of customers.

Path 3

I am on call and something is on fire

Read top to bottom. Do not skip the first step. Most of the time spent in an incident is spent looking in the wrong layer.

  1. Start from the symptomTen symptoms, each with the usual causes and the commands for your engine.
  2. Practice: On call tonightThree incidents to work through before the real one: a filling disk, a lock pile-up, a lagging replica.
  3. Name the layer first: process, memory or diskEvery incident lives in one of the three. Naming it first saves ten minutes.
  4. The first five minutes checklistWhat to check, in order, before you touch anything.
  5. Which log answers which questionFive logs run everything. Know which one to open.
  6. The cheat sheetEight rules per engine, short enough to read while paged.
  7. Replica behind?Where the queue builds, and the command that shows it.
  8. Sessions piling up on one row?How fast a pool runs out, and which timeouts to set.
  9. Disk or bloat growing without a reason?A long transaction is the usual cause. Find it first.
  10. Engine commands to runThe commands for PostgreSQL, MySQL and MongoDB.
  11. Slow query with an index?Column order, OFFSET paging and N+1 explain most of these.
Path 4

I am choosing a database

The engine is the last decision to make. First write down the workload: what reads, what writes, how big, and what a lost commit costs.

  1. Application designsFourteen design docs and a picker. Find the application closest to yours and start from its placement.
  2. Database familiesB-tree, LSM, column, in-memory, distributed SQL and more, and the traffic each one suits.
  3. Pick the database from the workloadStart from what the application does, not from fashion.
  4. The three engines, side by sideHow each behaves in the same four situations.
  5. On-prem or cloudWhat changes when someone else runs the database.
  6. Why the bill is huge, and what to cut firstWhere the money goes, and a safe order for cutting it.
  7. When it starts to hurtThe signs that you outgrew a single node, and the options after.
  8. Where to run itOn-prem, managed, EC2 or Kubernetes, with the people cost counted.
Part 1 of 4 · Learn · 23 pagesAll pages

How do databases actually work? From one row on disk to transactions: the words you need, PostgreSQL, MySQL and MongoDB from the files up, then Redis, Cassandra and vector search, side by side, and the query and concurrency traps.