Skip to main content

Application Budgets

MetricBudget
UI render60fps (16ms/frame)
Cold start to interactive1.5 seconds
Idle CPU usage1%
Memory footprint30 MB
Event processing latency10ms per event
Bundle size (initial, gzipped)500 KB
Backend reads per session start≤ 5 documents
Serverless warm execution500ms
Serverless cold start3 seconds
Main thread long tasks0 tasks > 50ms

Core Web Vitals

Targets align with Google’s “Good” thresholds (measured at p75 from real user data):
MetricGoodNeeds ImprovementPoorWhat It Measures
LCP≤ 2.5s2.5–4.0s> 4.0sLoading — largest visible element render time
INP≤ 200ms200–500ms> 500msResponsiveness — worst interaction latency across full session
CLS≤ 0.10.1–0.25> 0.25Visual stability — cumulative unexpected layout shifts
  • LCP optimization: preload hero images/fonts, inline critical CSS, use fetchpriority="high" on LCP elements, server-side render above-the-fold content.
  • INP optimization: break long tasks with scheduler.yield(), defer non-critical event handlers, avoid layout thrashing in input handlers, keep interaction callbacks < 100ms.
  • CLS optimization: set explicit width/height on images and embeds, reserve space for dynamic content, avoid inserting content above the viewport after load.

API Response Time Budgets

Endpoint Typep50p95p99Timeout
Read (single)50ms150ms300ms5s
Read (list)100ms300ms500ms10s
Write (create)100ms250ms500ms10s
Write (update)75ms200ms400ms10s
Search150ms500ms1000ms15s
Aggregation200ms800ms2000ms30s
Auth flow100ms300ms500ms10s
  • All endpoints must return within their timeout or abort with a structured error.
  • Client-side: set AbortController timeouts matching the table above. Show loading indicators after 300ms.

Database Query Budgets

ConstraintBudget / Rule
Single query execution< 100ms
N+1 detection0 N+1 patterns (enforced via lint/review)
Queries per request≤ 10
Connection pool size10–20 per service instance
Index coverageEvery query in hot paths must hit an index
Full collection scansForbidden in production code
Batch read size≤ 100 documents per batch
  • Use query explain plans during code review for new or modified queries.
  • Log slow queries (> 200ms) with the query pattern and execution plan.

Network Budgets

ConstraintBudget
Requests per page load≤ 30
Total transfer size (initial)≤ 1.5 MB
Image payload per page≤ 500 KB
Individual API response≤ 100 KB (gzipped)
WebSocket message size≤ 10 KB
Font files loaded≤ 2 families, WOFF2 only
Third-party script budget≤ 100 KB (gzipped)
  • Images: serve WebP/AVIF with responsive srcset. Lazy-load below-the-fold images.
  • Fonts: use font-display: swap, preload critical fonts, subset to used character ranges.
  • Enable Brotli or gzip compression on all text responses. Set Cache-Control headers per resource type.

Enforcement Mechanisms

GateTool / MethodTriggerThreshold
Bundle sizesize-limit in CIEvery PRFail if > 500 KB gzipped
Lighthouse scoreLighthouse CI assertionsEvery PRPerformance ≥ 90
Core Web VitalsLighthouse CI + CrUXPR + weeklyAll metrics in “Good” range
API latencyIntegration test assertionsEvery PRp95 within budget table
DB query countTest-level query counterEvery PR≤ 10 per request
Runtime regressionRUM dashboards + alertsContinuousAlert on p75 regression > 10%
Synthetic monitoringScheduled Lighthouse runsHourly/dailySlack alert on score drop
  • CI must block merge if any enforcement gate fails. No manual overrides without tech-lead approval.
  • Track budget trends over time: plot bundle size, LCP, and INP per release on the performance dashboard.

Measurement Tooling

Metric CategoryLab / CI ToolField / Production Tool
Core Web VitalsLighthouse CI, WebPageTestCrUX, web-vitals library (RUM)
Bundle sizesize-limit, webpack-bundle-analyzerN/A
API latencyIntegration tests, k6OpenTelemetry histograms
DB performanceQuery explain, test query countersSlow query logs, APM traces
Memory / CPUChrome DevTools, profilerInfrastructure metrics (Prometheus)
Visual regressionPlaywright screenshot diffingRUM CLS tracking
  • Automated regression detection: compare each PR’s metrics against the main branch baseline. Flag regressions > 5% in any budget metric.
  • Review performance budgets quarterly and tighten thresholds as the application matures.

Build docs developers (and LLMs) love