Interview Q&A · 30 questions · 6 answered publicly
Performance & Scalability Interview Questions
Ordered by how often they're asked. Sign in free to see every answer, rate your confidence and run timed mock interviews.
-
Most asked What is the difference between vertical and horizontal scaling?
Summary
Vertical scaling adds resources (CPU, RAM) to one machine; horizontal scaling adds more machines behind a load balancer. Vertical is simpler but has hard limits and a single point of failure; horizontal scales further and improves availability but requires stateless services and distributed coordination.
Longer Answer
Stateless application servers scale horizontally easily; databases are harder (replicas, sharding). Start vertical where it's cheap, design for horizontal scaling of the stateless tier from the beginning.
Key Points
- Vertical: bigger machine
- Horizontal: more machines
- Stateless services scale out
- Databases need special strategies
-
Most asked What's the difference between latency and throughput?
Summary
Latency is how long one operation takes (e.g., p99 request time); throughput is how many operations complete per unit of time (requests/second). Improving one doesn't automatically improve the other; batching raises throughput but can increase latency.
Longer Answer
Little's Law links them: concurrency = throughput × latency. If latency doubles at the same throughput, you need twice the concurrent capacity (threads, connections).
Key Points
- Latency: time per operation
- Throughput: operations per second
- Little's Law: L = λ × W
- Batching trades latency for throughput
-
Most asked How do you approach a performance problem methodically?
Summary
Define the goal and measure (which metric, which percentile, under what load), reproduce, profile to find where time is actually spent (traces, CPU/memory profilers, query analysis), fix the biggest bottleneck, and re-measure, repeating until the goal is met.
Longer Answer
Avoid optimizing by intuition. Common culprits: database queries (N+1, missing indexes), external calls in series, chatty network round trips, serialization of big payloads, lock contention, GC pressure and synchronous work that could be async or cached.
Key Points
- Set measurable goals
- Profile, don't guess
- Fix the biggest bottleneck
- Re-measure
-
Most asked How do load balancers work, and what algorithms do they use?
Summary
Load balancers distribute requests across healthy backends using algorithms like round robin, least connections, weighted, or consistent hashing (for affinity), and remove unhealthy instances using health checks. L4 balancers route TCP/UDP connections; L7 balancers understand HTTP and can route by path, header or host.
Longer Answer
L7 features: TLS termination, path-based routing, retries, sticky sessions (avoid when possible), request buffering. Global load balancing (DNS/anycast) routes users to the nearest region.
Key Points
- Round robin / least connections / hashing
- Health checks
- L4 vs L7
- Avoid sticky sessions
- Global LB for regions
-
Most asked Why are timeouts, retries and circuit breakers essential for performance and reliability?
Summary
Without timeouts, slow dependencies tie up threads and connections until the whole service stalls (cascading failure). Retries recover from transient errors but can amplify load; circuit breakers stop calling a failing dependency for a while so it can recover and callers fail fast.
Longer Answer
Set timeouts per call based on SLOs, retry only idempotent operations with exponential backoff, jitter and a retry budget, and use bulkheads (separate pools) to isolate dependencies.
Key Points
- Timeouts on every remote call
- Bounded retries with jitter
- Circuit breakers fail fast
- Bulkheads isolate failures
-
Most asked What are the most common database-related performance problems?
Summary
N+1 queries, missing or wrong indexes, fetching too many rows or columns, deep OFFSET pagination, long transactions holding locks, too many connections, unbounded queries in hot paths, and running analytics on the OLTP database.
Longer Answer
Fix with eager loading, proper indexes, select only needed columns, keyset pagination, short transactions, pooling, and moving reporting to replicas/warehouses.
Key Points
- N+1 and missing indexes
- Over-fetching
- OFFSET pagination
- Lock contention
- Analytics on OLTP
- Why should application servers be stateless, and where does state go?
- How does autoscaling work and what are its pitfalls?
- What are common concurrency bottlenecks in web applications?
- How does a CDN improve performance?
- When does asynchronous I/O improve performance, and when doesn't it?
- How can garbage collection affect application performance?
- What are Core Web Vitals and how do you improve them?
- How do you load test a system effectively?
- How would you scale a read-heavy system?
- How would you scale a write-heavy system?
- How do you reduce payload sizes in web applications?
- How do you do capacity planning?
- What is the 'chatty API' problem and how do you fix it?
- How can moving work to background jobs improve performance?
- Why does tail latency matter more as systems fan out?
- Why does connection reuse (keep-alive, pooling) matter for performance?
- How can serialization become a bottleneck?
- What is load shedding?
- What is graceful degradation?
- What changes when you scale to multiple regions?
- How can adding caches or indexes hurt performance?
- What are cold starts and how do you reduce them?
- What are common mistakes when benchmarking?
- How do algorithm and data structure choices affect backend performance?