Skip to content
Knowledge Hub

Design: build a shortener that handles 38,600 req/s Intermediate

Estimated reading time: 1 min read

You have a list of components and a budget. Drag each component into the right tier. Every time you add or remove one, p99, error rate, database load and cost are recalculated instantly.

  • Goal: meet every requirement at the lowest possible cost.
  • Try also: find a design that meets the requirements without a CDN, and one without Redis. Which costs more, and why?
Design

Build a URL shortener that handles 38,600 req/s

Your shortener is about to run a big campaign. Per the case study estimate, peak reads are ~38,600 req/s, while writes are only ~39 req/s.

Simplified assumptions for the game: 1 app instance handles ~8,000 req/s, 1 PostgreSQL node handles ~10,000 primary-key lookups/s, the CDN absorbs ~50% of redirects, and Redis hits ~95%. Illustrative numbers, not benchmarks.

Requirements

  • No errors at peak load, p99 ≤ 50 ms
  • Block bots spamming the link-creation API
  • Cost ≤ 20 units/month

Press + Add on each layer to choose a component. On a computer you can drag a component onto a layer. Metrics update right away.

Tap a component to see what it does.

Users Client
EdgeCDN, load balancer, rate limit
AppService that handles requests
CacheBuffer layer in front of the database
DataWhere links are stored
p99 latency3,000 ms
Error rate100 %
Database load150 %
Cost0 units
  • No PostgreSQL yet: newly created links have nowhere to be stored.
  • No App service yet to handle redirects.
  • No rate limiter yet: a bot can spam the link-creation API and fill up the database.

The numbers in the game are round assumptions for easy math, not benchmarks. How to estimate peak load is covered in the URL shortener case study.