| | |

Vercel 18 ▲ Observability & Cost Optimization — Inspecting runtime logs, Speed Insights, Web Analytics, and Fluid active CPU usage

⏱️ Estimated read: 25 min | |

A deployment that cannot be observed cannot be operated. Vercel’s default posture is that every deployment produces logs, every pageview produces an analytics event, and every browser session reports its Core Web Vitals back to the platform — but the mechanisms are separate, the data lives in separate surfaces, and the cost model that ties them together is the part most teams learn last. An application can be functionally correct and quietly expensive because one API route spends four hundred milliseconds per request in a synchronous loop, and the only way to discover that is to read the logs and correlate them with the billing.

The four surfaces this chapter covers are the ones that matter most for a production application. Runtime Logs are the per-invocation stdout and stderr stream, extended to serverless functions that build on the Function Logs system, drained to external services, and retained from one hour (Hobby) to thirty days (with Observability Plus). Speed Insights collects field data from real browsers — Largest Contentful Paint, Interaction to Next Paint, Cumulative Layout Shift, First Contentful Paint, Time to First Byte — and reports them as percentiles rather than averages, which is the only way Core Web Vitals are meant to be read. Web Analytics is the pageview and custom-event layer that replaces a third-party script with a first-party one, costs nothing to load for most visitors, and answers “which page, from which referrer, at what rate” without a cookie banner. Fluid compute is the billing model that underpins all of it: functions are billed on Active CPU time — the time the process is actually executing instructions — plus Provisioned Memory time (memory held for the duration of the function) plus invocations, which changes the optimization target from “make the function shorter” to “make the function do less work per millisecond it is alive.”

The chapter is ordered the way a team actually diagnoses a problem. Logs first, because that is where the error message lives. Then Speed Insights, because that is where “the site feels slow” turns into a number. Then Web Analytics, because that is where “traffic dropped” turns into a referrer and a page. Then Fluid compute, because that is where the bill is confirmed. Each section is self-contained, but the four together are the loop: observe, measure, attribute, optimize.

Key point: Runtime Logs are ephemeral by default and only survive on a paid plan through log drains or Observability Plus; Speed Insights reports percentiles from the field, not averages; Web Analytics is privacy-safe and does not use cookies; and Fluid compute bills on Active CPU plus Provisioned Memory, which means reducing wall-clock duration and reducing real work are now two different optimizations.


Why it exists

The invisible-production problem. A common observation: production is the only environment nobody can attach a debugger to. Locally you have a terminal, a breakpoint, a hot reload. In production you have aggregate metrics and log lines, and the log line is the only channel through which the function can explain itself at the level of a single request. Runtime Logs exist because that channel is the fundamental unit of debugging a deployed function, and without it every incident is a black box with a stack trace that arrived too late.

The cold-start and sampling problem. Serverless functions do not behave like a long-running server. They start, handle a request, and stop. They are billed per invocation, so a function that handles ten million requests produces ten million invocation records and, if it logs on every request, ten million log lines. Retaining all of it is prohibitive, so the default retention is short, and the paid mechanism is a drain that pipes the stream to a third-party store — Datadog, Axiom, Splunk, a self-hosted HTTP endpoint. Observability Plus is the same idea kept inside Vercel: extended retention, full-text search, and custom queries, purchased per project.

The metric problem. Averages lie. If ninety-nine percent of requests complete in 80ms and one percent take 3 seconds, the average is 110ms and it looks fine. Core Web Vitals are defined by the 75th percentile precisely because the average hides the tail, and the tail is what real users hit on a slow connection or a mid-range phone. Speed Insights exists to make the percentile visible, and to separate field data (real users, real devices, real network conditions) from lab data (a synthetic test on a fast connection), because the two frequently disagree and the disagreement is the diagnosis.

The attribution problem. “Traffic dropped 30% yesterday” is not actionable. “Traffic dropped 30% on /pricing from google.com referral on iOS Safari” is. Web Analytics exists because attribution requires per-page, per-referrer, per-device breakdowns at a granularity that generic search logs cannot provide, and because the third-party analytics script that used to provide it — Google Analytics, Plausible, Fathom — is a network request the visitor pays for and, in the EU, a consent banner that halves the sample by asking for permission. A first-party analytics endpoint does not.

