Load/Bearing
Field notes

The ideas behind every box

Start with the fundamentals: one article per building block you place in the game. Then see how they combine in full case studies, and how to write the code in a low-level design round.

Fundamentals

The building blocks you place in the game, in the order the levels need them.

  1. 01

    Back-of-the-envelope estimation

    Level 1, 2, 7

    Before you draw a single box, work out how much traffic, data and bandwidth you are designing for.

  2. 02

    Load balancing and horizontal scaling

    Level 2, 11

    Add machines instead of buying bigger ones, and put something in front that spreads the work and routes around failures.

  3. 03

    Caching

    Level 3, 4, 7, 11, 12

    Keep the answers to popular questions in memory so the database only sees the questions nobody asked recently.

  4. 04

    Database indexing

    Level 3

    Before you buy another database, make each query touch fewer rows. Indexes are the cheapest scaling you'll ever do.

  5. 05

    SQL vs NoSQL

    Level 12

    Choose a database by its data model and access patterns. The label on the box matters much less.

  6. 06

    Database replication

    Level 3, 5, 11

    Copies of your database give you more read capacity and a standby for when the primary dies. They cost consistency.

  7. 07

    CDNs and edge caching

    Level 6, 12

    You can't make light faster, but you can shorten the distance by serving bytes from a city near each user.

  8. 08

    Message queues and backpressure

    Level 7, 9, 10

    Accept work now, do it at a pace you can sustain, and make sure you eventually catch up.

  9. 09

    Rate limiting

    Level 8

    Decide how much each client may ask for, and say no early and cheaply when they ask for more.

  10. 10

    Availability, redundancy and failover

    Level 11, 2

    Every component fails eventually. Design so that one failure costs you capacity, not the whole site.

  11. 11

    Sharding and consistent hashing

    Level 12, 13

    When one primary can't absorb your writes, split the data so each database owns a slice.

High-level design

High-level design case studies. Each one combines the fundamentals into a full system.

  1. 12

    URL shortener and ID generation

    A tiny product with a real design question: how do you hand out billions of short, unique keys without a bottleneck?

  2. 13

    News feed and fan-out

    Level 14, 13

    Precompute every user's feed when someone posts, or assemble it when they open the app? The answer is both.

  3. 14

    Notification service

    Level 9

    Deliver each message once, on the right channel, at the right time, even though every provider and network in the path can fail.

  4. 15

    Chat systems and real-time connections

    Millions of open connections, messages that must arrive in order, and users who are offline half the time.

  5. 16

    Monitoring and alerting systems

    Level 15

    Take in a flood of alerts without dropping one, collapse them into incidents a person can act on, and keep working when everything else is on fire.

  6. 17

    Running a design interview

    A system design round is graded on how you get to an answer. Here's a sequence and a clock that keep you in control.

Low-level design

Low-level design: object models, design patterns and working Java code you can write in 90 minutes.

  1. 18

    SOLID and the six patterns worth knowing

    Principles that keep classes easy to change, and the handful of patterns that come up in almost every low-level design round.

  2. 19

    Coding an LRU cache and a rate limiter

    Two classics you should be able to write from memory in Java: O(1) LRU eviction and a thread-safe token bucket, with tests.

  3. 20

    Parking lot in 90 minutes

    The classic LLD problem: clarify, model the entities, leave an extension point, and handle two cars racing for the last spot.

  4. 21

    Splitwise: expenses, splits and settling up

    Model shared expenses so equal, exact and percentage splits share one code path, then settle the group in as few payments as practical.

  5. 22

    Elevator system: state machine and scheduling

    Model each car as a state machine that refuses illegal moves, and keep the dispatch policy swappable.