#2Easy

Design TinyURL

You are designing the backend for a URL shortening service. Users submit a long URL and receive a short link (e.g., tiny.url/abc123). When anyone visits the short link, they are redirected to the original URL. The service must handle a high volume of redirects with low latency while reliably storing the URL mappings.

Functional Requirements

  • 1Given a long URL, generate a unique short URL
  • 2Redirect short URL to the original long URL
  • 3Short URLs should expire after a configurable time

Non-Functional Requirements

  • 1Handle 100:1 read-to-write ratio
  • 2Redirect latency < 100ms
  • 399.9% availability
  • 4Short URLs should be hard to guess

Scale

Daily Active Users

10M

Writes /sec

4

Redirects /sec

400

Read To Write Ratio

100

More stats

Total Urls Stored

500M

Test Cases

Normal Load

Average daily traffic with 100:1 read-to-write ratio

Writes /sec: 4Redirects /sec: 400

Marketing Spike

Viral marketing campaign causes 5x redirect traffic

Writes /sec: 4Redirects /sec: 2,000

Hints

Seen this question in a real interview before?

Companies

⚠ Full editor available on desktop

Components