Core Web Vitals and Apdex: two lenses on a micro frontend

· 15 min read PerformanceWeb VitalsObservabilityModule Federation

Core Web Vitals tell you how the page felt. Apdex tells you how the calls behind it behaved. Looking at both together gives the best overview of performance health.

A user does not need to know where the bottleneck is. A team does, because the fix depends on where it sits: the CDN, the host, the micro frontend or the API. This article uses two metrics, Core Web Vitals and Apdex, and three tools, Sentry, Grafana Faro and Prometheus, to find that point. The example is a React micro frontend (MFE) rendered on the client side and integrated through Module Federation into a Next.js host with SSR, all on AWS.

Sentry

Web Vitals

Faro

The MFE

Prometheus

Apdex

  1. 1. Introduction
  2. 2. Development
  3. 3. Conclusion
  4. References

1. Introduction

The scenario

The system has two applications that the user sees as one page:

  • The host is a Next.js app that renders on the server (SSR). It owns the page shell, the routes and the first HTML.
  • The MFE is a React app that runs on the client side: the UI is built in the browser, not on the server. The host loads it at runtime through Module Federation, so it ships as its own set of files and is deployed on its own.
  • AWS carries both: a CDN (CloudFront) in front, static files on S3, the host and the API behind a load balancer.

The measurements and improvements covered here happen in the MFE. When the outcome depends on the host, the text points out what the host can do to help and in which situations it becomes the problem.

In a micro frontend architecture, responsibility for performance is split. The page belongs to the host, but part of the content belongs to the MFE. Without separating the data by owner, it is hard to tell who should fix a slow page.

Core Web Vitals in one minute

Core Web Vitals (CWV) are a set of Google metrics that measure user experience in loading (LCP), interactivity (INP) and visual stability (CLS). Each one has a target, and a page is considered good when all three targets are met at the 75th percentile of loads, evaluated separately for mobile and desktop (web.dev: Web Vitals):

MetricAsksGood
LCP, Largest Contentful PaintWhen did the main content show up?2.5 s or less
INP, Interaction to Next PaintHow fast does the page respond to an interaction?200 ms or less
CLS, Cumulative Layout ShiftDoes the content shift while the page is being used?0.1 or less

INP replaced First Input Delay (FID) and became one of the main CWV metrics in 2024. CWV are measured in the browser of a real user, so they include the network, the device and everything the page loads, yours or not. Even browser extensions count, since they can delay page rendering (test of about a thousand Chrome extensions).

Apdex in one minute

Apdex turns a pile of response times into one number between 0 and 1. You choose a target time T. Each request lands in one of three zones, and the score is the weighted share (New Relic: Apdex, Prometheus: histograms and Apdex):

The zones

  • Satisfied: up to T
  • Tolerating: above T, up to 4T
  • Frustrated: above 4T, or failed

The score

(satisfied + tolerating / 2) / total

1.00 means every request was fast. A failed request counts against you, the same as a very slow one.

Try it below: twenty fixed requests, and the slider sets the value of T. Watch the score change even though no request got faster or slower:

Apdex is easy to game by raising T, and hard to compare between teams that chose different Ts. Its value is the trend for one endpoint with one T that you wrote down, not the absolute number.

Why both

They look at different things, so they fail differently:

  • CWV describe the experience in the browser. They tell you the page felt slow, but not which request caused it.
  • Apdex describes the latency of calls against a target. It tells you an endpoint is slow, but not whether the user even noticed.

One says that it hurts, the other helps find where. Later, the four combinations go in a small table.

2. Development

Three tools, three cuts

The three tools do not do the same job. Each one sees a different slice of the request path, and that is the reason to have all three. Pick a tool to see its slice:

request pathCloudFrontCDN + S3 filesHost (Next.js)SSR on AWSBrowserhost pageBrowserMFE (React)API / BFFmain endpointSentry: infrastructure response → browser renderFaro: the MFE onlyPrometheus: the API

Sentry sees the user's side of the page, Faro sees only your micro frontend, Prometheus sees the endpoint it calls. Together they cover the whole path without anyone measuring the same thing twice.

Sentry is where Core Web Vitals are read. Its browser SDK captures LCP, INP, CLS, FCP and TTFB from real page loads and rolls them into a 0 to 100 performance score, weighted 30% LCP, 30% INP, 15% CLS, 15% FCP and 10% TTFB (Sentry: Web Vitals).

The span that matters here runs from the moment the infrastructure answers (TTFB) to the moment the browser paints. That is the stretch where the MFE's cost shows up: downloading files, running them and drawing the result.

Caveat: Sentry's Web Vitals dashboard covers initial page loads and interactions, not navigations. If the user moves between routes inside the host without a full load, those moves are not in the score.

Faro is the MFE's own health chart. The Faro Web SDK captures web vitals (TTFB, CLS, FCP, INP, LCP, built on the web-vitals package), errors, logs, sessions and traces, and every measurement carries a rating of good, needs improvement or poor plus attribution, such as the LCP element (Grafana: Web vitals).

