RUMReal User MonitoringWeb PerformanceAnalyticsSaaSWeb Vitals

Real User Monitoring (RUM): Metrics, Tools & Setup (2026)

What is real user monitoring (RUM)? The key RUM metrics (LCP, CLS, INP, TTFB), the tools worth paying for, and a step-by-step monitoring setup you can ship in an afternoon.

Huifer
Huifer
June 11, 20265 min read
Also available in:Deutsch · 中文

Written by Huifer, solo developer and maintainer of TanStack Ship. I've run real user monitoring across production SaaS apps on Cloudflare Workers, deployed RUM beacons, traced support-ticket spikes back to real sessions, and compared RUM tooling for small teams first-hand. This guide is the setup I wish I had on day one.

Verified sources: Cloudflare Workers Observability · web.dev vitals · MDN Performance API · TanStack Start docs · npmjs.com

Last updated: 2026-10-19 · Changelog


TL;DR: Lab tests (Lighthouse, CI benchmarks) tell you how your app performs on a test machine. Real User Monitoring tells you how your app performs for actual users on their devices, networks, and locations. RUM catches performance issues that lab tests never will — slow connections, memory pressure, ad blocker interference, and geographic variance.


Real User Monitoring (RUM): What It Is, Key Metrics & Setup

What is real user monitoring (RUM)?

Real User Monitoring (RUM) is the practice of collecting performance data from every actual user session in production — page load times, interaction delays, and layout shifts — as those users experience them on their own devices and networks. Unlike synthetic monitoring, which runs scripted tests from fixed lab locations, RUM instruments your application with a small collector script (typically the web-vitals library) and beacons every metric back to your backend for analysis.

RUM monitoring answers the question lab tools cannot: what is performance actually like for my real users, in their countries, on their devices, on their networks? A Lighthouse run from a datacenter can say "your page scores 95." A RUM dashboard can say "your p75 LCP in Southeast Asia is 4.8 seconds and 20% of mobile users on 3G see a broken layout."

Key RUM metrics

The metrics that matter in a RUM dashboard are Google's Core Web Vitals plus two supporting signals:

RUM MetricWhat it measuresGood threshold
LCP (Largest Contentful Paint)How fast the main content renders≤ 2.5s at p75
INP (Interaction to Next Paint)How fast the page responds to taps and clicks≤ 200ms at p75
CLS (Cumulative Layout Shift)How stable the layout is while loading≤ 0.1 at p75
TTFB (Time to First Byte)How fast the server responds≤ 800ms at p75
FCP (First Contentful Paint)When anything first renders≤ 1.8s at p75

Each metric is collected with its rating (good / needs-improvement / poor) so your RUM monitoring can alert on degradation, not just report averages.


Lab vs Field Data

AspectLab (Lighthouse)Field (RUM)
EnvironmentControlled (Moto G4, slow 3G)Real user devices
NetworkSimulated throttlingActual connections (5G, 4G, 3G, WiFi)
LocationSingle locationGlobal (330+ Cloudflare locations)
DeviceFixed device profileAll devices and form factors
Sample sizeSingle run per PREvery page load
DetectsOptimization opportunitiesActual user experience issues
MissingWhat real users experienceControlled comparison

The truth: Lab data tells you what to fix. Field data tells you what users actually experience. You need both.


RUM Data Collection

Setting Up Web Vitals Collection

Collecting Web Vitals from real users is the first step in any RUM implementation. The web-vitals library provides attribution-aware metrics that tell you not just the value but also what caused it:

typescript
// src/lib/rum.ts
import { onLCP, onCLS, onINP, onTTFB, onFCP } from "web-vitals/attribution"

type VitalName = "LCP" | "CLS" | "INP" | "TTFB" | "FCP"

interface VitalReport {
  name: VitalName
  value: number
  rating: "good" | "needs-improvement" | "poor"
  id: string
  metadata: Record<string, string>
  deviceType: string
  connectionType: string
}

export function initRUM() {
  const vitals: Array<{ name: VitalName; fn: (metric: any) => void }> = [
    { name: "LCP", fn: onLCP },
    { name: "CLS", fn: onCLS },
    { name: "INP", fn: onINP },
    { name: "TTFB", fn: onTTFB },
    { name: "FCP", fn: onFCP },
  ]

  vitals.forEach(({ name, fn }) => {
    fn((metric) => {
      sendVital({
        name,
        value: metric.value,
        rating: metric.rating,
        id: metric.id,
        metadata: extractAttribution(metric),
        deviceType: getDeviceType(),
        connectionType: getConnectionType(),
      })
    })
  })
}

