Module A-2·27 min read

DNS → CDN → edge → origin → streaming response anatomy, cold start cost breakdown, ISR revalidation internals, instrumentation.ts register() lifecycle, and instrumentation-client.js for browser SDK boot.

JJS
Written by Jatin Jain Saraf · Senior Software Engineer

A-2 — The Full Request Lifecycle and Edge Infrastructure

Who this is for: Architects who need to understand every hop a request takes from the user's browser to your database and back — and what happens at each layer. This is the module that explains why a page can have a 5ms TTFB or a 800ms TTFB depending on where in the infrastructure the request gets handled.


The Complete Request Path

A request to a Next.js application in production touches up to five distinct layers. Understanding each one tells you where your latency comes from and where to intervene.

text

A static page () served from CDN cache has a TTFB of 5-30ms globally. A dynamic page (λ) that hits the database has a TTFB of 100-500ms depending on database location, query complexity, and connection pool state. The difference between those two numbers is the entire caching architecture.


What the CDN Layer Does

The CDN sits in front of your Next.js server. For static routes, the CDN stores the pre-rendered HTML and RSC payloads — every request for that route gets served directly from the CDN node nearest the user. The Next.js server is not involved at all.

Next.js communicates with the CDN through HTTP cache headers it generates automatically:

text

On Vercel, this happens automatically — Vercel's CDN understands Next.js's cache model. On self-hosted deployments behind Nginx or Cloudflare, you need to either pass these headers through to the CDN or configure CDN caching rules explicitly.


Cold Start Anatomy

In serverless environments (Vercel Functions, AWS Lambda), your Node.js process doesn't exist until someone requests it. The cold start is the time it takes to create the process, load your application code, and handle the first request.

Cold start breakdown:

text

Module loading is where your application has the most control. The more code you import at the top level, the longer the cold start.

Strategies to reduce cold start:

ts
ts

On Vercel, you can see cold start frequency in the Functions tab. A rate of >5% cold starts on production traffic warrants optimisation. For critical paths (login, checkout), consider warming strategies: scheduled pings every 5 minutes, or Vercel's Fluid compute (always-warm instances).

Sign in to keep reading

The rest of this module is free — sign in with Google to unlock it and track your progress.

Sign in & Register

Discussion

0

Join the discussion

Loading comments...

© 2026 Jatin Jain Saraf (JJS). All rights reserved.