The billing-model problem. Before Fluid compute, Vercel functions were billed on wall-clock duration: the time from the first byte of the request to the last byte of the response. That model created a perverse incentive — a function that awaited a slow database query was billed for the wait, even though no CPU was executing. Fluid compute splits the bill into Active CPU, Provisioned Memory, and Invocations, so that a function which waits on I/O without holding a hot loop is billed only for the memory it holds and the invocation it consumes. The optimization target changes with the model, and teams that optimize wall-clock duration without understanding the split are optimizing the wrong thing.

The correlation problem. The logs, the metrics, the analytics, the bill — each is a separate surface with a separate query language and a separate time range. A slow request in the logs and a slow percentile in Speed Insights are the same incident, but discovering that requires correlating two time series against the same deployment, which is what the deploy ID in every log line and every Speed Insights record is for. Observability Plus surfaces the correlation explicitly; the default surfaces require it to be reconstructed by hand.

The trade-off. Every observability feature costs money, either directly (Observability Plus per project) or indirectly (log drains bill on the receiving side, Speed Insights bills per data point, Web Analytics bills per event). The safe default is to enable the surface, watch the bill, and add retention only where it is used. The difference between an application that is well-instrumented and one that is over-instrumented is a factor of two on the monthly bill and zero on the quality of the incident response.


a. Runtime Logs — streaming, retention, and log drains

Every function invocation writes to a log stream associated with its deployment. The stream is available in the Vercel dashboard under the deployment’s Logs tab, in real time while the request is in flight, and is queryable afterward by request ID, by path, by status code, by duration, and by arbitrary text inside the log line. The log line format is JSON, which is what makes the queries work: console.log in a serverless function is serialized to a structured record with the deployment ID, the request ID, the region, the function name, and the timestamp attached by the platform, regardless of what the function passed in.

// app/api/checkout/route.ts
import { NextResponse } from "next/server";

export async function POST(request: Request) {
  const started = performance.now();
  const body = await request.json();

  // Structured fields survive into the log index and are queryable
  console.log(JSON.stringify({
    event: "checkout.start",
    cartId: body.cartId,
    items: body.items.length,
    timestamp: new Date().toISOString(),
  }));

  const order = await createOrder(body);

  // Duration is measured in-function so it excludes the platform overhead
  console.log(JSON.stringify({
    event: "checkout.complete",
    orderId: order.id,
    durationMs: Math.round(performance.now() - started),
  }));

  return NextResponse.json({ orderId: order.id });
}

The structured form is the important habit. console.log("checkout done") is a string nobody can filter; console.log(JSON.stringify({ event: "checkout.complete", orderId })) is a record that can be counted, grouped, and correlated. The platform attaches the request ID to every line emitted during a single invocation, which means the two lines above are joinable by request ID in the dashboard even though they do not share a field in the JSON.

Retention is the constraint. On the Hobby plan, runtime logs are retained for one hour — enough to debug the request in front of you, not enough to investigate yesterday’s incident. On Pro, retention extends to one day, which covers the same-day investigation but not a weekend. Enterprise extends to three days. The paid extension is Observability Plus at $10 per project per month, which raises retention to thirty days and adds full-text search across the extended window, custom query language, and a saved-query interface.

When retention is insufficient, the answer is a log drain. A drain is an HTTP endpoint you configure in project settings toward which Vercel streams every log line as it is produced. The receiving service is your choice — Datadog, Axiom, Grafana Loki, a self-hosted endpoint — and the drain itself is the durable store. The vercel.json entry is a list of drain targets, each with a URL, a format, a list of sources, and a list of environments:

{
  "logDrains": [
    {
      "deliveryFormat": "ndjson",
      "url": "https://logs.example.com/ingest/vercel",
      "sources": ["lambda", "build", "edge", "static"],
      "environments": ["production", "preview"]
    }
  ]
}

The sources field decides which streams are forwarded. lambda is the serverless function output, build is the build process output, edge is the edge function output, and static is the static asset request log. The deliveryFormat is either json (batched arrays) or ndjson (one record per line), and ndjson is the correct choice for any receiver that streams. The drain is billed by the receiving service, not by Vercel, so a modest volume of logs is cheaper to retain in Axiom than to upgrade to Observability Plus — but the setup cost is higher, which is why small teams usually start with Observability Plus and move to a drain when they outgrow it.


b. Speed Insights — field data, percentiles, and Core Web Vitals