function extractAttribution(metric: any): Record<string, string> {
  if (metric.attribution) {
    // Extract useful debugging info
    const { element, url, fcp, ...rest } = metric.attribution
    return {
      ...(element && { lcpElement: element.tagName }),
      ...(url && { lcpUrl: url }),
    }
  }
  return {}
}

function getDeviceType(): string {
  const ua = navigator.userAgent
  if (/Mobi|Android/i.test(ua)) return "mobile"
  if (/Tablet|iPad/i.test(ua)) return "tablet"
  return "desktop"
}

function getConnectionType(): string {
  const conn = (navigator as any).connection
  return conn?.effectiveType ?? "unknown"
}

Sending RUM Data to the Backend

Once collected, vital metrics need reliable delivery to your server. Using navigator.sendBeacon ensures data is sent even when the user navigates away:

typescript
// Use sendBeacon for reliable delivery (survives page navigation)
function sendVital(report: VitalReport) {
  const payload = {
    ...report,
    pathname: window.location.pathname,
    timestamp: Date.now(),
  }

  if (navigator.sendBeacon) {
    navigator.sendBeacon("/api/vitals", JSON.stringify(payload))
  } else {
    fetch("/api/vitals", {
      method: "POST",
      body: JSON.stringify(payload),
      keepalive: true,
    })
  }
}

Server-Side Storage

On the server side, store each metric report in D1 with contextual metadata like country and device type for later analysis:

typescript
// server/rum.ts
export const reportVital = createServerFn({ method: "POST" }).handler(
  async ({ request, context }) => {
    const data = await request.json()

    // Store in D1 for querying
    await context.env.DB.prepare(`
      INSERT INTO rum_metrics (
        id, name, value, rating, pathname,
        device_type, connection_type,
        country, metadata, created_at
      ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    `).bind(
      data.id,
      data.name,
      data.value,
      data.rating,
      data.pathname,
      data.deviceType,
      data.connectionType,
      request.cf?.country ?? "unknown",
      JSON.stringify(data.metadata),
      data.timestamp
    ).run()

    return { received: true }
  }
)

Analyzing RUM Data

Querying by Metric

After collecting enough data, query it to understand your performance baseline. This dashboard function computes p50, p75, and p95 percentiles along with the percentage of "good" ratings for each metric:

typescript
export const getRumDashboard = createServerFn({ method: "GET" }).handler(
  async ({}, { context }) => {
    // Overall metrics for the last 7 days
    const overall = await context.env.DB.prepare(`
      SELECT
        name,
        COUNT(*) as samples,
        APPROX_PERCENTILE(value, 0.5) as p50,
        APPROX_PERCENTILE(value, 0.75) as p75,
        APPROX_PERCENTILE(value, 0.95) as p95,
        SUM(CASE WHEN rating = 'good' THEN 1 ELSE 0 END) * 100.0 / COUNT(*) as good_pct
      FROM rum_metrics
      WHERE created_at > datetime('now', '-7 days')
      GROUP BY name
    `).all()

    // Breakdown by pathname (top 10 slowest)
    const byPath = await context.env.DB.prepare(`
      SELECT
        pathname,
        APPROX_PERCENTILE(CASE WHEN name = 'LCP' THEN value END, 0.5) as lcp_p50,
        APPROX_PERCENTILE(CASE WHEN name = 'INP' THEN value END, 0.5) as inp_p50,
        COUNT(*) as pageviews
      FROM rum_metrics
      WHERE created_at > datetime('now', '-7 days')
      GROUP BY pathname
      ORDER BY lcp_p50 DESC
      LIMIT 20
    `).all()

    return { overall: overall.results, slowestPaths: byPath.results }
  }
)

RUM Dashboard

RUM Dashboard (Last 7 Days)

Web Vitals Overview:
┌────────┬──────────┬──────────┬──────────┬─────────┐
│ Metric │ P50      │ P75      │ P95      │ % Good  │
├────────┼──────────┼──────────┼──────────┼─────────┤
│ LCP    │ 1,200ms  │ 2,100ms  │ 4,500ms  │ 78%     │
│ CLS    │ 0.02     │ 0.05     │ 0.15     │ 85%     │
│ INP    │ 80ms     │ 150ms    │ 350ms    │ 82%     │
│ TTFB   │ 150ms    │ 350ms    │ 900ms    │ 88%     │
└────────┴──────────┴──────────┴──────────┴─────────┘

Performance by Geographic Region:
┌─────────────┬─────────┬──────────┬──────────────┐
│ Region      │ P50 LCP │ P95 LCP  │ Slow % (>3s) │
├─────────────┼─────────┼──────────┼──────────────┤
│ US East     │ 900ms   │ 2,100ms  │ 3%           │
│ US West     │ 1,100ms │ 2,800ms  │ 5%           │
│ Europe      │ 1,300ms │ 3,200ms  │ 8%           │
│ Asia Pacific│ 2,100ms │ 5,500ms  │ 20%          │
│ South America│ 2,400ms│ 6,000ms  │ 25%          │
└─────────────┴─────────┴──────────┴──────────────┘

