Skip to content

System Design Interview: A Step-by-Step Framework (Worked Example)

A 6-step framework for the system design interview, applied to a full worked example: designing a URL shortener, from requirements and estimates to scaling.

The system design round is where a lot of good engineers stall. You can write clean code, ship features and debug production, and still freeze when the interviewer says “design a URL shortener” and hands you a blank whiteboard. The problem is rarely knowledge. It is the lack of a structure: without one, you jump straight to databases, forget to ask what the system actually needs to do, and run out of time before the interesting part.

This guide gives you a six-step framework you can reuse for almost any prompt, then walks through it end to end on a classic question: design a URL shortener like bit.ly.

The 6-step system design interview framework

A typical round lasts 45 to 60 minutes. A rough budget:

StepWhat you doTime
1. RequirementsAgree on what the system must and must not do~5 min
2. EstimatesRough numbers for traffic, storage and bandwidth~5 min
3. APIThe handful of endpoints clients will call~5 min
4. Data modelWhat you store and how you look it up~5 min
5. High-level designBoxes and arrows for the main request paths~10 min
6. Deep dives and trade-offsScaling, bottlenecks, failure modes~15 min

The order matters. Each step gives you the facts you need for the next one, and the interviewer sees you reason instead of recite. Now let’s apply it.

Step 1: Clarify the requirements

Never start drawing before you know what you are building. Ask questions and write the answers down where the interviewer can see them.

Functional requirements (what it does):

  • Given a long URL, return a short one, like tc.io/aZ3kP9x.
  • Visiting the short URL redirects to the original.
  • Optional: custom aliases, expiry dates, click counts.

Non-functional requirements (how well it does it):

  • Redirects must be fast, because they sit in front of every click.
  • Very high availability for redirects. A broken short link is a broken link everywhere it was shared.
  • Short codes must not be guessable in sequence, if the interviewer cares about privacy.
  • The system is read-heavy: a link is created once and clicked many times.

Agree on scope out loud: “I’ll cover creation, redirects and basic analytics, and skip user accounts unless you want them.” Interviewers reward this.

Step 2: Back-of-the-envelope estimates

Back-of-the-envelope estimation is not about precise numbers. It tells you whether one database is enough or whether you need caching and sharding. State your assumptions clearly; the interviewer may change them.

Assume (these are interview assumptions, not real bit.ly figures):

  • 100 million new URLs per month
  • 100 redirects for every URL created (read-to-write ratio of 100:1)
  • About 500 bytes per stored record (short code, long URL, timestamps, owner)

Then:

  • Writes: 100M ÷ ~2.6M seconds in a month ≈ 40 new URLs per second.
  • Reads: 40 × 100 ≈ 4,000 redirects per second on average, with peaks several times higher.
  • Storage: 100M × 500 bytes = 50 GB per month, about 600 GB per year, roughly 3 TB over five years.

How long should the short code be? With base62 (a–z, A–Z, 0–9), 6 characters gives 62⁶ ≈ 56.8 billion combinations and 7 characters gives 62⁷ ≈ 3.5 trillion. Five years at 100M per month is 6 billion URLs, so 7 characters leaves a lot of headroom.

The conclusion: writes are modest, reads are where the load is, and the dataset fits comfortably on a few machines. That points us toward caching before anything exotic.

Step 3: Design the API

Keep it small:

POST /api/urls
  body: { "longUrl": "https://...", "customAlias": "optional", "expiresAt": "optional" }
  returns: 201 { "shortUrl": "https://tc.io/aZ3kP9x" }

GET /{shortCode}
  returns: 301 or 302 redirect to the long URL, or 404

A good detail to raise: 301 vs 302. A 301 (permanent) redirect is cached by browsers, so repeat clicks may never reach your servers. That saves load but you lose click counts. A 302 (temporary) means every click hits you, which is what you want if analytics matter. Pick one and say why.

Also mention rate limiting on POST /api/urls, so one script can’t fill your database with spam links.

Step 4: The data model

The core lookup is “short code → long URL”, a perfect key-value access pattern:

urls
  short_code   (primary key)
  long_url
  created_at
  expires_at   (nullable)
  owner_id     (nullable)

There are no joins on the hot path. Both a relational database (PostgreSQL with the short code as the primary key) and a key-value or wide-column store (DynamoDB, Cassandra) work. At ~3 TB over five years, PostgreSQL is perfectly reasonable at first; say that a key-value store makes sharding simpler if the data grows much larger. Interviewers want the trade-off, not a brand name.

Step 5: High-level design

The two request paths:

Create: client → load balancer → app server → generate a short code → write to database → return the short URL.

Redirect: client → load balancer → app server → check cache → on a miss, read from database and fill the cache → return the redirect.

App servers are stateless, so you scale them horizontally behind the load balancer. The interesting decision is how to generate the short code. There are three common approaches:

  1. Hash the long URL (for example SHA-256, then take the first 7 base62 characters). Simple, but two different URLs can collide on the same 7 characters, so you must check the database and retry with a salt on a collision.
  2. A counter encoded in base62. Every new URL gets the next number, and you encode it. No collisions, but a single counter is a bottleneck and the codes are sequential and easy to enumerate.
  3. Pre-allocated ID ranges. Each app server asks a coordinator (a database sequence or a service like ZooKeeper) for a block of, say, 1,000 IDs and hands them out locally. No collisions, no per-request coordination. To avoid guessable codes, shuffle the IDs with a reversible scramble before encoding.

Option 3 is a strong answer. Explain why you rejected the others: that reasoning is what gets scored.

Step 6: Deep dives and trade-offs

Now go where the load is. Good topics for a URL shortener:

Caching the hot links. Click traffic is very uneven; a small share of links gets most of the clicks. Put a Redis cache in front of the database using the cache-aside pattern with LRU eviction. Short codes never change, so cache invalidation is easy: you only remove entries when a link is deleted or expires.

Scaling the database. Reads go to replicas; writes go to the primary. If the dataset outgrows one machine, shard by a hash of the short code so data spreads evenly.

Analytics without slowing redirects. Don’t write a click row synchronously on every redirect. Publish a click event to a message queue (Kafka, SQS) and let a separate worker aggregate counts. The redirect stays fast even if analytics fall behind.

Expiry. Check expires_at on read and return 404 for expired links. A background job deletes old rows later.

Failure modes. If the cache dies, the database takes the full read load: make sure replicas can absorb it for a while. If the ID coordinator dies, servers can keep issuing from the blocks they already hold.

Finish by summarising your design in two sentences and naming one thing you’d improve with more time. That closing shows judgment.

Common mistakes to avoid

  • Jumping to the solution. Ten minutes on requirements and numbers is not wasted time.
  • Naming technologies without reasons. “Kafka” is not an answer; “a queue so redirects don’t wait on analytics” is.
  • Designing for Google scale by default. If the numbers say one database is enough, say so.
  • Going silent. Think out loud. The interviewer is grading your reasoning.

Practise the framework, then practise it live

Read the framework once, then run it on two or three more prompts: a rate limiter, a news feed, a WhatsApp-style chat app. The steps stay the same; only the deep dives change. Our glossary covers every term used here in plain English.

If you have two or more years of experience and want structured practice with feedback, that is exactly what System Design for the AI Era is for: six live Saturday classes (7–9 PM PKT) where you write real design docs, get them reviewed, and finish with a live mock interview. Start with the free demo class on Saturday 28 November at 7 PM PKT, and decide after that.