Speed Insights is the mechanism by which the browser reports real performance numbers back to Vercel. The collection is a small script injected by the framework integration — for Next.js it is the @vercel/speed-insights package rendered in the root layout — and the script samples interactions and navigation, computes the Core Web Vitals, and posts them to a first-party endpoint at the end of the page lifecycle.

// app/layout.tsx
import { SpeedInsights } from "@vercel/speed-insights/next";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        {/* Samples every route by default; the script ships once per session */}
        <SpeedInsights />
      </body>
    </html>
  );
}

The metrics themselves are the five Core Web Vitals plus a few supporting measurements. The two that are ranked by Google and therefore the two that matter for SEO are LCP (Largest Contentful Paint, the time the largest above-the-fold element takes to render — the “is it loaded” metric) and INP (Interaction to Next Paint, the time between a click or keypress and the next visible frame — the “does it respond” metric). CLS (Cumulative Layout Shift) measures how much the layout moves unexpectedly; FCP (First Contentful Paint) and TTFB (Time to First Byte) are supporting metrics that diagnose why LCP is slow.

// Sending a custom timing metric alongside the automatic ones
import { useReportWebVitals } from "next/web-vitals";

export function WebVitals() {
  useReportWebVitals((metric) => {
    // metric.name is "LCP" | "INP" | "CLS" | "FCP" | "TTFB"
    // metric.value is the measured number; metric.rating is good/needs-improvement/poor
    console.log(JSON.stringify({
      event: "web_vital",
      name: metric.name,
      value: metric.value,
      rating: metric.rating,
      path: window.location.pathname,
    }));
  });
}

The critical detail is the percentile. Speed Insights reports the 75th percentile of each metric per route, not the average, because Core Web Vitals are defined by the 75th percentile — a page is “good” if 75% of its real-user loads meet the threshold. The thresholds themselves are the Google ones: LCP good below 2.5s, needs improvement between 2.5s and 4.0s, poor above 4.0s; INP good below 200ms; CLS good below 0.1. A page that reports an average LCP of 1.8s with a 75th percentile of 3.2s is a page that fails the audit even though the average looks fine.

The difference between field and lab data is the second critical detail. Field data is what a real user on a mid-range Android phone over a congested network experienced; lab data is the same page tested from a datacenter on a fast connection, which is what Lighthouse and PageSpeed Insights produce when no real data is available. The two are complements: field data says what is wrong, lab data says why, because the lab run has a waterfall and a flame chart. Speed Insights is the field channel, and it is the one that reflects the ranking signal.

Speed Insights is metered per data point collected — each page view that reports a metric is one data point — with a per-plan included allowance and an overage rate. The sample rate is adjustable; a large site can reduce cost by sampling 10% of sessions and still getting statistically meaningful percentiles, because percentiles converge on large samples and are not skewed by the sample being smaller, only by it being non-random.


c. Web Analytics — pageviews, referrers, and custom events

Web Analytics is the pageview and event layer. It reports the count of page views per path, the referrer each view arrived from, the country and device of the visitor, and a stream of custom events you emit yourself. It does not use cookies and does not persist a visitor identifier across sessions, which is why it does not require a consent banner — the data is aggregate and the visitor is not tracked between visits.

// app/layout.tsx
import { Analytics } from "@vercel/analytics/next";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        {/* One lightweight script, no cookie, no consent gate */}
        <Analytics />
      </body>
    </html>
  );
}

The custom event layer is the part most teams under-use. A pageview tells you that someone reached /checkout; a custom event tells you whether they completed the purchase. Both are needed to compute conversion, and both are emitted from the same client-side module:

// Emitting a custom event at a meaningful product moment
import { track } from "@vercel/analytics";

export function CheckoutButton({ cartId, value }: { cartId: string; value: number }) {
  const handleClick = () => {
    // Custom events are filterable in the dashboard by name and value
    track("checkout_started", { cartId, value });
    // ... navigate to the checkout flow
  };

  return <button onClick={handleClick}>Checkout</button>;
}

The event name must be a constant — "checkout_started" — not a template string, because the dashboard groups by the name and a dynamic name produces one group per variant. The properties are optional and can carry any string or number; they appear in the event stream and can be used to sum a numeric property, which is how revenue is aggregated.

The referrer handling is worth understanding because it is the part that produces surprising numbers. The Referer header is stripped by most modern browsers when the source is a cross-origin HTTPS page without rel="noreferrer", so a click from a third-party site often arrives with direct as the referrer even though the visitor came from somewhere. The common mitigation is UTM parameters in the outbound link, which Web Analytics reads and attributes to the campaign — the referrer would have been stripped, but the query string is preserved.

