How do I scale a web app?
Scale in this order — measure first, then fix the real bottleneck:
- Measure: monitoring, error tracking and slow-query logs
- Cache & CDN: serve static files from a CDN; cache expensive results (Redis)
- Fix the database: indexes, efficient queries, connection pooling
- Go stateless & horizontal: run several app servers behind a load balancer (or serverless that autoscales)
- Move slow work to queues: emails, reports and imports run in the background
- Read replicas: send read-heavy traffic to database copies
- Split services last: only the parts that genuinely need independent scaling
Why this order: the cheapest fixes (caching, indexes) usually give the biggest wins.