Course contentsShow
← System Design
Lesson 1522 of 1,91937. Real-World System: URL ShortenerFree lesson

Read-Heavy Workload and Database Scaling

Analyze the read-to-write ratio (100:1 or higher) and justify read replicas for handling redirect traffic.

Read-Heavy Workload and Database Scaling

What you'll learn: How to scale a URL shortener's database to handle massive redirect traffic by understanding read-to-write ratios and deploying read replicas.

Understanding the Read-to-Write Ratio

A URL shortener exhibits an extremely read-heavy workload—every redirect (reading the original URL) vastly outnumbers URL creation (writing a new entry). Industry data shows ratios of 100:1 or higher: for every URL created, it may be clicked hundreds or thousands of times over its lifetime. Some viral links push this ratio even further.

This imbalance creates a predictable bottleneck: your primary database server handling both reads and writes will hit CPU and I/O limits from redirect queries long before it struggles with the occasional write operation.

The Read Replica Solution

Read replicas are copies of your database that handle only read queries. Your architecture splits traffic:

  • Primary database: Handles all writes (new URL creation, updates)
  • Read replicas: Handle redirect lookups (the overwhelming majority of traffic)

With replication, your primary asynchronously copies data to multiple replicas. A load balancer distributes redirect queries across replicas, multiplying your read capacity linearly. Need to handle 10x traffic? Add more replicas.

Why This Works for URL Shorteners

  1. Eventual consistency is acceptable: A few milliseconds delay before a new short URL appears on replicas doesn't matter
  2. Simple queries: Lookups by short code are fast, cacheable, and index-friendly
  3. Cost-effective scaling: Replicas are cheaper than sharding or massive vertical scaling
  4. Geographic distribution: Place replicas near users for lower latency

Key Takeaway: URL shorteners' 100:1+ read-to-write ratio makes read replicas the most effective scaling strategy, allowing you to multiply read capacity while keeping a single source of truth for writes.