Web Analytics is metered on events — a pageview is one event, a track call is one event — with a per-plan included allowance (larger than the Speed Insights allowance because page views outnumber metric reports) and an overage rate. The custom-event stream is the part that grows fastest on a high-traffic site, which is why it is worth sampling or disabling events on routes where a counter would suffice — a page that fires four events per view on a million views per day is four million billed events, and the conversion rate it produces could be computed from one pageview event and one purchase event.


d. Fluid compute — Active CPU, Provisioned Memory, and the cost model

Fluid compute is Vercel’s current default execution model for serverless functions. It changes the billing from GB-hours of wall-clock duration to three separate quantities: Active CPU time (the millisecond window in which the function is actively executing instructions and holding a CPU), Provisioned Memory time (the memory allocated for the entire life of the function, including I/O waits), and Invocations (one per request, plus one per cron trigger).

The three line up with the pricing table as three separate charges. Active CPU is the expensive one — $0.128 per CPU-hour on Pro — because it represents a CPU that could not be used for anything else. Provisioned Memory is cheaper — $0.0106 per GB-hour — because memory is abundant relative to CPU. Invocations are $0.60 per million and dominate the bill only on the highest-traffic endpoints.

The consequence of the split is that a function awaiting a slow database call is billed for the memory it holds and the invocation it consumes, but not for the CPU — because no CPU is executing while it waits. A two-second request that spends 1,900ms awaiting a query and 100ms parsing the response is billed for 100ms of Active CPU, not 2,000ms. The optimization target shifts from “make the function finish faster” to “make the function do less work per millisecond it is alive,” and the two are not identical.

// vercel.json
{
  "functions": {
    "app/api/report/route.ts": {
      // The report generator is CPU-bound: allocate more CPU to halve Active CPU time
      "memory": 3009,
      "maxDuration": 60
    },
    "app/api/webhook/route.ts": {
      // The webhook is I/O-bound: it awaits an upstream call, so more memory is wasted
      "memory": 1024,
      "maxDuration": 10
    }
  }
}

The memory setting is the knob because Active CPU scales roughly linearly with allocated memory up to the CPU core count, and Provisioned Memory scales linearly with it always. A CPU-bound function benefits from more memory because it finishes in less Active CPU time — the total cost can go down as memory goes up. An I/O-bound function does not benefit, because the CPU is idle during the wait, and more memory just increases the Provisioned Memory charge for no gain. Reading the two lines side by side is the whole optimization: an endpoint that awaits a slow upstream is a memory setting to leave alone, and an endpoint that loops over a JSON payload is a memory setting to raise.

The other two cost levers are outside the function. Region selection moves the function closer to the database or the user, whichever dominates — for a read-heavy page the user’s region is right; for a write-heavy API the database’s region is right. Caching at the edge or via ISR removes the invocation entirely on a cache hit, which is the only optimization that costs nothing on the billing table, because a cache hit never invokes the function.

// app/pricing/page.tsx
// Revalidating every 3600 seconds: one invocation per hour replaces one per request
export const revalidate = 3600;

export default async function PricingPage() {
  // On a cache hit this line does not execute; the edge serves the cached HTML
  const plans = await getPricingPlans();
  return <PricingTable plans={plans} />;
}

The revalidation window is the setting that most directly converts to money on a page that is read far more often than it is written. A marketing page revalidated hourly on a site with a million views per day produces twenty-four invocations per day instead of a million. The trade-off is staleness — a price change takes up to an hour to appear — and it is almost always worth taking on a page that is not transactional.


Complete Example Session

// ============================================
// PART 1: THE STRUCTURED LOG LINE
// ============================================
import { NextResponse } from "next/server";

export async function GET(request: Request) {
  const started = performance.now();
  const url = new URL(request.url);

  // JSON keeps the fields queryable and correlates by request ID
  console.log(JSON.stringify({
    event: "api.invoked",
    path: url.pathname,
    query: Object.fromEntries(url.searchParams),
  }));

  const result = await expensiveQuery(url.searchParams);

  // The completion line carries the in-function duration
  console.log(JSON.stringify({
    event: "api.completed",
    durationMs: Math.round(performance.now() - started),
    rows: result.length,
  }));

  return NextResponse.json(result);
}