Top 5 Slowest Pages:
1. /dashboard/analytics (p50 LCP: 4.2s) — heavy charts
2. /products/listing (p50 LCP: 3.8s) — large images
3. /reports/export (p50 LCP: 3.5s) — slow API

Alerts from RUM Data

Automated alerting turns raw RUM data into actionable notifications. This function checks LCP quality and identifies consistently slow pages:

typescript
export const checkRumAlerts = createServerFn({ method: "GET" }).handler(
  async ({}, { context }) => {
    const alerts = []

    // Alert if LCP good percentage drops below threshold
    const lcpQuality = await context.env.DB.prepare(`
      SELECT
        COUNT(*) as total,
        SUM(CASE WHEN rating = 'good' THEN 1 ELSE 0 END) * 100.0 / COUNT(*) as good_pct
      FROM rum_metrics
      WHERE name = 'LCP' AND created_at > datetime('now', '-1 hour')
    `).first()

    if (lcpQuality && Number(lcpQuality.good_pct) < 70) {
      alerts.push({
        type: "rum_degradation",
        metric: "LCP",
        goodPct: Math.round(Number(lcpQuality.good_pct)),
        threshold: 70,
        severity: "high",
      })
    }

    // Alert if any specific page has p95 LCP > 5s
    const slowPages = await context.env.DB.prepare(`
      SELECT pathname, COUNT(*) as views
      FROM rum_metrics
      WHERE name = 'LCP'
        AND value > 5000
        AND created_at > datetime('now', '-1 hour')
      GROUP BY pathname
      HAVING views > 10
      ORDER BY views DESC
      LIMIT 5
    `).all()

    if (slowPages.results.length > 0) {
      alerts.push({
        type: "slow_pages",
        pages: slowPages.results,
        severity: "medium",
      })
    }

    return alerts
  }
)

Using RUM to Drive Optimizations

RUM SignalInvestigationOptimization
High LCP on mobileCheck hero image sizeServe AVIF, preload hero, reduce image size
High CLS on product pageCheck dynamic content insertionReserve space, fix font swap layout shift
High INP on dashboardProfile main thread activityBreak up long tasks, lazy load charts
Poor APAC LCPGeographic latency issueEdge caching, CDN optimization
Poor TTFB on auth pagesAuth middleware overheadOptimize session lookup, cache auth state

RUM Data Schema

sql
-- migrations/rum_metrics.sql
CREATE TABLE IF NOT EXISTS rum_metrics (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,         -- LCP, CLS, INP, TTFB, FCP
  value REAL NOT NULL,        -- Metric value in ms or score
  rating TEXT NOT NULL,       -- good, needs-improvement, poor
  pathname TEXT NOT NULL,     -- URL path
  device_type TEXT,           -- mobile, desktop, tablet
  connection_type TEXT,       -- 4g, 3g, 2g, slow-2g
  country TEXT,               -- Two-letter country code
  metadata TEXT,              -- JSON with attribution data
  created_at INTEGER NOT NULL
);

CREATE INDEX idx_rum_name ON rum_metrics(name);
CREATE INDEX idx_rum_created ON rum_metrics(created_at);
CREATE INDEX idx_rum_path ON rum_metrics(pathname);

RUM Implementation Checklist

  • Web Vitals library installed and initialized on all pages
  • RUM data sent via sendBeacon for reliable delivery
  • Server endpoint stores metrics in D1 or Analytics Engine
  • Sample rate configured (100% for initial setup, then reduce to 10-25%)
  • Dashboard built for p50/p75/p95 metrics
  • Geographic breakdown visible in dashboard
  • Pathname-level aggregation for slow page detection
  • Automated alerts for RUM degradation
  • Device type segmentation (mobile vs desktop)
  • Connection type tracking for network-aware optimization
  • Integration with CI pipeline — compare PR RUM vs production RUM
  • Historical data retention for trend analysis

Conclusion

Real User Monitoring bridges the gap between what you test in development and what your users experience in production. Without RUM, you are optimizing based on assumptions. With RUM, every optimization decision is backed by data from actual users.

The implementation is straightforward:

  1. Collect Web Vitals from every page load
  2. Store them in D1 or Analytics Engine
  3. Build dashboards for visualization
  4. Set alerts for degradation
  5. Use the data to prioritize optimization work

To deepen your performance practice, explore our Core Web Vitals Optimization Guide for metric improvement strategies, Performance Budgeting for preventing regressions, SaaS Monitoring and Observability for infrastructure health, and Lighthouse 95+ Optimization Tips for lab-based auditing.