Scaling a Next.js App to Millions of Requests
Caching layers, edge rendering, and database patterns that keep a Next.js app fast under real load.
Next.js is fast by default, but "fast in dev" and "fast at a million requests an hour" are different problems. Here's what actually moves the needle when traffic gets serious.
Render where it makes sense
Static and incrementally-regenerated pages should never hit your origin on every request. Reserve server rendering for genuinely dynamic, per-user routes, and push the rest to the CDN edge.
Cache deliberately
Layer your caching: CDN for full pages, a shared cache like Redis for expensive queries, and HTTP cache headers everywhere. Measure hit rates, a cache you can't observe is a cache you can't trust.
Mind the database
Serverless functions exhaust connection pools fast. Use a pooler, keep queries indexed for the access patterns you actually have, and read from replicas where consistency allows.