// ============================================
// PART 2: THE LOG DRAIN
// ============================================
// vercel.json
// {
//   "logDrains": [
//     {
//       "deliveryFormat": "ndjson",
//       "url": "https://logs.example.com/ingest",
//       "sources": ["lambda", "build"],
//       "environments": ["production"]
//     }
//   ]
// }

// ============================================
// PART 3: THE SPEED INSIGHTS MOUNT
// ============================================
// app/layout.tsx
import { SpeedInsights } from "@vercel/speed-insights/next";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <SpeedInsights sampleRate={0.1} />
      </body>
    </html>
  );
}

// ============================================
// PART 4: THE CUSTOM VITAL REPORTER
// ============================================
import { useReportWebVitals } from "next/web-vitals";

export function Vitals() {
  useReportWebVitals((metric) => {
    // Fires once per metric per page; metric.rating is the Google band
    console.log(JSON.stringify({
      event: "web_vital",
      name: metric.name,     // LCP, INP, CLS, FCP, TTFB
      value: metric.value,   // milliseconds or unitless (CLS)
      rating: metric.rating, // good | needs-improvement | poor
    }));
  });
  return null;
}
// ============================================
// PART 5: THE WEB ANALYTICS MOUNT
// ============================================
// app/layout.tsx
import { Analytics } from "@vercel/analytics/next";

export function AnalyticsMount() {
  return <Analytics />;
}

// ============================================
// PART 6: THE CUSTOM EVENT
// ============================================
import { track } from "@vercel/analytics";

export function PurchaseButton({ sku, price }: { sku: string; price: number }) {
  return (
    <button onClick={() => {
      // One pageview + this event per session crosses the attribution line
      track("purchase_clicked", { sku, price });
    }}>
      Buy
    </button>
  );
}

// ============================================
// PART 7: THE FUNCTION MEMORY TUNING
// ============================================
// vercel.json
// {
//   "functions": {
//     "app/api/report/route.ts": { "memory": 3009, "maxDuration": 60 },
//     "app/api/webhook/route.ts": { "memory": 1024, "maxDuration": 10 }
//   }
// }

// ============================================
// PART 8: THE CACHE WIN
// ============================================
// app/pricing/page.tsx
// One invocation per hour instead of one per request
export const revalidate = 3600;
export default async function PricingPage() {
  return <PricingTable plans={await getPricingPlans()} />;
}

// ============================================
// PART 9: THE REGION CHOICE
// ============================================
// vercel.json
// {
//   "functions": {
//     "app/api/orders/route.ts": { "regions": ["iad1"] }
//   }
// }
// iad1 sits next to the primary database; the user-region default is wrong here

// ============================================
// PART 10: THE BILLING READ
// ============================================
// Pulling the Fluid-compute usage breakdown to confirm the optimization
const usage = await fetch(
  `https://api.vercel.com/v1/usage?from=${start}&to=${end}`,
  { headers: { Authorization: `Bearer ${process.env.VERCEL_TOKEN}` } }
).then((r) => r.json());

// The three Fluid lines, in the order they were billed
console.log({
  activeCpuMs:   usage.functions?.activeCpuDurationMs,
  memoryGbHours: usage.functions?.provisionedMemoryGbHours,
  invocations:   usage.functions?.invocations,
});

The ten parts built the two ends of the loop: a structured log line that a query engine can index, a drain that extends its retention, the Speed Insights mount and its reporter, the Web Analytics mount and its custom event, the two memory settings that trade off against each other, a revalidate window that removes the invocation entirely, a region choice that follows the database, and finally the usage API call that confirms the effect on the bill.


Quick Reference

Log Retention by Plan

PlanRetentionExtension
Hobby1 hourObservability Plus
Pro1 dayObservability Plus
Enterprise3 daysObservability Plus
Observability Plus30 daysLog drain to external

Speed Insights Metrics

MetricGood ThresholdMeasures
LCP≤ 2.5sLargest element render
INP≤ 200msClick to next frame
CLS≤ 0.1Unexpected layout shift
FCP≤ 1.8sFirst text or image
TTFB≤ 800msResponse start latency

Fluid Compute Billing (Pro)

Line itemRateBasis
Active CPU$0.128 / CPU-hourExecution milliseconds
Provisioned Memory$0.0106 / GB-hourAllocated memory × duration
Invocations$0.60 / millionRequest count
Fast Data Transfer$0.15 / GBEgress bandwidth

