Skip to main content

Performance Mental Model, Budgets & Measurement

Performance is not a single score.

A Next.js request can be fast on the server and still feel slow in the browser. A page can have a small JavaScript bundle and still have poor LCP because its hero image is late. A route can stream quickly and still have poor INP because a large Client Component blocks the main thread after hydration.

The useful senior model is:

user intent
↓
network + CDN + server
↓
RSC / HTML / assets
↓
browser parse + style + layout + paint
↓
client JavaScript + hydration
↓
interaction work
↓
perceived user experience

Performance has several independent dimensions​

Track at least:

server latency
render latency
cache hit/miss behavior
payload bytes
client JavaScript bytes
resource scheduling
main-thread work
visual stability
interaction latency
memory
backend dependency latency

Optimizing only one can move cost somewhere else.

User-centric outcomes come first​

For most product routes, ask:

  • how quickly does useful content appear?
  • how quickly can the user interact?
  • does the layout move unexpectedly?
  • does navigation feel immediate?
  • does the route remain responsive during long sessions?
  • does performance hold on slower devices and networks?

That is more meaningful than asking whether a benchmark is "fast" in isolation.

Core Web Vitals are field-oriented signals​

The three current Core Web Vitals are:

LCP → loading experience
INP → interaction responsiveness
CLS → visual stability

Common good thresholds are:

LCP ≤ 2.5 s
INP ≤ 200 ms
CLS ≤ 0.1

Evaluate the 75th percentile of real user experiences, segmented where useful by device class, route, geography, connection, release, or browser.

Do not turn these thresholds into the only definition of performance. TTFB, FCP, server duration, resource timing, long tasks, memory, and business-task duration can explain why a Core Web Vital regressed.

Field data and lab data answer different questions​

Field data​

Real user monitoring tells you what actual users experienced.

Strengths:

  • real devices
  • real networks
  • real caches
  • real geography
  • real third-party interference
  • real interaction patterns

Weaknesses:

  • noisy
  • delayed
  • harder to reproduce
  • traffic distribution can hide a minority segment

Lab data​

Lighthouse, DevTools, synthetic tests, and local profiling are controlled experiments.

Strengths:

  • reproducible
  • inspectable
  • useful before deployment
  • easy before/after comparison

Weaknesses:

  • simulated environment
  • cannot represent every user
  • one run is not a distribution

A production workflow uses both.

field regression
↓
segment and diagnose
↓
lab reproduction
↓
change
↓
lab verification
↓
field confirmation

Performance budgets prevent slow drift​

A budget is an engineering constraint, not a vanity target.

Possible route budgets:

initial client JS
route-specific client JS
LCP resource bytes
third-party JS
request count
server p95 duration
RSC payload size
image bytes
font bytes
long-task count
INP p75
CLS p75

Budgets should be tied to a user journey.

Example:

marketing homepage
→ extremely strict LCP and third-party budget

analytics workspace
→ stricter interaction/main-thread budget

admin configuration route
→ lower traffic, but still bounded bundle and server latency

Budgets need baselines and ownership​

A useful budget record includes:

metric
route or journey
baseline
warning threshold
failure threshold
owner
measurement source
review cadence

Bad:

keep bundles small

Better:

/dashboard initial client JS
baseline: 165 KB compressed
warning: +10%
block release: +20% unless reviewed
owner: dashboard team

The exact number depends on the product. The discipline is what matters.

Measure production behavior, not only development​

Development mode intentionally adds tooling and different runtime behavior.

For meaningful application performance checks:

npm run build
npm run start

Then inspect the production-like application.

Use development mode for iteration and debugging, not final performance conclusions.

Separate cold, warm, and cached paths​

A route has multiple performance states:

cold process
cold application cache
warm process
warm data cache
browser cold cache
browser warm cache
prefetched navigation
hard reload
soft navigation

Benchmarking only the fastest state is misleading.

A performance report should state which state was measured.

Server timing is not browser timing​

Imagine:

server completes in 120 ms
HTML arrives in 180 ms
LCP resource discovered at 240 ms
image downloads until 1.4 s
main-thread hydration blocks until 1.8 s
first interaction paints at 2.1 s

"Server was 120 ms" does not describe the user experience.

Likewise, poor TTFB can dominate an otherwise optimized browser path.

Think in critical paths​

For a visible element:

