KatInterview

Design an Ultra-Low Latency Distributed Link Shortening Platform

System DesignModel answer
MediumModel answerSystem Designsystem-designdistributed-systemscaching

Last updated

Architect a scalable, high-availability URL shortener capable of handling heavy read workloads, instant redirects, custom aliases, and automated TTL cleanup.

Problem Statement

Design a distributed URL shortener service (similar to Bitly or TinyURL) capable of processing high volume with a strong read-to-write skew.

Requirements

Functional

  1. URL Encoding: Convert a long target URL into a short, unique code (e.g., https://short.link/a7B9kX2).
  2. Redirection: Resolve a short link to its original target URL with high responsiveness.
  3. Custom Vanity Links: Allow users to specify custom short aliases when available.
  4. Link Expiration: Support optional TTL (Time To Live) parameters after which links expire and cease to redirect.

Non-Functional

  1. Ultra-Low Latency: Redirect lookup latencies must maintain sub-100ms at $p_{99}$.
  2. High Availability: The read path must remain resilient even during single-node or regional failures.
  3. Capacity Target: Design for 100 million creation requests per month with a 100:1 read-to-write ratio.

Deliverables

Present an end-to-end system design addressing:

  • Estimation & scale requirements
  • RESTful API definitions
  • Data model and storage architecture
  • Collision-free short code generation strategy
  • Caching layer and read/write optimization paths
  • Trade-offs and failure scenarios

Hints

Hint 1

Calculate throughput requirements for reads vs. writes first to inform your storage and caching layer decisions.

Hint 2

Consider how pre-allocating integer ranges (or using a Key Generation Service) avoids database locks or collision retries during short code generation.

Hint 3

Evaluate HTTP 301 vs. HTTP 302/307 status codes carefully with respect to client-side caching and telemetry collection.