Scalability, Latency and Back-of-the-Envelope Estimates

Learn the vocabulary of system design: vertical vs horizontal scaling, latency vs throughput, availability, and quick capacity estimates.

Intermediate · about 5 hours · difficulty 3/5

Learn first: HTTP, HTTPS and TLS, NoSQL Databases

High-level design (HLD) interviews are common for SDE-2 roles and increasingly appear for strong freshers and interns at product companies. Even when not asked directly, this vocabulary helps you discuss your projects convincingly.

Core vocabulary

  • Vertical scaling: a bigger machine. Simple, but has a ceiling and a single point of failure.
  • Horizontal scaling: more machines behind a load balancer. Needs stateless application servers (sessions in Redis or tokens, not in server memory).
  • Latency (time per request) vs throughput (requests per second). Report latency as percentiles: p50, p95, p99. Averages hide slow tails.
  • Availability: "three nines" (99.9%) allows about 8.8 hours of downtime a year; four nines about 53 minutes. Redundancy and removing single points of failure raise it.
  • Reliability, fault tolerance and graceful degradation (serve cached data when a dependency is down).

Back-of-the-envelope estimation

  • Useful constants: a day has about 86,400 seconds (round to 10^5), so 1 million requests per day is roughly 12 requests per second on average; plan for peaks of 2-10x.
  • Storage: users x items per user x bytes per item x retention. 100 million tweets per day at 300 bytes is about 30 GB per day.
  • Bandwidth: requests per second x response size.
  • Know the rough latency ladder (memory vs SSD vs network) from computer architecture.

Why this matters

Estimates decide the design. 12 requests per second fits a single server and database; 100,000 per second needs caching, sharding and queues. Always estimate before choosing components.

Good enough to move on: you can estimate QPS, storage and bandwidth for a service like Instagram in five minutes and explain why stateless servers make horizontal scaling easy.

Key concepts

  • Vertical vs horizontal scaling
  • Stateless services
  • Latency, throughput and percentiles
  • Availability and nines
  • Single points of failure and redundancy
  • QPS, storage and bandwidth estimates
  • Latency numbers

Mini project

Write one-page capacity estimates for three services (a URL shortener, WhatsApp, and YouTube uploads): daily active users, read and write QPS with peaks, storage over five years and bandwidth, and state which numbers would force caching or sharding.

Check yourself

A service gets 50 million requests per day with a 5x peak factor. Roughly what peak QPS must it handle, and could a single server cope?

Free resources