AI Hints
Home›System Design Tutorial›Case Study: URL Shortener
System Design · Lesson 92 of 120

URL Shortener: Estimates

How big.

⏱ 2 min read▶ Video at 1:51:24🎓 Free
Watch this lesson in the System Design courseWatch on YouTube ↗Full System Design course

Now some quick math. How many requests per second, and how much storage? This tells us where the hard parts are.

URL Shortener: Estimates
From the video: URL Shortener: Estimates
  • Quick math
  • Requests per second
  • Storage

Estimating the shortener

A hundred million new links a month. People read links far more than they create them, so let's assume a hundred reads per write. Each record is about five hundred bytes. Run it. About forty writes per second, but almost four thousand reads per second. And three terabytes of data over five years.

shortener_math.pypython
links_month = 100_000_000
reads_per_write = 100
record_bytes = 500
seconds_month = 30 * 86_400

writes = links_month / seconds_month
print(f"writes/sec: {writes:,.0f}")
print(f"reads/sec:  {writes * reads_per_write:,.0f}")

total = links_month * 12 * 5
print(f"links in 5 years: {total / 1e9:.0f} billion")
print(f"storage: {total * record_bytes / 1e12:.0f} TB")
Output
writes/sec: 39
reads/sec:  3,858
links in 5 years: 6 billion
storage: 3 TB

What the numbers tell us

The numbers shape the design. It's very read heavy, so caching redirects is the big win. Six billion links need short codes with enough room. And three terabytes fits in a sharded database comfortably. Writes, at forty per second, are easy.

keyvalue
Read heavycache the redirects
6 billion linkscodes need room
3 TBshard, but modest
Writeseasy

Summary

The shortener is read heavy, with about four thousand reads a second, and six billion links over five years. Next, making the short codes.

Key takeaways
  • ~40 writes/sec
  • ~4,000 reads/sec
  • 6 billion links, 3 TB
Next up: URL Shortener: Short Codes — base 62