Sign in
TodayMapLearnPracticeReview
Library
16 MINcoreFoundationsNot started

Performance vs Scalability

Performance is how fast a system handles a single request. Scalability is how well it handles more requests. They are related but distinct: a system can be fast and unscalable, or slow and scalable. Confusing them leads to bad architecture decisions.

Why this matters

If you don't know whether your problem is a performance problem or a scalability problem, you'll apply the wrong solution. Adding more servers (scaling out) doesn't fix slow code. Optimizing an algorithm doesn't help if your single database is the bottleneck. Naming the problem correctly is half the solution.

Prerequisites
  • What is System Design
Related
  • Latency vs Throughput
  • Horizontal Scaling
Used in
  • Capacity Estimation
  • Latency vs Throughput
Lesson

How it works

Performance measures how fast your system does one thing. Scalability measures how well it does many things. These sound similar, but they fail in different ways and need different fixes.

A Formula 1 car has high performance (fast lap time) but poor scalability (only seats one). A city bus has lower performance (slower) but better scalability (seats 50). Neither is 'better' — they solve different problems.

Definitions

Performance: how quickly a system responds to a given load. Measured in latency, throughput, resource utilization.

Scalability: how well a system maintains performance as load increases. Measured in how throughput changes when you add resources.

A system that handles 100 RPS at 50ms latency and 1000 RPS at 50ms latency is scalable. A system that handles 100 RPS at 50ms and 1000 RPS at 500ms is fast but not scalable.

Performance and scalability interact, but improving one doesn't always improve the other:

  • Fast but not scalable: A single PostgreSQL instance with a well-tuned query. Handles 100 RPS at 5ms. But at 10,000 RPS it falls over because one machine can't handle the connections.
  • Scalable but not fast: A distributed system across 100 nodes. Each request takes 200ms (slow) because of network hops, but the system handles 1M RPS without latency increasing.
  • Both: A system with a fast single-request path AND horizontal scalability. This is the goal — and it's hard.
How to diagnose

If latency is high at low load → performance problem. Fix the code, the algorithm, or the hardware.

If latency is low at low load but increases as load grows → scalability problem. Add capacity (scale out), partition data (shard), or introduce caching.

If latency is high at all loads → you have both problems. Start with the performance problem; it's usually cheaper to fix.

Check yourself
core

Your API responds in 50ms when 100 users hit it, but takes 500ms when 1000 users hit it. Is this a performance problem or a scalability problem?

Pick one answer.

Check yourself
core

Which change is a performance optimization (not a scalability optimization)?

Pick one answer.

How systems fail to scale. A system that doesn't scale doesn't usually fail loudly — it degrades gracefully at first, then catastrophically. The classic progression:

  1. Low load (10 RPS): everything is fast. CPU 5%, latency 20ms. Looks great.
  2. Medium load (500 RPS): latency creeps to 50ms. CPU 40%. Database starts showing some lock contention. Cache hit rate still 95%.
  3. High load (2000 RPS): latency jumps to 500ms. Why? Connection pool exhausted — requests queue waiting for a free DB connection. Cache hit rate drops to 85% because evictions are thrashing. CPU is now 80% but the bottleneck is I/O wait, not CPU.
  4. Critical load (5000 RPS): latency hits 10s. The DB connection pool is fully exhausted, requests time out at the app layer, clients retry, retry traffic doubles the load, more requests queue, the system cascades to failure.

The diagnosis at each stage is different. Stage 2 needs optimization (indexes, query tuning). Stage 3 needs scaling (read replicas, bigger cache). Stage 4 needs circuit breaking and load shedding — you're already over capacity, and adding more load makes it worse, not better. The mistake teams make is jumping to 'scale out' at stage 4 when they should have been shedding load and diagnosing the real bottleneck at stage 2.

Scalability lecture — scaling fundamentals— Supplementary explanation. The NO CAP lesson remains self-contained.
Amdahl's Law — the ceiling on parallel speedup

