A Framework for Any Design

The seven steps every case study on this site follows, how long to spend on each, and what interviewers expect from you at each step.

15 minLesson 2 of 6
On this page
  1. The seven steps and their time budget
  2. Step 1: Clarify the problem
  3. Step 2: Estimate the scale
  4. Step 3: Define the API (optional)
  5. Step 4: Model the data
  6. Step 5: High-level design
  7. Step 6: Deep dives
  8. Step 7: Bottlenecks and failures
  9. Which steps to always do and which to shorten
  10. In the interview
  11. What to practise next

The framework is a fixed order of seven steps for answering any system design question: clarify the problem, estimate the scale, define the API, model the data, draw a high-level design, go deep on the hard parts, and then look for bottlenecks and failures. It solves the problem of having too much to say and no order to say it in. Without an order, candidates jump between caching, sharding and endpoints, and the interviewer cannot tell whether the design works.

The seven steps and their time budget

Every case study on this site uses these steps as its headings. The minutes below assume a 45-minute slot, which is described in how the interview works. The table is a summary of the sections that follow.

StepMinutesWhat you produce
1. Clarify the problem5Functional and non-functional requirements, and what is out of scope.
2. Estimate the scale4Requests per second (average and peak), storage and bandwidth.
3. Define the API (optional)0 to 3The main endpoints, if the interviewer asks or time allows.
4. Model the data3The records, how they are looked up, and the kind of store.
5. High-level design10A diagram in which both reads and writes work.
6. Deep dives10Two or three hard parts, with the options and a choice.
7. Bottlenecks and failures5What breaks at ten times the load, or when a component dies.

The budget leaves a few minutes of slack. In a 60-minute slot, give most of the extra time to steps 6 and 7.

The steps below use a pastebin as the example, a service that stores a block of text and returns a link to it.

Step 1: Clarify the problem

You ask questions until you can list what the system must do, how well it must do it, and what you will not build. Ask about features first, then about scale, and then about the qualities the interviewer cares about, such as latency, availability and durability. Interviewers expect this step every time, because a design for the wrong requirements cannot be rescued by good engineering later. Keep it to about five minutes.

Scoping the pastebin
Interviewer

Design a service where people paste text and share a link to it.

You

Can anyone with the link read a paste? Can pastes expire? Is there a size limit? Do we need accounts or editing?

Interviewer

Yes, anyone with the link can read it. Expiry is optional. The limit is 1 MB. No accounts and no editing.

You

How many pastes are created per day, and how often is each one read?

Interviewer

About 5 million new pastes a day, averaging 10 KB, and each is read about ten times.

The answers become three short lists. The functional requirements are to create a paste of up to 1 MB with an optional expiry and get a link, and to read a paste by its link. The non-functional requirements are that a paste is never lost, that reads take under 100 ms and are highly available, and that links are hard to guess. The out-of-scope list holds accounts, editing, search and syntax highlighting. Say the out-of-scope list aloud, so that the interviewer does not expect those features later.

Step 2: Estimate the scale

You turn the numbers from step 1 into requests per second, storage and bandwidth, so that you know what the design has to handle. Round a day to 100,000 seconds (it is really 86,400), and say that you are rounding; estimation covers the method in detail.

For the pastebin, 5 million creates a day is about 50 writes per second, and assuming the peak is three times the average gives 150. With ten reads per paste, reads are about 500 per second and 1,500 at peak. Storage is 5 million pastes of 10 KB, which is 50 GB a day and about 18 TB a year. Only the last number matters for the design: 18 TB a year that never stops growing is too much to keep in a database row, and that decides the next step.

Step 3: Define the API (optional)

This step is optional. Do it when the interviewer asks for it, when an API decision shapes the design (for example whether clients poll or the server pushes), or when you have time left. Otherwise skip it and spend the minutes on deep dives. If you do it, list only the main endpoints with their error cases.

Pastebin API
POST /pastes
  body: { "content": "...", "expires_in_days": 7? }
  201 Created   { "id": "x7Kp2QaZ", "url": "https://paste.example/x7Kp2QaZ" }
  413 Content Too Large   over 1 MB
 
GET /pastes/{id}
  200 OK   { "content": "...", "created_at": "...", "expires_at": "..." }
  404 Not Found   no such paste, or it has expired

Step 4: Model the data

You list the records the system stores, how each one is looked up, and which kind of data store fits those lookups. If records are only ever fetched by id, a key-value store or a blob store is enough.

