Caching Strategy is Everything
When you hit 100k users, you cannot render every page request on the server (SSR) without massive infrastructure costs. You need a caching strategy.
Incremental Static Regeneration (ISR) is the sweet spot. It allows you to retain the benefits of static generation (SSG) while ensuring content updates propagate.
Pro Tip: Use On-demand ISR (revalidateTag) over time-based revalidation for e-commerce sites. It saves thousands of build cycles.
Database Connection Pooling
Serverless environments are notorious for exhausting database connection limits. Each lambda spins up, opens a connection, and might not close it immediately.
The Fix: Use a connection pooler like PgBouncer or Supabase Transaction Mode. This allows thousands of concurrent lambda functions to share a small set of persistent database connections.
Image Optimization at Scale
Serving unoptimized images is the fastest way to kill your bandwidth budget and your SEO score. The next/image component is mandatory, but configuration matters:
- Use
AVIFformat whenever possible (smaller than WebP). - Define
sizesprop accurately to prevent downloading desktop images on mobile. - Offload image processing to a dedicated CDN if your build times skyrocket.
Scaling isn't about adding more servers; it's about removing bottlenecks.