Gene Amdahl proved in 1967 that if a fraction P of a workload can be parallelized and (1-P) must run serially, the maximum speedup from N processors is 1 / ((1-P) + P/N). The implication is brutal: if 5% of your workload is serial (a single-threaded lock, a serial commit log, a synchronous cross-shard query), then even with infinite processors your speedup is capped at 1 / 0.05 = 20x. Most real systems hit this wall: database transactions need a serial commit log, distributed coordination needs a leader, garbage collection has stop-the-world phases. This is why 'just add more servers' eventually stops working — you hit the serial fraction. The system design response: minimize the serial fraction. Use sharding to keep transactions single-shard. Use append-only logs (no locking for reads). Use eventual consistency where possible (no coordination needed). The goal is to drive P toward 1.0.

Real systems make the trade-off explicit.

Redis optimizes for performance first: single-threaded, in-memory, ~100K ops/sec on one instance, sub-millisecond latency. It scales horizontally through Redis Cluster (sharding across N nodes), but each shard is still single-threaded — so throughput scales linearly with shards, but per-key latency stays flat at ~1ms. The designers explicitly separated the two concerns: 'be the fastest possible single instance' was the goal; horizontal scaling was layered on later via sharding.

Cassandra optimizes for scalability first: distributed, multi-primary, no single point of failure, linear horizontal scaling. But per-request latency is higher than Redis — typically 5-20ms due to network hops, quorum reads (reads from multiple replicas), and write-path coordination. Cassandra trades per-request performance for the ability to handle petabytes across hundreds of nodes with no leader.

The lesson: when you pick a database, you're picking which side of the performance/scalability trade-off to optimize for. There is no 'best' — there is only 'best for your workload.' A session cache wants Redis. A time-series log across 1000 nodes wants Cassandra. Most systems need both, layered: Redis in front of Postgres for hot reads, Cassandra for write-heavy event logs.

Check yourself
interview

You profile your monolithic service and find 10% of the request time is spent in a single-threaded in-memory lock (a global registry that all requests touch). You scale from 1 to 10 app servers. What's the maximum speedup you can possibly achieve?

Pick one answer.

Try this
interview

Your monitoring shows: at 200 RPS, CPU is at 30%, DB connection pool is 20% utilized, cache hit rate is 92%. There's no obvious single slow query. Last year's incident showed p50 jumped to 400ms at 1000 RPS, and the DB connection pool was 100% saturated at 1500 RPS.

Black Friday is approaching. Your e-commerce API normally runs at 200 RPS with p99 latency of 80ms. Last year on Black Friday you hit 2000 RPS and p99 spiked to 5s, losing sales. You have budget for either (a) a major code optimization project, or (b) doubling server capacity. Which do you choose?

Engineering mental model

Mental model. Think of Performance vs Scalability as a deliberate boundary in a system. The boundary exists because something becomes harder to manage when everything is done in one place: latency, scale, failure isolation, consistency, cost, or team ownership. The useful question is not “what does Performance vs Scalability mean?” but “what pressure makes this boundary worth introducing, and what new failure mode does it create?”

Design lens

Before choosing Performance vs Scalability, name the workload, the critical user path, the dominant bottleneck, the failure you are trying to absorb, and the trade-off you are willing to accept. If you cannot name those five things, the design is probably premature.

Original NO CAP systems visual for Performance vs Scalability.
Image unavailable. Original NO CAP systems visual for Performance vs Scalability.
Performance vs Scalability: a compact system-thinking visual.— Original NO CAP visual.
// Pseudocode
request = receive()
result = performance_vs_scalability(request)
return result

// Production questions:
// 1. What happens on timeout?
// 2. Can this operation be retried safely?
// 3. What is the bottleneck?
A minimal engineering sketch for reasoning about Performance vs Scalability.

Back-of-the-envelope reasoning

Numerical lens: write down traffic, payload size, read/write ratio, peak multiplier and durability target before choosing a component. The numbers should justify the architecture.