When it is initialized inside the MFE with the MFE's own app name and version, everything it reports belongs to that micro frontend, so a release of the MFE can be compared with the one before it without the host's noise.

Prometheus is where Apdex works best. It does not see the browser. It sees the requests that arrive at your main endpoint, and a latency histogram there is exactly what Apdex needs, with a target and a tolerated limit read straight from the buckets (Prometheus: histograms and summaries).

This is the communication between the endpoint and the frontend: how many calls were fast, how many were slow, how many failed.

What Prometheus measures is the latency the server saw. It does not include the user's network. When a call looks fine in Prometheus and slow in Sentry or Faro, the gap is network, CDN or the browser.

SentryFaroPrometheus
SeesThe page as the user lives itThe MFE aloneThe API that the MFE calls
Best atCore Web Vitals, from response to renderMFE health per releaseApdex and latency of the main endpoint
QuestionDoes the page feel fast?Is this micro frontend healthy?Is the backend answering in time?
Blind toWhich API call was slow, without tracingThe host and everything outside the MFENetwork and rendering on the client

None of them is the winner. For a first step, Sentry is the natural start, because the page is what the user and Google judge. The other two answer the question that comes next.

Wiring them up

Each tool needs very little code. What matters is where it lives and what you call it.

Sentry goes in the app entry. The tracing integration is what captures the page-load vitals, and tracePropagationTargets links the frontend request to the backend span (Sentry: React tracing):

import * as Sentry from "@sentry/react";

Sentry.init({
  dsn: "https://<key>@o<orgId>.ingest.sentry.io/<projectId>",
  integrations: [Sentry.browserTracingIntegration()],
  tracesSampleRate: 0.2,                       // 1.0 while testing, lower in production
  tracePropagationTargets: [/^https:\/\/api\.example\.com/],
});

With an MFE, a good practice is to add a tag such as mfe: "checkout" and the release version to Sentry events, so a poor score can be filtered by owner. Sentry reports the page, and the page has more than one owner.

Faro is initialized inside the MFE with its own name and version. That is what makes it a cut of the MFE (Faro Web SDK):

import { initializeFaro, getWebInstrumentations } from "@grafana/faro-web-sdk";

initializeFaro({
  url: "https://collector.example.com/collect",
  app: { name: "checkout-mfe", version: "1.4.2" },
  instrumentations: [...getWebInstrumentations()],   // includes Web Vitals
});

Agree with the host team about who initializes what. If both the host and the MFE call the initializer on the same page, you want two clearly named apps, not one confused one.

Prometheus needs a latency histogram on the API, with buckets at exactly your T and 4T. The docs are explicit: you must have buckets at the exact boundaries, and a common choice is a tolerated limit of about four times the target. With T = 0.3 s and 4T = 1.2 s:

# Apdex over 5 minutes. Buckets are cumulative, so satisfied counts twice
# and tolerating once, hence the division by 2. Failed requests stay in
# the denominator only, so they count as frustrated.
(
    sum(rate(http_request_duration_seconds_bucket{le="0.3", status!~"5.."}[5m]))
  + sum(rate(http_request_duration_seconds_bucket{le="1.2", status!~"5.."}[5m]))
) / 2
/ sum(rate(http_request_duration_seconds_count[5m]))

The Prometheus docs' own example does not exclude failed requests, and they say a strictly correct Apdex has to. The status filter above is one way to do that. The metric and label names are yours to match with your instrumentation.

What drags the numbers down

