The website is slow. How do you troubleshoot it?
In one line: Start with how users are affected, use metrics to narrow down which layer is slow — CDN, load balancer, application, database or a dependency — then drill in with traces and logs, mitigate quickly, and fix the root cause.
Step 1 — Understand the problem
- Slow for everyone or some users? One page/API or all? Since when? Did anything change (deployment, config, traffic spike, a marketing campaign)?
Step 2 — Check the high-level metrics (golden signals)
- Latency (p95/p99), traffic, errors and saturation on the dashboards.
- Compare with the same time yesterday or last week.
- Check the deployment timeline — a slowdown that starts right after a release points to that release.
Step 3 — Narrow down the layer
- Client/CDN/DNS — is the slowness before reaching your servers? Check CDN hit ratio and synthetic checks from different regions.
- Load balancer — target response time, unhealthy targets, surge queue, 5xx counts.
- Application — CPU/memory of pods, garbage collection pauses, thread pool exhaustion, pod restarts, CPU throttling.
- Database — slow query log, CPU, locks, connection count, missing indexes.
- Dependencies — slow third-party APIs, caches (Redis) down or with low hit rate, queues backing up.
Step 4 — Use traces and logs
- A distributed trace shows exactly where the time goes (for example 2.8 of 3 seconds spent in one SQL query).
- Logs show timeouts, retries and errors.
Step 5 — Mitigate quickly
- Roll back a bad deployment, scale out pods, add a missing index (carefully), disable a heavy feature with a flag, increase cache TTLs, or rate-limit abusive traffic.
Step 6 — Fix and prevent
- Fix the real cause (query optimisation, caching, code fix, capacity).
- Add alerts on latency SLOs, and a load test to catch it next time.
- Write a post-mortem if users were badly affected.
Example: p99 latency jumped from 400 ms to 5 s after a release. Traces showed a new query scanning a whole table. Rolled back in 3 minutes, added the index, redeployed the next day with a performance test in the pipeline.
Tip for interviews: be methodical: "measure → narrow down → mitigate → fix → prevent". Interviewers care more about the method than the exact tool.