Log Drain Sources

SourceContent
lambdaServerless function output
buildBuild process output
edgeEdge function output
staticStatic asset requests

Cost Levers in Order of Impact

LeverEffectCost
ISR / cacheRemoves the invocation$0
RegionLowers latency, not cost$0
Memory tuningHalves Active CPUFree or small
SamplingDownsizes telemetrySaves metric fee

Best Practices

✅ Do This:

// Emit JSON, not strings
console.log(JSON.stringify({ event: "x", id }))              // ✅

// Sample Speed Insights on large properties
<SpeedInsights sampleRate={0.1} />                            // ✅

// Use constant event names for custom analytics
track("purchase_clicked", { sku })                            // ✅

// Raise memory on CPU-bound functions
"memory": 3009                                                // ✅
// Keep memory default on I/O-bound routes
"memory": 1024                                                // ✅

// Revalidate public pages on a long window
export const revalidate = 3600                                // ✅

// Drain to an external store for long retention
"deliveryFormat": "ndjson"                                    // ✅

❌ Don’t Do This:

// Log free-form strings you cannot query
console.log("done")                                           // ❌

// Report every session on a high-traffic page
<SpeedInsights sampleRate={1} />                              // ❌

// Dynamic event names that fragment the dashboard
track(`purchase_${sku}`)                                      // ❌

// Raise memory on an I/O-bound function
"memory": 3009  // on a webhook that awaits                    // ❌
// Cache a page that must not be stale
export const revalidate = 0  // defeats the cache              // ❌

// Use `dynamic = "force-dynamic"` on every route
export const dynamic = "force-dynamic"                        // ❌

// Assume the referrer header survives
// (it is stripped cross-origin; use UTM)                     // ❌

Common Pitfalls

PitfallWhy It HappensFix
Logs gone after an hourHobby retentionObservability Plus
Speed Insights shows averagesUser reads the summaryRead the 75th percentile
Referrer is directReferer header strippedUse UTM parameters
Event groups fragmentDynamic track nameUse a constant name
Bill rose after a deployMemory raised on I/O-bound routesRevert memory
Cache never hitsforce-dynamic presentRemove the export
Slow API not visible in logsNo duration loggedLog performance.now()
Drain bills surpriseReceiving service metersAdd sampling at the drain

Real-World Examples

1. Structured error log

console.error(JSON.stringify({ event: "error", code, path }));

2. Duration measurement

const t0 = performance.now();
await doWork();
console.log(JSON.stringify({ ms: performance.now() - t0 }));

3. Speed Insights mount

<SpeedInsights sampleRate={0.25} />

4. Custom vital in a client hook

useReportWebVitals((m) => track("vital", { name: m.name, value: m.value }));

5. Web Analytics mount

<Analytics />

6. Event with value

track("purchase", { sku, value: 49.99 });

7. Memory on a CPU-bound route

"app/api/report/route.ts": { "memory": 3009 }

8. Memory on an I/O-bound route

"app/api/webhook/route.ts": { "memory": 1024 }

9. Revalidate a marketing page

export const revalidate = 3600;

10. Pin a route to a region near the database

"app/api/orders/route.ts": { "regions": ["iad1"] }

Visual

The Observability Stack

┌─────────────────────────────────────────────────────────┐
│  BROWSER                                                │
│    Speed Insights  ──►  75th-percentile vitals          │
│    Web Analytics   ──►  pageviews, referrers, events    │
└─────────────────────────────────────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────────────────────┐
│  FUNCTION                                               │
│    Runtime Logs  ──►  stdout, stderr, structured JSON   │
│    Fluid billing ──►  active CPU, memory, invocations   │
└─────────────────────────────────────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────────────────────┐
│  RETENTION                                              │
│    Observability Plus  ──►  30 days in Vercel           │
│    Log Drain           ──►  external store, unbounded   │
└─────────────────────────────────────────────────────────┘

The Fluid Compute Bill