The pastebin has two records, and both are looked up only by id. The metadata record holds the id, the size, the timestamps and a pointer to the content, which comes to about 200 bytes and fits in a key-value or relational store. The content is up to 1 MB of text that never changes, so it goes in blob storage under a key such as pastes/{id}. The id is a random string of 8 letters and digits. The service inserts the row only if the id is not already taken and retries with a new id otherwise, and the id space is large enough that guessing a valid link is impractical.

Step 5: High-level design

You draw the boxes that make the system work and show that both the write path and the read path function end to end. Start with the simplest design that meets the requirements, and add a component only when you can say which requirement or number needs it.

The paste servers keep no state, small metadata rows go in a database, large content goes in blob storage, and frequently read pastes are kept in a cache.Browser to Load balancer (HTTPS); Load balancer to Paste service; Paste service to Paste cache (get / set); Paste service to Metadata DB (row by id); Paste service to Blob storage (content).BrowserLoad balancerPaste servicePaste cacheMetadata DBBlob storageHTTPSget / setrow by idcontent
The paste servers keep no state, small metadata rows go in a database, large content goes in blob storage, and frequently read pastes are kept in a cache.

After drawing, walk through one write and one read to prove that the design works. The tracer below does that for the pastebin, and it ends with a failure to show what the design does when a component is down.

Create a paste, read it twice, then lose blob storageUse the arrows or ← → keys
  1. Create a paste, read it twice, then lose blob storage, step 1Browser to Load balancer; Load balancer to Paste service; Paste service to Paste cache; Paste service to Metadata DB; Paste service to Blob storage.BrowserLoad balancerPaste servicePaste cacheMetadata DBBlob storage

    1A user submits 12 KB with POST /pastes. Any paste server can take it.

  2. Create a paste, read it twice, then lose blob storage, step 2Browser to Load balancer; Load balancer to Paste service; Paste service to Paste cache; Paste service to Metadata DB; Paste service to Blob storage.BrowserLoad balancerPaste servicePaste cacheMetadata DBBlob storageput x7Kp2QaZ
    id
    x7Kp2QaZ

    2The server picks a random id, x7Kp2QaZ, and writes the content to blob storage first.

  3. Create a paste, read it twice, then lose blob storage, step 3Browser to Load balancer; Load balancer to Paste service; Paste service to Paste cache; Paste service to Metadata DB; Paste service to Blob storage.BrowserLoad balancerPaste servicePaste cacheMetadata DBinsert rowBlob storage
    id
    x7Kp2QaZ

    3Then it inserts the metadata row, so that no reader can find a row that points at missing content. A crash between the two writes leaves an orphan blob, which a cleanup job removes later.

  4. Create a paste, read it twice, then lose blob storage, step 4Browser to Load balancer; Load balancer to Paste service; Paste service to Paste cache; Paste service to Metadata DB; Paste service to Blob storage.BrowserLoad balancerPaste servicePaste cacheMetadata DBBlob storage
    id
    x7Kp2QaZ
    status
    201

    4Both writes are durable, so the server returns 201 and the link.

  5. Create a paste, read it twice, then lose blob storage, step 5Browser to Load balancer; Load balancer to Paste service; Paste service to Paste cache; Paste service to Metadata DB; Paste service to Blob storage.BrowserLoad balancerPaste servicePaste cachemissMetadata DBBlob storage
    id
    x7Kp2QaZ
    reads
    1

    5Someone opens the link. The paste is new, so the cache misses.

  6. Create a paste, read it twice, then lose blob storage, step 6Browser to Load balancer; Load balancer to Paste service; Paste service to Paste cache; Paste service to Metadata DB; Paste service to Blob storage.BrowserLoad balancerPaste servicePaste cacheset x7Kp2QaZMetadata DBBlob storage
    id
    x7Kp2QaZ
    reads
    1

    6The server reads the row to check that the paste has not expired, reads the content, and caches both until the paste expires at the latest. Pastes never change, so a cached copy is never stale.

  7. Create a paste, read it twice, then lose blob storage, step 7Browser to Load balancer; Load balancer to Paste service; Paste service to Paste cache; Paste service to Metadata DB; Paste service to Blob storage.BrowserLoad balancerPaste servicePaste cachehitMetadata DBBlob storage
    id
    x7Kp2QaZ
    reads
    2

    7The next read hits the cache, so most of the 500 reads per second should end here.

  8. Create a paste, read it twice, then lose blob storage, step 8Browser to Load balancer; Load balancer to Paste service; Paste service to Paste cache; Paste service to Metadata DB; Paste service to Blob storage.BrowserLoad balancerPaste servicecreates: 503Paste cacheMetadata DBBlob storagedown
    id
    x7Kp2QaZ
    reads
    2

    8Blob storage goes down. Cached pastes still load, but creates fail with 503, because accepting a paste that cannot be stored would break the "never lost" requirement.

