{}DSA Atlas

Scalability Fundamentals

Performance vs scalability, latency vs throughput, vertical vs horizontal scaling, stateless services, load balancing recap, autoscaling, Little's Law and queueing intuition, and the classic journey from a single server to millions of users.

Intermediate5 interview questions

Key definitions

TermMeaning
Performancehow fast the system is for a single user / request
Scalabilityhow capacity grows as you add resources (ideally linearly)
Latencytime per request (measure p50, p95, p99)
Throughputrequests completed per second
Availabilityfraction of time the system serves requests successfully
Elasticityadding/removing capacity automatically with demand

A system has a performance problem if it's slow for one user, and a scalability problem if it's fast for one user but slow under load.

Vertical vs horizontal

Vertical (scale up) 4 vCPU 64 vCPU512 GB RAM simple · ceiling · single point of failure Horizontal (scale out) load balancer near-linear · redundant · needs statelessness
Scale stateless tiers out; scale stateful tiers up until you must partition.
VerticalHorizontal
Efforttrivialneeds stateless design, LB
Limitbiggest machinepractically unlimited
Fault tolerancenonebuilt-in redundancy
Cost curvesuper-linear at the toproughly linear
Downtime to scaleoftennone

Statelessness

clients LB app (stateless) app (stateless) app (stateless) sessions → Redis data → database files → object storage background work → queue
Any instance can serve any request because all state lives in shared, specialised stores.

Queueing intuition: why 100% utilisation is a disaster

utilisation →latency ~70%: knee of the curve 50% → ~2× service time90% → ~10×
Response time ∝ 1 / (1 − utilisation): keep headroom for tail latency and bursts.

Little's Law: concurrency = throughput × latency. Use it to size pools and to understand cascading failures (latency up → in-flight requests up → pools exhausted).

Load balancing (recap)

L4 vs L7, algorithms, health checks: see Proxies, load balancers & CDNs. Key system-design points:

  • Redundant load balancers (managed LBs are already redundant across AZs).
  • Health checks + connection draining for safe deploys.
  • Global load balancing (GeoDNS/anycast) for multi-region.

Autoscaling

TypeTriggerNotes
Reactive (target tracking)CPU %, requests per instance, queue depth, concurrencymost common; lag of minutes
Scheduledknown daily/weekly peakspre-warm before events
PredictiveML forecasts of trafficsmoother for regular patterns
Event-driven (KEDA)queue length, Kafka laggreat for workers

Pitfalls: scaling on CPU for I/O-bound services, slow instance start-up (pre-warmed pools, smaller images), databases that don't scale with the app tier (connection storms — use poolers like PgBouncer/RDS Proxy), and flapping (use cooldowns and scale-in protection).

From one server to millions of users

The AWS-flavoured evolution from the System Design Primer illustrates the path: DNS and CDN in front, load balancers, stateless web/app tiers split into read and write APIs, a memory cache, SQL primary with read replicas, object storage, a queue with workers for async writes, and eventually NoSQL, sharding and federation for the hottest data.

Architecture diagram of a system scaled to millions of users on AWS: client, DNS, CDN, load balancer, web servers, read and write APIs, memory cache, SQL write master and read replicas, object store, queue and worker service, NoSQL, sharded and federated SQL
Scaling to millions of users. Diagram from The System Design Primer by Donne Martin, licensed CC BY 4.0.
UsersTypical architectureDriven by
1–1kone server (app + DB), managed DB snapshot backupssimplicity
1k–100kseparate DB, LB + 2+ app servers (multi-AZ), CDN for staticavailability, static load
100k–1MRedis cache, read replicas, object storage, queues + workers, autoscalingread load, slow tasks
1M–10Mfunctional partitioning (separate DBs per domain), search engine, more caching, observabilitywrite load, team growth
10M+sharding, NoSQL for hot paths, multi-region, service decomposition, cell-based architecturedata size, global latency, blast radius

Interview questions

0 / 5 marked confident

Answer out loud first, then open the model answer. Mark a question confident only when you could explain it to an interviewer without notes.