---
title: "Monitoring latency: Vercel Serverless Function vs Vercel Edge Function"
url: "https://www.openstatus.dev/blog/monitoring-latency-vercel-edge-vs-serverless"
date: "2024-03-14"
author: "Thibault Le Ouay Ducasse"
description: "We benchmarked Vercel Edge vs Serverless functions from 6 global regions. Edge averaged 106ms (P50), Serverless warm 246ms, and Serverless cold 859ms. Edge is 9x faster on cold starts and 2x faster when warm."
category: "education"
image: "https://www.openstatus.dev/assets/posts/monitoring-vercel/serverless-vs-edge.png"
---

In our previous
[article](/blog/monitoring-latency-cf-workers-fly-koyeb-raylway-render),
we compared the latency of various cloud providers but did not include Vercel.
This article will compare the latency of Vercel Serverless Function with Vercel
Edge Function.

We will test a basic Next.js application with the app router. Below is the code
for the routes:

```ts

export const dynamic = "force-dynamic";

export const maxDuration = 25; // to trick and not using the same function as the other ping route

export async function GET() {
  return NextResponse.json({ ping: "pong" }, { status: 200 });
}

export async function POST(req: Request) {
  const body = await req.json();
  return NextResponse.json({ ping: body }, { status: 200 });
}
```

We have 4 routes, 3 using the NodeJS runtime and one is using Edge runtime.

- `/api/ping` is using the NodeJS runtime
- `/api/ping/warm` is using the NodeJS runtime
- `/api/ping/cold` is using the NodeJS runtime
- `/api/ping/edge` is using the Edge runtime

Each route have a different `maxDuration`, it's a trick to avoid bundling the
functions in the same physical functions.

Here is the repository of the
[application](https://github.com/openstatusHQ/openstatus-next-latency).

## Vercel Serverless Function - NodeJS runtime

They are using the NodeJS 18 runtime. We have access to all the nodejs API. Our
function are deployed in a single location: iad1 - Washington, D.C., USA.

Upgrading to Node.js 20 could enhance cold start performance, but it's still in
beta.

We analyzed the header of each request and observe that all requests are
processed in a data center near our location before being routed to our
serverless location.

- `ams` -> `fra1` -> `iad1`
- `gru` -> `gru1` -> `iad1`
- `hkg` -> `hkg1` -> `iad1`
- `iad` -> `iad1` -> `iad1`
- `jnb` -> `cpt1` -> `iad1`
- `syd` -> `syd1` -> `iad1`

We never encountered a request routed to a different data center, and we never
hit the Vercel cache.

### Warm - `/api/ping/warm`

**100**% UPTIME

**0**# FAILS

**12,090**# PINGS

**246**ms P50

**305**ms P75

**442**ms P90

**563**ms P95

**855**ms P99

We are pinging this functions every 5 minutes to keep it warm.

### Cold - `/api/ping/cold`

**100**% UPTIME

**0**# FAILS

**2,010**# PINGS

**859**ms P50

**933**ms P75

**1,004**ms P90

**1,046**ms P95

**1,156**ms P99

We are pinging this functions every 30 minutes to ensure the functions will be
scaled down.

### Cold Roulette - `/api/ping`

**100**% UPTIME

**0**# FAILS

**6,036**# PINGS

**305**ms P50

**791**ms P75

**914**ms P90

**972**ms P95

**1,086**ms P99

We are pinging this functions every 10 minutes. It's an inflection point where
we never know if the function will be warm or cold.

## Vercel Edge Function

Vercel Edge Functions is using the Edge Runtime. They are deployed globally and
executed in a datacenter close to the user.

They have limitations compared to the NodeJs runtime, but they have a faster
cold start.

We analyzed the request header and found that the `X-Vercel-Id` header indicates
the request is processed in a datacenter near the user.

- `ams` -> `fra1`
- `gru` -> `gru1`
- `hkg` -> `hkg1`
- `iad` -> `iad1`
- `jnb` -> `cpt1`
- `syd` -> `syd1`

### Edge - `/api/ping/edge`

**100**% UPTIME

**0**# FAILS

**6,042**# PINGS

**106**ms P50

**124**ms P75

**152**ms P90

**178**ms P95

**328**ms P99

We are pinging this functions every 10 minutes.

## Conclusion

| Runtime | p50 | p95 | p99 |
| --- | --- | --- | --- |
| Serverless Cold Start | 859ms | 1 | 046ms |
| Serverless Warm | 246ms | 563ms | 855ms |
| Edge | 106ms | 178ms | 328ms |

Globablly Edge functions are approximately 9 times faster than Serverless
functions during cold starts, but only 2 times faster when the function is warm.

Edge functions have similar latency regardless of the user's location. If you
value your users and have a worldwide audience, you should consider Edge
Functions.

You can reproduce this for your own deployment with the
[website speed test](/play/checker) — it runs from the same 28 regions and breaks
each request into DNS, TCP, TLS, and TTFB, which is how the cold-start gap above
becomes visible.

Create an account on [openstatus](/app/sign-up) to
monitor your API and get notified when your latency increases.

## Frequently asked questions

<details>
  <summary>Is Vercel Edge faster than Vercel Serverless?</summary>
  Yes. In our benchmark from 6 global regions, Edge functions averaged 106ms (P50) vs 246ms for warm Serverless and 859ms for cold Serverless. Edge is about 9x faster during cold starts and 2x faster when warm.
</details>

<details>
  <summary>What is the cold start latency of Vercel Serverless functions?</summary>
  In our test, Vercel Serverless cold starts averaged 859ms (P50), with P95 at 1,046ms and P99 at 1,156ms. Functions were pinged every 30 minutes to ensure they scaled down between requests.
</details>

<details>
  <summary>Do Vercel Edge functions have cold starts?</summary>
  Vercel Edge functions have negligible cold starts. In our benchmark, Edge functions maintained a consistent P50 of 106ms and P99 of 328ms regardless of request frequency, compared to Serverless which jumped from 246ms (warm) to 859ms (cold).
</details>

<details>
  <summary>Where are Vercel Serverless functions deployed?</summary>
  Vercel Serverless functions are deployed in a single region (iad1 — Washington, D.C. by default). All requests are routed through a nearby data center before being forwarded to the function's region. Edge functions are deployed globally and execute in the datacenter closest to the user.
</details>