System Design URL Shortener: Interview Talk Track

System Design URL Shortener: Interview Talk Track

A system design URL shortener interview talk track is a classic mid-level opener: clear APIs, heavy read skew, and a short-code uniqueness problem. Candidates commonly report this prompt at product companies because it forces encoding choices, redirect latency, and abuse controls without drowning you in social-graph complexity. This guide gives you a structured script from clarifying questions through capacity, data model, and tradeoffs.

Clarify before you draw

Do not invent a billion-user product in silence. Ask:

Talk track:

“I’ll assume high read skew on redirects, optional custom aliases, no hard TTL unless you want one, and basic click counts. Redirects should be fast and cacheable; create can be a bit slower.”

Write assumptions on the board. Interviewers correct scope early when you invite it.

APIs (keep boring)

Discuss 301 vs 302: 301 is cacheable aggressively by browsers/CDNs (good for permanent); 302 keeps control if you may change the target. Candidates commonly report interviewers accepting either with a reason.

Capacity estimate (order of magnitude)

Pick round numbers and show the method:

Talk track:

“Writes are modest; reads dominate. I’ll design for thousands of redirects per second with caching, and treat create as a lower QPS path with uniqueness enforcement.”

If they give different scale, redo the arithmetic out loud. The skill is flexibility, not the specific billions.

Short-code design

Common options:

ApproachProsCons
Base62 of auto-increment IDSimple, compactPredictable; needs distributed ID
Hash(long URL) truncatedDeterministic for same URLCollisions; truncation tradeoffs
Random base62 stringHard to guessCollision retry; not deterministic
Snowflake / KSUID then encodeDistributed-friendlyMore moving parts

Interview default many candidates use: distributed unique ID → base62 encode to ~7–8 characters (62^7 is large enough for many years at moderate create rates). Mention collision checks if you choose random.

Custom aliases: separate uniqueness constraint; reserve reserved words; rate-limit.

Redirect path (the hot path)

  1. Receive short code
  2. Lookup code → long URL (cache first)
  3. Emit 302/301 with Location
  4. Async or sampled analytics increment

Talk track:

“Redirect is cache-aside on shortCode. On miss, read primary store, populate cache with TTL. Click counting is async so it does not block the redirect.”

Data model (minimal)

Table urls:

Optional clicks aggregate or event stream. Do not design a full warehouse in the first pass unless asked.

Caching and CDN

Stampede: coalesce misses on a viral code.

Uniqueness and create path

Create flow:

  1. Validate URL (scheme, length, malware denylist ideally)
  2. Generate code (ID encode or random)
  3. Insert with uniqueness constraint; retry on conflict
  4. Optionally write cache
  5. Return short URL

If same long URL should map to one code, store a hash index of long URL → code and reuse.

Sharding (only when scale needs it)

Start with one primary + replicas. When range grows:

Do not draw six databases before one works.

Abuse, safety, and product edges

Mention briefly—shows senior taste:

Talk track:

“I’d rate-limit creates, support disable, and avoid trivially enumerable codes if links are sensitive.”

Consistency and failure modes

First ten minutes structure

  1. Requirements + non-goals (2 min)
  2. API + 301/302 choice (1 min)
  3. Capacity back-of-envelope (2 min)
  4. Encoding + schema (2 min)
  5. Hot path + cache (2 min)
  6. Scale-out / abuse if time (1 min)

Tradeoffs to keep ready

Soft practice note

URL shortener rounds are narration plus clean diagrams. If you want a Chrome side panel to rehearse this system design URL shortener talk track under timed pressure, Luna Interview is built for calm rehearsal. Use it to build structured communication—not to invent production war stories or to violate interview rules.

Day-of checklist

Keep the redirect path boring and fast—that is the URL shortener interview talk track.