Get Senior Engineers Straight To Your Inbox

Slashdev Engineers

Every month we send out our top new engineers in our network who are looking for work, be the first to get informed when top engineers become available

Slashdev Cofounders

At Slashdev, we connect top-tier software engineers with innovative companies. Our network includes the most talented developers worldwide, carefully vetted to ensure exceptional quality and reliability.

Top Software Developer 2026 - Clutch Ranking

Scale Next.js Jamstack to 10K+ with React Server Components/

Patrich

Patrich

Patrich is a senior software engineer with 15+ years of software engineering and systems engineering experience.

0 Min Read

Scale Next.js Jamstack to 10K+ with React Server Components

Scaling a Next.js Jamstack to 10K+ daily users with minimal ops

Context and goals

Audience growth was unpredictable, so the mandate was: fast first paint, stable costs, zero on-call. We targeted p95 TTFB under 300ms for cached pages, sub-1s for personalized views, and a monthly infra budget under $400 until 50K MAU.

Architecture overview

We kept the stack boring and serverless-friendly:

  • Next.js App Router with React Server Components (RSC) for data-fetching on the server and streamed HTML.
  • Static-first delivery via ISR and tag-based revalidation, backed by a global CDN.
  • API Routes/Server Actions for authenticated mutations; zero long-lived servers.
  • Managed Postgres with serverless connection pooling; no self-hosted cache layer.
  • Edge middleware for geolocation and AB flags; minimal logic at the edge to avoid cold paths.

React Server Components implementation

RSC let us lift data dependencies out of the client. We created a thin client shell and kept product lists, category pages, and article bodies as server components. Suspense boundaries streamed above-the-fold content first, then progressively hydrated small client islands (cart, search box, tracking). The result: fewer JS kilobytes, fewer waterfalls, and stable performance on low-end devices.

Key tactics that mattered:

Modern data server room with network racks and cables.
Photo by Brett Sayles on Pexels
  • Cache every fetch in RSC with a semantic key and revalidateTag on writes. Example: fetch(‘/api/products?cat=shoes’, { next: { tags: [‘cat:shoes’] } }).
  • Coalesce parallel fetches with Promise.all in the layout; never sequence catalog, price, and inventory queries.
  • Make analytics a client component loaded with defer; first interaction stays unblocked.
  • Server Actions for forms to skip API hops and reuse RSC cache invalidation.

Database design and optimization

Postgres schema emphasized read efficiency for hot paths. We denormalized a few counters (review_count, inventory_snapshot) and kept transactional truth in normalized tables. Composite indexes covered the majority of WHERE + ORDER BY patterns, e.g., (category_id, published_at DESC). Partial indexes served only active=TRUE rows, trimming bloat.

We avoided N+1 by querying view models in one round trip: product core joined to latest price and a precomputed availability table. On serverless, connections are scarce; we used a serverless pool (Neon) and kept transactions short, under 100ms. UUID primary keys with monotonic ULIDs improved index locality for recent inserts.

Close-up of HTML and JavaScript code on a computer screen in Visual Studio Code.
Photo by Antonio Batinić on Pexels
  • Slow query budget: p95 under 40ms. Anything slower got an index or a query rewrite.
  • Explain-analyze in CI for top 20 queries using recorded bind parameters.
  • Write amplification reduced via append-only event tables plus nightly compaction to materialized summaries.
  • Encrypted at rest, row-level security for multi-tenant campaigns without extra shards.

Caching and revalidation strategy

We used ISR for landing pages with revalidate: 60 and tag-based revalidation for product and article pages. When a product updated, a single revalidateTag(‘product:123’) invalidated RSC cache, ISR page, and edge cache coherently. For personalized blocks (recently viewed), we used cookies + client components without touching the CDN. No Redis: the CDN plus RSC cache covered 95% of hits.

Critical insight: cache dairy, not steak. We cached list and detail pages aggressively, but left cart totals and user dashboards dynamic. This kept correctness simple and eliminated stale-money bugs.

Detailed view of Ethernet and VGA ports on a server highlighting connectivity features.
Photo by Brett Sayles on Pexels

Results and costs

At 10K+ daily users and 120 req/s peak bursts, 88% of traffic served from the CDN, 9% from RSC cache, 3% hit the database. p95 TTFB: 210ms cached, 620ms uncached. DB p95: 24ms. Infra cost averaged $310/month across hosting, database, and monitoring, scaling linearly with usage.

Ops minimization playbook

  • Prefer managed services with clear limits; test those limits with load rehearsal.
  • Ship feature flags that default to static rendering; only opt into dynamic when ROI is clear.
  • One pipeline: preview builds for every PR; Lighthouse budgets fail builds over 200KB JS.
  • Back-pressure writes with queues only where humans click twice; avoid durable queues otherwise.
  • Runbooks as code: a single script to warm caches and another to reindex safely online.

Pitfalls and how we fixed them

  • ISR stampedes: we added background regeneration with a mutex per tag to cap origin hits.
  • Edge cold starts: moved non-critical logic to RSC and reused edge middleware only for routing.
  • Pool exhaustion: used serverless auth (JWT) and connectionless reads via HTTP APIs for low-value metrics.
  • Search latency: swapped LIKE for trigram index; 4x faster with better relevance.

People and partners

To move fast without staff bloat, we paired a lean core team with vetted specialists from slashdev.io. Their remote engineers helped harden our React Server Components implementation and reviewed database migrations, letting us keep velocity high while staying within the minimal-ops mandate.

What this means

With disciplined Jamstack choices, RSC, and tuned Postgres, you can ship faster, spend less, and sleep at night-even as traffic doubles without extra ops.