ScalingExpert

The site is slow. What is your first step?

“A single-server app with one Postgres database is slowing down as traffic grows. Walk me through what you do first, second and third, and what evidence moves you from one step to the next.”

What this tests

  • Measure before changing anything
  • Ordering the scaling ladder by cost and by what the evidence says
  • Vertical scaling and indexing before distributed anything
  • Naming the new problem each step introduces

Answers by level

Read the beginner answer first and notice what is missing.

First, measure: which resource is saturated and where the time goes. App CPU at 95% and DB idle is a different problem from DB CPU at 95% with app instances waiting on connections. A trace of a slow request tells me whether it is one slow query, many small ones (N+1), or an external call. Half the time the answer is a missing index or a query doing a sequential scan, which is a one-line fix with no architecture change.

Second, the cheapest capacity: vertical scaling. Doubling the instance size takes ten minutes and buys time to do the rest properly. Then horizontal for the stateless tier — move sessions out, add a load balancer, run three instances — which introduces the state problem and the balancer as a component to run. Third, the database, which is where growth actually bites: connection pooling if connections are the limit, a cache for hot repeated reads if the profile is read-heavy, read replicas if the read set is broad and lag is tolerable. Each of those introduces staleness in some form.

Sharding, queues and services come only when a specific measured problem demands them: write throughput beyond one primary, background work distorting request latency, or teams blocking each other. Every rung buys capacity by adding a problem, so I climb only as far as the evidence requires.

Green flags · Red flags

Strong green flag · Names connection-pool sizing against Postgres concurrency as a common hidden limit before reaching for replicas.
Green flags
  • Measures first: metrics, slow-query log, a trace
  • Fixes indexes and N+1 before adding infrastructure
  • Scales vertically before horizontally and names the ceiling
  • Orders database steps: pooling, cache, replicas, partitioning, each with a trigger
  • States the new problem each step introduces
  • Rejects the NoSQL-scales-better reflex
Red flags
  • "Move to microservices so it scales."
  • Adds a cache before knowing the read/write profile
  • Skips vertical scaling as "not real scaling"
  • Cannot say what evidence would move them to the next step

Follow-up questions

F1
DB CPU is 90%; the slow-query log shows one query at 60% of total time. Next step?
F2
You add read replicas and users see their own edits disappear. Why?
F3
When is sharding the right step?

Scenario

One 8-CPU server and one Postgres instance serve a marketplace. p99 has gone from 300 ms to 2.1 s over three months as listings grew from 200k to 4M. The proposal on the table is "Kubernetes plus Redis plus Kafka". Describe the first two hours of your investigation, the likely findings, and the smallest change that fixes the p99.

Learn this topic