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
- 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
- "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