System Design AI
Design brief
Product & backendBeginner35 min suggested

Design a URL Shortener

Create short links, resolve them quickly and handle expiry without sending users to the wrong destination.

Backend and product engineers designing software behavior.

Your approach: Use diagrams, tables or prose for customer contracts, state transitions and data ownership; include APIs only to the depth the question requests.

The problem

Design a URL shortener that creates links and redirects visitors to their original destination. Define the create and redirect contracts, how short codes remain unique, and how expiry and deletion affect cached redirects. Explain one failure from the visitor’s perspective.

  • Create 1 million links/day; each link receives 100 redirects on average.
  • Redirect traffic peaks at ten times the daily average. Store the destination and owner for one year.
  • Owners may expire or delete a link. Custom aliases and detailed analytics are optional follow-ups.

Work within these constraints

Redirect latency

State a p95 server response target, excluding the destination website and internet transit.

Required target: ≤ 100 milliseconds

Unique destinations

Concurrent creates and retries must not assign one short code to two different destinations.

Deletion and expiry

State a bounded delay for invalidating redirects and how clients see expired or deleted links.

What to deliver

1

API and data model

Define link creation, redirect and deletion responses, identifiers and ownership.

2

Read and write paths

Show durable link storage, code allocation and the redirect cache.

3

Capacity estimate

Estimate average and peak redirect QPS and one year of storage with stated record size.

4

Failure and tradeoff

Trace a duplicate create and a cache outage; compare two ways to allocate codes.