request
→ render decision
→ data dependency
→ HTML/RSC delivery
→ resource discovery
→ download
→ decode / execute
→ layout / paint

Every serial dependency on this path adds latency.

Optimization often means turning serial work into:

  • cached work
  • parallel work
  • preloaded work
  • deferred work
  • server-only work
  • removed work

Start early, await late​

Phase 5 introduced this data principle.

Bad:

const user = await getUser()
const recommendations = await getRecommendations()

If independent, start both first:

const userPromise = getUser()
const recommendationsPromise = getRecommendations()

const [user, recommendations] = await Promise.all([
userPromise,
recommendationsPromise,
])

But do not parallelize unbounded fan-out. Parallel work still consumes sockets, CPU, database connections, and upstream quotas.

Streaming changes perceived timing, not total work​

Suspense can let useful UI arrive before slow descendants.

shell ready
↓ stream now
slow panel still rendering
↓
panel arrives later

This can improve perceived loading without making the slow panel itself faster.

Measure both:

time to useful shell
and
slow dependency duration

Caching is a latency tool with correctness constraints​

Caching can eliminate expensive work, but incorrect caching creates security or freshness bugs.

Performance review must ask:

  • what is cached?
  • for how long?
  • by which key?
  • where is the cache located?
  • what invalidates it?
  • can user or tenant data cross boundaries?
  • what is the miss path?

Never trade authorization correctness for a benchmark.

Client JavaScript has multiple costs​

A JavaScript file costs more than transfer bytes.

download
→ decompress
→ parse
→ compile
→ execute
→ hydrate
→ retain memory
→ run future interactions

That is why moving non-interactive transformation work into Server Components can outperform simply compressing the same client bundle.

Main-thread blocking is a product problem​

Long JavaScript tasks delay input processing and painting.

Common causes:

  • huge Client Component trees
  • chart/table rendering
  • markdown or syntax processing in the browser
  • large JSON transformations
  • third-party scripts
  • synchronous loops
  • unnecessary rerenders

INP debugging should identify the interaction and the work responsible for delay, not only the global score.

Performance and architecture are connected​

A broad 'use client' boundary can pull many modules into the client graph.

A database call placed behind an internal Route Handler can add an unnecessary server-to-server HTTP hop.

A root-layout dynamic request API can change rendering strategy.

A nonce-based CSP can force request-time rendering.

A tag manager can load arbitrary vendor code.

Performance review therefore belongs in architecture review.

Avoid cargo-cult optimizations​

Examples:

memoize everything
lazy-load everything
preload everything
cache everything forever
turn off SSR
add more Suspense boundaries everywhere

Each can make performance worse.

Ask:

what evidence identifies the bottleneck?
what cost will this change remove?
what new cost will it create?
how will we verify the result?

The optimization loop​

Use this loop consistently:

1. define user journey
2. establish baseline
3. identify bottleneck
4. form hypothesis
5. make one meaningful change
6. measure again
7. verify field impact
8. keep or revert

Senior review checklist​

Before approving a performance-sensitive feature, ask:

  • What is the critical user journey?
  • Which work is on its critical path?
  • Which work runs on server vs browser?
  • What is the initial client JavaScript impact?
  • What new resources are introduced?
  • Are dependencies parallelized appropriately?
  • Is caching correct and scoped?
  • Are third parties deferred or isolated?
  • Is loading stable without layout shift?
  • What field metric will prove success?
  • Is there a regression budget?
  • Can the change be rolled back safely?

Interview questions​

Why is bundle size not enough to describe frontend performance?​

Because transferred bytes are only one cost. JavaScript also requires parsing, compilation, execution, hydration, memory, and interaction-time work, while other bottlenecks such as server latency, images, fonts, CSS, and third parties can dominate user experience.

Why can streaming improve UX without improving backend latency?​

It can send completed UI earlier while slow work continues. The slow dependency may take exactly the same time, but it no longer blocks the entire visible response.

What is the strongest performance optimization process?​

Measure → diagnose → change → measure again, using both controlled lab evidence and real-user field data.

Exercise​

Choose one route and build a performance contract containing:

  1. critical user task
  2. field metrics
  3. server metrics
  4. client bundle budget
  5. resource budget
  6. cold/warm/cache scenarios
  7. one likely bottleneck
  8. how you would prove an optimization worked