1 / 8

Step 6: Deep dives

You pick two or three parts of the design where the choice is hard and explain the options and your decision for each. Choose the parts that the numbers from step 2 make difficult, or the ones the interviewer points at. For each one, state the problem, compare at least two options by what each costs, and say what would make you choose differently.

For the pastebin the hardest part is where the content lives. Putting it in the database row gives one write, one read and one system to run, and it is the right choice when the total data is small or the values are a few kilobytes. At 18 TB a year it bloats the database and makes backups slow. Putting the content in blob storage with a pointer in the row is cheap per byte and grows without limit, but each create needs two writes and each cache miss needs two reads, and the gap between the two writes has to be handled, which is why the tracer writes the blob first. Here the blob store is the better choice because the content is large, never changes and keeps growing. A second possible deep dive is id generation, covered in unique IDs.

Step 7: Bottlenecks and failures

You ask what breaks first if the load grows by ten times, and what happens when each component fails.

For the pastebin, ten times the load is 15,000 reads per second at peak. The paste servers are stateless, so you add more of them, and you grow the cache as a cluster. The metadata grows by about 1 GB a day (5 million rows of about 200 bytes), so when one database is no longer enough you partition it by id, and because ids are random the rows spread evenly. On the failure side, a dead cache node sends its reads to the metadata store and blob storage, the metadata database fails over to a replica, and a blob storage outage stops creates while cached reads continue.

Which steps to always do and which to shorten

Interviewers expect steps 1, 5 and 6 every time. Without step 1 they cannot judge your design against requirements, and steps 5 and 6 are where most of the evaluation happens. Step 7 is expected too, but it can be short. Steps 2 and 4 are expected in a short form: one or two numbers that shape the design and the main lookups. Step 3 is the only one you may skip entirely, and you should do it only briefly when asked.

The interviewer tells you to skip ahead

If an interviewer says "skip the estimates" or "go straight to the hard part", do what they ask. The framework is a default order for when no one is steering. If you skip estimation, still ask "roughly how much data are we storing?", because one number is often enough to choose between a database and a blob store.

Naming a step without using it

Saying "now the estimates" and then ignoring the numbers is a ritual, and interviewers notice. Each step has to change something later. In the pastebin, the 18 TB a year from step 2 is the reason content moves out of the database in steps 4 and 6.

Running out of time

Spending too long on requirements and estimates is the usual cause. In a 45-minute slot, aim to finish the high-level design by about minute 27, and if you are behind, cut step 3 and shorten step 7.

In the interview

Say the plan once at the start and then name each step as you reach it, so that the interviewer can follow and steer. For example: "Storage grows 18 TB a year, so I'll keep content out of the database. The design works end to end now, so shall I go deeper on content storage or id generation?"

Questions to expect:

  • "Can we skip the estimates?" Yes, if the interviewer prefers it. Ask for one number, such as how much data is stored or how many requests per second, and say what it implies. A single figure is usually enough to choose between storage options.
  • "How do you decide what to go deep on?" Pick the part where the numbers or the requirements make the choice hard, and where there are at least two reasonable options. Also offer the interviewer a choice: "I could go into storage or id generation, which do you prefer?"
  • "What if the interviewer disagrees with your estimate?" Accept their number and rerun the arithmetic. Interviewers care that your method is sound and that the design changes when the input changes.
Opening a design questionStrong answer
Interviewer

Design a pastebin.

You

I'll start with requirements and rough scale, then sketch the design, and then go deep on one or two parts. First, can pastes expire, is there a size limit, and roughly how many are created a day?

Interviewer

Expiry is optional, the limit is 1 MB, and about 5 million a day.

You

That is about 50 writes a second and around 18 TB of content a year, with reads ten times higher. The yearly storage is the number that matters, so I'll keep content in blob storage and only a small row in the database. Should I define the API first, or go to the architecture?

Interviewer

Go to the architecture.

Quick check

You are 30 minutes into a 45-minute interview and have not started the deep dives. Which step is the best one to cut or shorten?

Why does a create write the blob before the metadata row in the pastebin?

An interviewer says, "Skip the estimates, I don't care about numbers." What is the best response?

What to practise next

Each step has its own lesson, starting with Requirements and Scope. For a full case study that follows these seven steps, read Design a URL Shortener.