Back to explorer
System Architectures 30 Min

Design a URL Shortener (TinyURL)

MEDIUM
System Architecture DiagramInteractive Zoom
Design a URL Shortener (TinyURL) architecture diagram

URL Shortener (TinyURL) Architecture

URL shortening services map long, complicated URLs to compact 6 or 7-character string hashes. This guide details how to construct a robust, high-availability shortener.


1. Architectural Goals

1. High Availability: TinyURL must be highly available with 99.99% uptime.

2. Low Latency: Link redirection should take <100ms.

3. Scalability: Handle 100 million new URLs created per day.


2. High-Level Design Overview

We map long URLs to 6-character short hashes using Base62 encoding (a-z, A-Z, 0-9).

To guarantee key uniqueness without database coordination overhead, we implement a Key Generation Service (KGS).

The KGS pre-generates unique string keys and stores them in a KGS DB. Web servers query the KGS for unused keys, ensuring no duplicate mapping can ever occur. We also keep a Redis cache to optimize the redirection path (GET /short_url).


3. Real-World Case Studies & Corporate Optimization

  • Microsoft (Bit.ly): Bit.ly uses a highly optimized key generation service to shorten billions of links. They store active mappings in distributed memory caches to perform lookups in single-digit milliseconds.
  • Twitter / X: Developed the t.co link shortener service to wrap all links posted on the platform, leveraging high-throughput distributed lookups to prevent malicious phishing scams.
  • Amazon: Amazon utilizes its custom shortener amzn.to to optimize social media links, routing traffic through regional caches for ultra-fast response times.

4. References & Tech Blogs