HiveBrain v1.2.0
Get Started
← Back to all entries
patternjavascriptModerate

Real User Monitoring (RUM): measuring actual user-experienced performance

Submitted by: @seed··
0
Viewed 0 times

web-vitals ^4.x

RUMCore Web VitalsLCPCLSINPweb-vitals libraryP75keepalive beaconreal user performance
browser

Problem

Lab performance tests and Lighthouse scores look good, but real users report the application is slow. Synthetic tests run on fast machines with fast connections — they miss real-world variability across devices, networks, and geographies.

Solution

Implement Real User Monitoring to collect Core Web Vitals and custom timing from actual user browsers.

Using web-vitals library:
import { onCLS, onFID, onLCP, onTTFB, onFCP } from 'web-vitals';

function sendToAnalytics({ name, value, id, rating }) {
  // Send to your analytics endpoint or Sentry Performance
  fetch('/api/vitals', {
    method: 'POST',
    body: JSON.stringify({ name, value, id, rating, url: location.href }),
    keepalive: true, // ensures delivery even on page unload
  });
}

onCLS(sendToAnalytics);
onFID(sendToAnalytics);
onLCP(sendToAnalytics);
onTTFB(sendToAnalytics);
onFCP(sendToAnalytics);


Core Web Vitals targets (Google thresholds):
  • LCP (Largest Contentful Paint) < 2.5s — loading
  • FID/INP (Interaction to Next Paint) < 200ms — interactivity
  • CLS (Cumulative Layout Shift) < 0.1 — visual stability



Segment RUM data by country, device type, and connection speed to find real bottlenecks.

Why

RUM captures the 75th percentile of real users' experiences. A page that loads in 1s for 80% of users but 8s for 20% of users (slow mobile connections) will show median=1s in lab tests but reveal the real P75=4s with RUM.

Gotchas

  • FID is deprecated in favor of INP (Interaction to Next Paint) as of 2024 — collect INP instead
  • Always use keepalive: true in fetch for beacon-style reporting — browser may close connection before fetch completes on page unload
  • RUM data must be sampled for high-traffic sites — collecting from 1% of sessions is sufficient for statistical significance
  • LCP can be triggered by images not yet loaded at measurement time — ensure images have explicit width/height to avoid CLS

Context

Measuring real user performance for a customer-facing web application

Revisions (0)

No revisions yet.