┌─────────────────────────────────────────────────────────┐
│  REQUEST                                                │
│      │                                                  │
│      ▼                                                  │
│  ┌─────────────────────────────────────────────┐        │
│  │  request body read                          │        │
│  │  ── Active CPU  ──  ── Memory (held) ──     │        │
│  └─────────────────────────────────────────────┘        │
│      │                                                  │
│      ▼                                                  │
│  ┌─────────────────────────────────────────────┐        │
│  │  await database query                       │        │
│  │  ── idle ──  ── Memory (held) ──            │        │
│  └─────────────────────────────────────────────┘        │
│      │                                                  │
│      ▼                                                  │
│  ┌─────────────────────────────────────────────┐        │
│  │  parse response, serialize                  │        │
│  │  ── Active CPU  ──  ── Memory (held) ──     │        │
│  └─────────────────────────────────────────────┘        │
│                                                         │
│  ACTIVE CPU = shaded blocks only                        │
│  PROVISIONED MEMORY = entire span                       │
└─────────────────────────────────────────────────────────┘

Field vs Lab

┌─────────────────────────────────────────────────────────┐
│  FIELD (Speed Insights)         LAB (Lighthouse)        │
│                                                         │
│  real device                    datacenter CPU          │
│  real network                   simulated network       │
│  real session                   single load             │
│  p75 over many users            one run                 │
│                                                         │
│  answers: WHAT is slow          answers: WHY it is slow │
└─────────────────────────────────────────────────────────┘

The Cache Win

┌─────────────────────────────────────────────────────────┐
│  WITHOUT ISR                   WITH ISR (3600s)         │
│                                                         │
│  1,000,000 views/day           1,000,000 views/day      │
│         │                             │                 │
│         ▼                             ▼                 │
│  1,000,000 invocations         24 invocations           │
│         │                             │                 │
│         ▼                             ▼                 │
│  billed per request            edge serves cached HTML  │
│                                function not invoked     │
└─────────────────────────────────────────────────────────┘

Summary

ItemValue
Log retention (Pro)1 day, 30 days with Observability Plus
Log drain formatndjson for streaming receivers
Core Web VitalsLCP, INP, CLS, FCP, TTFB
LCP threshold2.5s (good, 75th percentile)
INP threshold200ms (good, 75th percentile)
Speed Insights script@vercel/speed-insights/next
Web Analytics script@vercel/analytics/next
Custom event calltrack(name, properties)
Fluid billing linesActive CPU, Provisioned Memory, Invocations
Active CPU (Pro)$0.128 per CPU-hour
Provisioned Memory (Pro)$0.0106 per GB-hour
Invocations (Pro)$0.60 per million

Key takeaways:

  • Structured logs are the only queryable logs. A console.log with a JSON payload becomes a record with fields the dashboard can filter, group, and correlate by request ID. A console.log("done") is a string nobody can act on, and the difference is measured most sharply during an incident.
  • Retention is a plan setting, not a default. Hobby keeps one hour, Pro keeps one day, and anything longer requires Observability Plus or a log drain. The drain is cheaper for a large volume; Observability Plus is cheaper to set up, and most teams will use both at different stages.
  • Speed Insights reports percentiles, not averages. The 75th-percentile numbers are the ranking signal and the numbers to read, because a page can average 1.8s LCP and still fail the audit at p75 = 3.2s. Field and lab data answer different questions — field says what, lab says why.
  • Web Analytics is a cookie-free pageview layer with a custom-event API. It replaces a third-party script, avoids the consent banner, and provides the attribution that generic request logs cannot. Custom event names must be constants, and UTM parameters are the way to recover the referrer that modern browsers strip.
  • Fluid compute bills the CPU that runs and the memory that is held, separately. An I/O-bound function is billed for memory and invocation, not for the wall-clock wait, so raising memory helps a CPU-bound loop and wastes money on a function that awaits an upstream.
  • The cheapest optimization is the cache hit. ISR and edge caching remove the invocation entirely on a hit, and a page revalidated hourly on a high-traffic site converts a million daily invocations into twenty-four. Read the usage API to confirm the effect before and after.

Remember: Observability on Vercel is four surfaces feeding one decision. The logs tell you which request was slow; Speed Insights tells you how many real users felt it; Web Analytics tells you which page and which referral the slowest traffic came from; Fluid compute tells you what that slowness cost. Read the tail, not the average. Read the CPU, not the wall-clock. Cache the page, not the request. The monthly bill is the sum of a thousand small decisions, and the ones that show up are the ones that were measured — every other decision is an assumption, and assumptions on a serverless platform are billed at the end of the cycle.

Was this helpful?


Stop using slow, ad-bloated tool sites! 🤮

🔎 Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)

⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free

🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!