Skip to content

Case Studies

Every earlier module took one idea and followed it as far as it went: a cache, a replica, a queue, a saga. A real system uses a dozen of them at once, and the hard part is choosing the order. This module designs fourteen systems from the first line to the last, each one the way an engineer would grow it: start with the simplest design that works, find the number that breaks it, add the one thing that fixes that number, and repeat.

You will not be given the final architecture. You will be given a load, a stage and a lab, and you will read where the stage gives way before the lesson says what to add.

Every case study has the same shape, so after the first one you know where to look.

  1. Requirements. What the system must do, what it must never do, and which numbers matter. Many designs are decided here.
  2. Estimate. The back-of-the-envelope arithmetic: requests per second, storage, bandwidth. It tells you which of the three the design is built around.
  3. Stages. A lab starts with one server and one database, then adds one component at a time. Each stage opens with the figure that forced it. Raise the load in the lab and watch the next limit appear.
  4. Deep dive. The one part of the system that is specific to this case: the celebrity account, the fee row, the orphaned object, the home region.
  5. Failure. Several “What happens if” moments: what the loss of a cache, a region or a worker does to the numbers.
  6. Trade-offs. A table of what each decision gains, what it costs, and when the other choice is better.
  7. Interview. The same design as a question you answer in your own words before you read a strong answer.
  1. URL shortener (25 min). Read-heavy traffic, key generation, caching and redirects.
  2. Pastebin (25 min). Blob storage with metadata, and expiry.
  3. File storage (25 min). Chunking, deduplication, sync and metadata consistency.
  4. Notification system (25 min). Fan-out across push, email and SMS, retries, idempotency and preferences.
  5. Chat (25 min). One region: one-to-one and group delivery, presence, an order per conversation, and offline delivery.
  6. Social feed (25 min). Fan-out on write against fan-out on read, and the celebrity problem.
  7. E-commerce (25 min). The catalog, the cart, inventory reservation and a checkout saga.
  8. Payment system (25 min). Idempotency, a double-entry ledger, reconciliation and the myth of exactly-once.
  9. Ride sharing (25 min). Geospatial indexing, matching and high-rate location updates.
  10. Video platform (25 min). On demand: upload, a transcoding pipeline, object storage, a CDN and adaptive bitrate.
  11. Live streaming (25 min). Low-latency ingest, real-time transcoding and fan-out from the edge to many concurrent viewers.
  12. Global messaging (25 min). Chat at planet scale: delivery across regions, one order per conversation, and data residency.
  13. Search engine (25 min). Crawling, an inverted index, a ranking pipeline and index sharding.
  14. Object storage (25 min). Durability with copies and erasure coding, a metadata service, and consistency.
  15. Recap and quiz (20 min). The fourteen designs side by side, a checklist for an interview-style design, a sorting exercise and two quizzes.

The case studies fall into five groups, and the order inside a group is the order of the list. The URL shortener, the pastebin and file storage are about data that is stored once and looked up many times, with the metadata kept apart from the bytes; the first two are read-heavy services and file storage adds chunking and sync. The notification system, chat, the social feed, ride sharing and global messaging are about messages, feeds and real-time updates, where the work is delivering the right thing to the right people in the right order. E-commerce and the payment system are about money and inventory, where a repeated request or a lost step costs something real. The video platform and live streaming are about media: a very large number of bytes per second, a CDN, and a pipeline that converts what was uploaded. The search engine and object storage are about very large data, and about how an index or a metadata service decides where the data lives.

  • Start any design from the requirements and a back-of-the-envelope estimate, and say which of requests, storage and bandwidth the design is built around.
  • Begin with the simplest design that works, find the component that breaks first at a given load, and say which single change removes that limit.
  • Scale a design stage by stage, saying for each stage the figure that forced it, what it costs and what breaks next.
  • Name the pattern a problem calls for: a cache, replicas, a queue, a saga, a ledger, a geospatial index, a CDN, erasure coding.
  • Say what happens to a design when a cache, a worker, a region or a disk is lost, and what limits the damage.
  • Defend a design in an interview: state the trade-off of each decision and when you would choose the other side.

All the numbers in the labs are illustrative. They are chosen to make the limit of each stage visible and to compare designs, not to forecast any real product or to benchmark any real database, cache or server.

Built by GhaziAlibi.

© ShardCraft. All rights reserved.