Skip to content

Lesson 9 of 9 · 27m

Performance Budgets and Operating the App

Production quality is enforced with budgets, instrumentation, deploy review, and rollback discipline — not with a Lighthouse score screenshot in a launch deck.

A Next.js application does not stay fast because the framework is fast. It stays fast because someone decides what "fast enough" means, measures the real user experience, and treats regressions like product defects. Without budgets, every feature team adds "just one" dependency, one client boundary, one personalization query, and one hero video. Eight months later the median phone waits eight seconds.

Budgets need units a team can enforce

Useful starting budgets:

Largest Contentful Paint: <= 2.5s at p75 on mobile
Interaction to Next Paint: <= 200ms at p75
Cumulative Layout Shift: <= 0.1
Initial client JS for core routes: <= 180 KB compressed
Server route p95 latency: <= 800ms uncached
Image payload above the fold: <= 150 KB

The exact numbers are less important than ownership and enforcement. A budget nobody can break in CI or review is a poster.

Analyze what ships

ANALYZE=true next build

With bundle analyzer integration, inspect which routes pull dependencies into client chunks. The recurring offenders are entire icon packs, date libraries with all locales, charting libraries imported at page scope, markdown editors loaded for a rarely used admin control, and accidental server-only packages pulled into client code.

Use dynamic import for heavyweight client-only tools:

const ChartEditor = dynamic(() => import("./chart-editor"), { ssr: false });

Do not use ssr: false as a hiding place. It is appropriate for browser-dependent editors and widgets, not as a blanket workaround for boundary mistakes.

Instrument the server, not only the browser

A fast page that depends on twelve uncached internal queries is fragile. Emit structured route timing: render duration, data-source duration, cache hit/miss, revalidation events, and upstream timeouts. Connect RUM data to server traces by route and deployment.

OpenTelemetry is the boring answer that ages well. Even if you do not adopt the whole stack, propagate request IDs through logs and upstream calls.

Deploy review is part of performance work

Every production deploy should answer:

  • Which routes changed from static to dynamic?
  • Did the client bundle cross a budget?
  • Are there new uncached upstream calls in hot paths?
  • Did migrations create a table scan the render path now hits?
  • Can we roll back without revalidating every cache manually?

In Next.js, build output is operational telemetry. The route table is not decorative build noise.

Incident discipline for rendering systems

When users report stale or inconsistent pages, resist the urge to purge everything first. Capture evidence: response headers, route, deployment ID, cache status, and whether a client router navigation or hard load shows the problem. The layer tells you the fix. Purging everything destroys evidence and can create the thundering herd you were trying to escape.

Field notes

  • Measure p75 field data, not only synthetic Lighthouse on a developer laptop.
  • Fonts and images are layout and latency. Use next/font deliberately, and give responsive images dimensions; missing width/height is often the mysterious CLS bug.
  • Rollback is part of performance: a deploy you cannot revert quickly turns every regression into a long outage.

Was this lesson helpful?

Sign in to rate