Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST
System Design
System Design

3 AM Page: Our URL Shortener's Database Melted Under a Billion Redirects

Learn how to design a URL shortener that survives a billion redirects a day using Cloud CDN, cache keys, and smart redirect codes.

MCB Editorial
MCB Editorial
Tech Buzz Daily Desk · 10 min read ·
New story
3 AM Page: Our URL Shortener's Database Melted Under a Billion Redirects
Narrated by Study Buddy Narration
Voiceover Engine • Interactive Audio Sync
0:0010:00

Learning Objectives & Key Takeaways

0 / 4 Completed
🚀 Architecture Ready
100%
What you will learn
  1. Cloud CDN hits bypass your origin entirely, which is the only way to survive billion-scale redirect traffic.
  2. The cache key, not the full URL, decides whether Cloud CDN serves a hit or forwards to your backend.
  3. Choosing 301 over 308 silently changes whether browsers cache redirects forever on their own.
  4. Negative caching lets you cache redirect responses themselves, not just final destinations.
  5. Hot keys like viral short links still need origin protection even with CDN in front.

The Morning the Short Links Took Down Production

It was a Tuesday morning when the on call engineer got paged because p99 latency on redirect requests had jumped from 20 milliseconds to 4 seconds. The culprit was not a bug in the code, it was success. A marketing campaign using the company's shortened links had gone viral overnight, and every single redirect request was hitting the origin database directly.

The team had built a perfectly reasonable URL shortener for a startup serving a few thousand redirects a day. They had a load balancer, an application server, and a Postgres table mapping short codes to destination URLs. Nobody had designed for a billion redirects a day, and nobody had planned for what happens when every request bypasses caching entirely.

In the rest of this story
  1. Why Most of Your Traffic Should Never Reach Your Database
  2. Designing the Cache Key Correctly
  3. Choosing the Right Redirect Status Code
  4. Configuring Cloud CDN for Redirect Traffic
  5. Protecting the Origin When a Link Goes Viral
1 code example · 10 min read in full
Member-only story

Checking your membership…

Members read every Tech Buzz story in full, with code examples, audio and the discussion, plus every course, quiz and interview set in the Learning Dashboard.

0
MCB Editorial
Written By

MCB Editorial

Tech Buzz Daily Desk. Contributing deep-dive engineering architectures, cloud paradigms, and system design insights to Master Class Buddy.