A Framework for Any Design

Seven steps with a time budget that turn any system design prompt into a structured answer, worked end to end on a small pastebin service.

16 minLesson 2 of 6
On this page
  1. The seven steps
  2. Worked example: a pastebin
  3. In the interview
  4. Common mistakes
  5. What to practice next

Two candidates know the same material. One hears "design a pastebin" and jumps between caching, sharding and the API. The other clarifies, estimates, then designs, and has time left for depth. The second one passes, on order alone.

A fixed order means you never skip a step, the interviewer can follow you, and no thought goes on what to do next.

The seven steps

Every case study on this site follows these steps, with these headings. Each step produces something the next one uses: the estimates decide the data store, the access patterns decide the keys, the hard parts decide the deep dives. Minutes are for a 45-minute slot with about 40 minutes of design, as in how the interview works.

StepMinutesWhat you produce
1. Clarify the problem5Functional and non-functional requirements, and what is out of scope.
2. Estimate the scale4Requests a second (average and peak), storage, bandwidth.
3. Define the API3The main endpoints or messages, with error cases.
4. Model the data3The records, how they are looked up, and the kind of store.
5. High-level design10A diagram where the main read and write paths both work.
6. Deep dives10Two or three hard parts, each with options and a choice.
7. Bottlenecks and failures5What breaks at 10 times the load, and what happens when each part dies.

That adds up to 5 + 4 + 3 + 3 + 10 + 10 + 5 = 40 minutes. In a 60-minute slot, give most of the extra time to steps 6 and 7.

Worked example: a pastebin

A pastebin stores a block of text and gives it a link. Here is the whole framework, at spoken length.

1. Clarify the problem

Scoping the pastebin
Interviewer

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

You

Are pastes public to anyone with the link? Can they expire? Is there a size limit? And do we need accounts or editing?

Interviewer

Anyone with the link can read. Optional expiry. Up to 1 MB. No accounts, no editing.

You

How many pastes a day, and how often is each one read?

Interviewer

About 5 million new pastes a day, averaging 10 KB. Ten reads per paste.

  • Functional: create a paste (text up to 1 MB, optional expiry) and get a link; read a paste by its link.
  • Non-functional: a created paste is never lost; reads are fast (under 100 ms) and highly available; links are hard to guess.
  • Out of scope: accounts, editing, search, syntax highlighting.

Requirements and scope covers which questions to ask.

2. Estimate the scale

Round a day to 100,000 seconds (really 86,400, so rates come out about 14% low). The estimation lesson explains the shortcuts.

  • Writes: 5 million ÷ 100,000 = 50 a second. Assume peaks of 3 times: 150.
  • Reads: 10 × 50 = 500 a second, 1,500 at peak.
  • Bandwidth out: 500 × 10 KB = 5 MB/s on average, 15 MB/s at peak. Small.
Estimate: Paste storage for one year

How much paste content is stored after one year?

You know
  • 5 million new pastes a day
  • 10 KB per paste on average
  • Ignore expiry and replication

Show the working
  1. Per day: 5 × 106 × 104 B = 5 × 1010 B = 50 GB
  2. Per year: 50 GB × 365 ≈ 18,000 GB = 18 TB

Estimate 18 TB (anything from 6 TB to 60 TB is a good answer)

18 TB a year, growing forever, is the number that shapes this design.

3. Define the API

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

4. Model the data

The metadata is a small row per paste (about 200 bytes: id, size, timestamps, a pointer to the content), looked up only by id. The content is up to 1 MB of text that never changes. So: metadata in a key-value or relational store keyed by id, about 5 million × 200 B = 1 GB a day; content in blob storage under the key pastes/{id}.

The id is 8 random characters from 62 letters and digits: 628 ≈ 2.2 × 1014 possibilities. After five years (9 billion pastes) a new id clashes about 1 time in 24,000, so insert-if-absent and retry. That ratio cuts both ways: one random guess in 24,000 also finds some paste, so a scraper can harvest them. If that matters, use 10 characters (about 1 in 90 million) and rate-limit 404s.

5. High-level design

Stateless paste servers. Small rows go in a database, large content in blob storage, hot pastes 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
Stateless paste servers. Small rows go in a database, large content in blob storage, hot pastes in a cache.
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 of text 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. In this order a reader never finds a row pointing at missing content; a crash in between leaves an orphan blob for a cleanup job.

  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 with 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 server checks the cache: a miss, since the paste is new.

  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

    6It reads the row (has it expired?) and the content, and caches both with a TTL that ends no later than the paste expires. Pastes never change, so nothing else can go 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 is a cache hit and touches neither store. Most of the 500 reads a 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 becomes unreachable. Cached pastes still load. Creates must fail with 503: accepting a paste you cannot store durably breaks the "never lost" requirement.

1 / 8

6. Deep dives

Pick the parts where the numbers are hardest. Here: where content lives, and id generation (see unique IDs).

Where paste content lives
OptionGood atBad atPick it when
In the database rowOne write, one read, one system to run.18 TB a year of large values bloats the database and slows backups.Small total data, or values of a few KB at most.
Blob storage, pointer in the row Usual defaultCheap per byte, grows without limit, built for large immutable objects.Two writes per create and two reads per miss; you must handle the gap between them.Large, immutable content that grows forever. This case.

What would change the choice: if the interviewer capped pastes at 4 KB and kept them for 30 days, the total would be about 5 million × 4 KB × 30 = 600 GB, and a single database would be simpler.

7. Bottlenecks and failures

At 10 times the load (15,000 reads a second at peak), add paste servers, since they are stateless, and turn the cache into a cluster. Metadata then grows about 3.65 TB a year (10 GB a day), so partition it by id; random ids spread evenly. Then walk the failures: a dead cache node sends reads to the stores, the metadata database fails over to a replica, and a blob storage outage stops creates.

In the interview

Say the plan once, then announce each transition:

  • "Before I draw anything, I want to pin down features and scale."
  • "Writes are 50 a second and storage grows 18 TB a year. That second number matters most, so I'll keep content out of the database."
  • "The design works end to end now. The two parts I'd like to go deeper on are content storage and id generation. Which interests you more?"

Follow-ups you should expect:

  • "Can we skip the estimates?" Yes, if the interviewer says so. Ask for the one number that matters ("roughly how much data?") and move on.
  • "Skip to the hard part." Go. The framework is a default order, not a script to defend.

Common mistakes

Quick check

In the pastebin, the interviewer changes the limit: pastes are at most 4 KB and expire after 30 days. With 5 million a day, about how much content is stored at any time?

Why does the create path write the blob before the metadata row?

Self-review: run the framework0 of 10

After your attempt, tick what you really did. Be strict: "I thought about it" is not "I said it out loud".

Scope and numbers

Interfaces

Design and depth

Failure and time

What to practice next

Each step has its own lesson, starting with Requirements and Scope. To see the full framework at case-study depth, work through Design a URL Shortener.