These are the problems to look for first in this kind of system, each with its cause and fix. Tap an item to see the cause, the fix and where it is fixed:

  • A waterfall before the first paintLCP
    HTML, then host JavaScript, then the MFE's remoteEntry, then its chunks, then data, then render. Each step waits for the one before.
    Start the remote earlier: preload its entry from the host's <head> or with the Module Federation runtime, which has preloading in version 2 (Module Federation). Keep the number of chunks on the critical path small.
    Host + MFE
  • Fetch on renderLCPApdex
    The MFE mounts and only then asks the API for what it needs to paint. The slowest call sets the LCP.
    Fire the request when the remote loads, not when the component mounts. Aggregate what the first view needs into one BFF call instead of several in sequence.
    MFE
  • The entry file is cached wrongLCP
    A long TTL on remoteEntry.js serves old versions. With no cache, every visit has to fetch the file again from the origin.
    Short max-age with stale-while-revalidate on the entry, long and immutable on content-hashed chunks, set in the CloudFront cache policy or in the S3 metadata (CloudFront: expiration). Keep old chunks around for a while, or users on the previous version hit 404s (Open edX notes).
    Infra (CloudFront, S3)
  • The same library downloaded twiceLCPINP
    React ships in the host and again in the MFE.
    Share the common dependencies as singletons in the federation config. Sharing reduces the download at runtime, and the share strategy trades strict versions for speed (Rspack: Module Federation plugin).
    Host + MFE
  • The LCP element appears lateLCP
    A hero image that only exists after the MFE runs, or one marked as lazy.
    Make the LCP resource discoverable early, give it high fetchpriority and never lazy-load it (web.dev: optimize LCP). Faro's attribution tells you which element it is.
    MFE + Host
  • Slow first byteLCP
    No CDN cache in front, redirects, an origin far from users.
    Put CloudFront in front of the host and assets, avoid redirects and cache-busting parameters. This one is mostly the host's.
    Host + Infra
  • An empty slotCLS
    The server HTML has a hole where the MFE will mount, so everything below jumps when it arrives.
    Reserve the space: a min-height or aspect ratio on the slot, and a skeleton with the final size until the MFE paints.
    Host
  • Late content with no sizeCLS
    Images without dimensions, web fonts that swap, banners injected after load.
    Set width and height, preload the main font and choose a fallback with similar metrics.
    MFE
  • A heavy render after an interactionINP
    Big lists and state kept far above the components that use it, so one click re-renders half the screen.
    Move state closer to the components that use it, virtualize long lists and mark non-urgent updates with useTransition.
    MFE
  • A busy main threadINP
    Large bundles, third-party scripts and long tasks that block the next paint.
    Load rarely used features with React.lazy, defer third-party scripts and break long handlers into smaller steps.
    MFE + Host
  • Heavy hydration in the hostLCPINP
    The host hydrates the whole page before the MFE even starts loading. The main thread stays busy, the remote waits and the first interactions are slow to respond.
    Send less client JavaScript from the host: keep what you can in Server Components and lazy-load client components below the fold (Next.js: lazy loading). Start loading the remote without waiting for hydration to finish.
    Host
  • A chatty frontendApdex
    Several sequential calls to build one screen, each paying its own latency.
    One endpoint per view in the BFF, calls in parallel, and a per-route histogram so you see which route drags the score.
    MFE + API / BFF
  • Slow work behind the endpointApdex
    N+1 queries, no cache for read-heavy responses, cold or undersized capacity.
    Fix the query, cache reads, and set a minimum capacity and scaling on latency for the service behind the load balancer.
    API + Infra
  • Errors read as frustrationApdex
    A failing dependency counts exactly like a slow one.
    Look at the error rate first, then at the latency. Add timeouts and retries where they are safe.
    API
  • A number nobody choseApdex
    One T for every route, or buckets that do not match T and 4T, so the query cannot compute it.
    Choose T per kind of route, write it down, and make the histogram buckets match.
    Monitoring

The host: what it can do, and when it is the problem

Some of the numbers above are decided outside the MFE. The host renders on the server, but the MFE only exists in the browser, and that gap shapes the page (Next.js also lets a client component skip server rendering with ssr: false, see Next.js: lazy loading).

What the host can do for the MFE

  • Reserve the MFE's slot in the server HTML, with a skeleton of the right size. That removes a layout shift and gives the browser something to paint.
  • Preload the MFE's entry file in the <head>, so the waterfall starts at the first byte and not after hydration.
  • Put the page shell in the first response and keep the server fast, so TTFB does not eat the LCP budget.
  • Own the shared dependencies, so there is only one React.

When the host is the problem

  • TTFB is high. Sentry shows a slow first byte on pages with and without the MFE. The MFE cannot fix that.
  • The LCP element is not the MFE's. Faro's attribution points to a host element, like a banner or header image.
  • INP is poor away from the MFE. The host's own scripts and third parties keep the main thread busy.
  • Hydration is heavy. The host hydrates a lot before the MFE even starts to load.

What settles who owns a bad number is the attribution, not opinions. The LCP element and the timing breakdown say whether the time went to the first byte, to discovering the resource, to downloading it or to rendering it (web.dev). Only then does a ticket go to someone's backlog.

Reading both signals

This is where the two metrics pay for themselves. Choose the state of each one:

Core Web Vitals (Sentry, Faro)
Apdex (Prometheus)

Pick one state for each metric to see the likely story.

The second case is the least intuitive one. A good CWV does not prove the backend is healthy, because a good front end can hide it for a while.

3. Conclusion

For this kind of system, the work splits like this:

ToolMetricCutQuestion it answers
SentryCore Web VitalsFrom infrastructure response to browser renderDoes the page feel fast to real users?
Grafana FaroVitals, errors, tracesThe MFE alone, per releaseIs the micro frontend healthy?
PrometheusApdexThe main endpoint the frontend callsAre the calls answering in time?

If you want to try this without building everything, start small and in this order:

  1. One lens on the page. Turn on Sentry tracing and look at LCP and TTFB for the pages that load the MFE. Get a baseline before changing anything.
  2. One name for the MFE. Initialize Faro inside it with its own name and version, so the next release has something to be compared with.
  3. One Apdex you wrote down. Pick T for your main endpoint, add the matching buckets and chart the query.

A good score is not the goal, a smaller distance to the problem is. CWV tell you the page hurts, Apdex helps find the call, and the attribution says whose it is. Read them together, change one thing, measure again.

References

← All articles