Interactive sandboxdeterministic

Interactive thought experiment: Performance vs Scalability

Change the variables below and predict what breaks first in Performance vs Scalability. The production lab can later reuse these same inputs.

System pressure24%
Try this

Change one variable at a time. Predict the failure mode first, then move the slider and see whether your mental model matches the simplified system response.

Hint

If you are stuck on Performance vs Scalability, start by drawing the request path and marking every network hop, stateful component, queue, cache and failure boundary. Then estimate where the system will saturate.

Check yourself
solid

You increase traffic by 10× in a system using Performance vs Scalability. What should you inspect first?

Pick one answer.

Check yourself
interview

Which statement is the safest engineering habit when using Performance vs Scalability?

Pick one answer.

Try this
interview

You have dashboards for traffic, latency, errors and saturation. You can change the architecture, but every change has operational cost.

Production scenario: your system uses Performance vs Scalability, traffic suddenly spikes, and p99 latency doubles. What is your first move?

Interview drill

Answer this without notes: When would you choose Performance vs Scalability, and when would you intentionally avoid it? Mention at least one bottleneck it addresses, one failure mode it introduces, and one alternative. Then quantify the workload you are designing for.

Engineering lens

A useful engineering lens for Performance vs Scalability: define the problem it solves, the simpler design that fails first, the constraint that forces you to introduce this concept, and the new failure modes the concept creates.

Numerical sanity check

Back-of-the-envelope reasoning beats fake precision. State your traffic, payload, concurrency and growth assumptions explicitly, then calculate enough to know whether the current architecture is orders of magnitude away from the target.

Check yourself
interview

Do not optimize for a memorized definition. Reason from the workload and failure mode.

Imagine the simplest version of a system using Performance vs Scalability. What breaks first as traffic grows by 10×, and what would you change before reaching 100×?

Pick one answer.

Trade-offs

What you gain, what you pay

Pros
  • +Naming the problem correctly points to the right fix.
  • +Performance optimizations are often cheap (code changes).
  • +Scalability optimizations are often additive (add more nodes).
Cons
  • −Performance and scalability can conflict: adding network hops for scalability can hurt single-request performance.
  • −Scalability fixes cost money (more servers).
  • −Performance fixes can introduce complexity (caching, async).
Failure modes

How this breaks in production

  • Adding more servers when the code is slow (doesn't fix the problem).
  • Optimizing algorithms when the database is the bottleneck.
  • Caching everything when the real issue is connection pool exhaustion.
Common mistakes

Don't fall into these traps

  • •Confusing 'fast' with 'scalable'.
  • •Treating scalability as a single axis — it has throughput, latency, and data-volume dimensions.
  • •Forgetting that scalability has a cost (more servers = more money + more complexity).
Where you see it

Real systems using this

Every system that needs to handle growth.Every performance review and capacity planning meeting.Every 'why is the app slow?' investigation.
Teardowns

How real systems implement this

  • Redis — Single-threaded, extremely fast per-request (performance). Scales by sharding across multiple Redis instances (scalability). The designers explicitly separated the two concerns.
  • Cassandra — Lower single-request performance than Redis (network hops, consensus), but linear horizontal scalability. Designed for scalability first.
Interview prompts

Practice saying it out loud

  • Q1What's the difference between performance and scalability? Give an example of each.
  • Q2If your system is slow, how do you decide whether to optimize code or add servers?
  • Q3Can a system be both high-performance and highly scalable? What's the tension?
Research

Further reading & references

System Design Primer
Open source
ByteByteGo — Scale from zero to millions
ByteByteGo
System Design Tutorial
GeeksforGeeks
System Design Roadmap
roadmap.sh
Foundations reference
Reference
Foundations reference
Reference
Foundations reference
Reference

Core explanations are original NO CAP material. External references are provided for deeper study and standards.

What next?

Mark as understood once the mental model clicks.

Next recommended

Latency vs Throughput