ProductionAdvanced6h

Performance & scaling.

Profiling, connection pools, and horizontal scaling.

What is performance and scaling?

Performance is how fast your service handles one request; scaling is how it copes as requests multiply. The two are linked: fixing a slow query helps both. The discipline is measuring first, finding the real bottleneck, and addressing that rather than guessing.

Why it matters

Slow services lose users and cost money, and the wrong fix wastes weeks. Most backend bottlenecks are the database or unnecessary work, not the language. Engineers who measure before optimizing solve the actual problem; those who guess add complexity that does not help. This is a senior-defining habit.

What to learn

  • Measuring before optimizing, and finding the bottleneck
  • Latency vs throughput
  • Database connection pooling
  • N+1 queries and how to batch them
  • Vertical scaling vs horizontal scaling
  • Statelessness as the key to scaling horizontally
  • Load testing to find the breaking point

Common pitfall

Optimizing code that is not the bottleneck — micro-tuning a loop while the real cost is an unindexed query making thousands of database round trips. Profile under realistic load, find where the time actually goes, and fix that. Premature optimization adds complexity and rarely touches the true limit.

Resources

Primary (free):

Practice

Load-test one endpoint and record its throughput and p95 latency. Find the bottleneck — likely the database — fix it with an index or connection pooling, then re-test and compare. Done when you can show a before-and-after number and name what the bottleneck actually was.

Outcomes

  • Measure throughput and latency before changing anything.
  • Locate the true bottleneck instead of guessing.
  • Use connection pooling and batching to cut database load.
  • Explain why statelessness enables horizontal scaling.
Back to Backend roadmap