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

Database Queries Per Second

Calculate expected read and write QPS to inform database scaling decisions.

Database Queries Per Second

What you'll learn: How to calculate expected read and write queries per second (QPS) to determine if your database can handle a URL shortener's traffic without falling over.

Why QPS Matters

When designing systems like a URL shortener, you can't just pick a database and hope it works. Databases have throughput limits—they can only handle so many operations per second before performance degrades or requests start failing. By calculating your expected QPS before launch, you inform critical scaling decisions: single server vs replicas, sharding strategy, caching layer size, and more.

Calculating Read QPS

Using estimates from previous lessons (DAUs, requests per user):

If you expect 10 million URL redirects per day (your read-heavy traffic), spread across 24 hours with peak traffic at 3× average:

  • Average reads/sec = 10,000,000 / 86,400 ≈ 116 QPS
  • Peak reads/sec ≈ 116 × 3 = ~350 QPS

Calculating Write QPS

If users create 1 million new short URLs per day:

  • Average writes/sec = 1,000,000 / 86,400 ≈ 12 QPS
  • Peak writes/sec ≈ 12 × 3 = ~36 QPS

The Read/Write Ratio Insight

Your URL shortener has a 10:1 read-to-write ratio (10M reads vs 1M writes). This heavily influences architecture:

  • A single MySQL instance handles 1,000–5,000 QPS easily → you're safe for now
  • But plan read replicas or caching for growth
  • Write QPS is low → single primary database sufficient initially

When to Scale

If projections show >1,000 read QPS, you'll need read replicas or aggressive caching. If >500 write QPS, consider sharding or vertical scaling.

Key Takeaway: Calculating read and write QPS from traffic estimates lets you right-size your database architecture, avoid over-engineering, and plan scaling thresholds before they become emergencies.