---
title: How to effectively load test your application on Vercel
description: Learn how to safely load test your Next.js app on Vercel. This guide covers realistic, policy-compliant testing of routes, caching, middleware, and databases to uncover performance issues without impacting Vercel’s infrastructure.
url: "https://vercel.com/kb/guide/how-to-effectively-load-test-your-vercel-application"
published: 2025-12-09
last_updated: 2026-11-18
authors: Nic Dillon
install_vercel_plugin: npx plugins add vercel/vercel-plugin
search_with_vercel_cli: npx vercel@latest kb search "<query>"
read_with_vercel_cli: "npx vercel@latest kb inspect how-to-effectively-load-test-your-vercel-application"
---

You need a safe, realistic way to load test your Next.js application on Vercel. The tests should validate your application logic without inadvertently stress-testing the Vercel platform or third-party services. Load tests should uncover issues in your code paths, caching, database access, middleware, and rate limiting before real traffic does—all while staying within Vercel's load-testing policy and security features.

> **Assumptions**: this guide assumes you have a Next.js app deployed to Vercel with Preview, Staging, and Production environments, and you can coordinate with any third-party providers used by your app.

* * *

### **1\. Define scope and guardrails**

**A) Align with Vercel’s policy**

If you plan to generate significant load, especially volumetric tests, coordinate first. Load tests that primarily exercise Vercel’s core infrastructure can be blocked by Vercel's DDoS mitigations while failing to validate your application’s implementation or configuration. Target your app’s dynamic routes and integrations instead.

> For any test that requires 50k+ requests per second (RPS), a ticket must be opened with Vercel’s engineering team. If your tests will reach this load, please reach out to your primary contact at Vercel to begin this process.

**B) Choose the right environment**

Run against a Staging or dedicated Preview deployment with production-like configuration and data fixtures. Use Preview deployments to wire tests into CI after each change.

**C) Instrument before you test**

Enable Vercel [Observability Plus](https://vercel.com/docs/observability/observability-plus) for detailed logs, traces, and insights. Add [Speed Insights](https://vercel.com/docs/speed-insights) and [Web Analytics](https://vercel.com/docs/analytics) to track traffic across pages and see fluctuations in performance metrics. If you need vendor APMs, enable OpenTelemetry using [Vercel OpenTelemetry Collector](https://vercel.com/docs/otel).

Vercel’s monitoring and observability tools can accrue significant cost during high traffic events, such as load testing. You will be responsible for any accrued cost, so be sure to turn off these monitoring tools or adjust sample rates to ensure costs stay in line with your team’s expectations and budget.

> Use Observability during tests to correlate spikes with function logs and traces, not just RPS charts.

**D) Configure System Bypass and WAF bypass rules**

To ensure your tests are not automatically blocked by Vercel’s DDoS mitigations or your WAF’s managed or custom rules, add a [System Bypass rule](https://vercel.com/docs/vercel-firewall/vercel-waf/system-bypass-rules) or a [custom bypass rule](https://vercel.com/docs/vercel-firewall/vercel-waf/managed-rulesets#bypassing-custom-rules), respectively. If possible, set the specific IP address or range of IP addresses you plan to send traffic from. Without these bypass rules in place, your load test requests may be identified as an attack or matched with WAF rules and blocked.

> System Bypass rules are available on Pro and Enterprise plans, with up to 10 rules per project on Pro and 75 on Enterprise. For load tests, use bypass rules rather than **Pause System Mitigations**. Pausing removes system mitigations for the entire project for 24 hours, and you are responsible for usage from all traffic during that time, including traffic that would otherwise have been blocked.

* * *

### **2\. Pick tooling and load shapes**

- Use a battle-tested tool like [**Artillery**](https://www.artillery.io/) or [**k6**](https://k6.io/).
  
- Prefer gradual ramps, stepped increases, and realistic traffic profiles.
  
- Avoid instant 0 → 100k RPS bursts that you will not see in production.
  
  - This keeps focus on your code paths rather than Vercel’s edge network capacity.
    

**Artillery example (ramped, realistic):**

```yaml
config:
  target: <https://your-staging-deployment.vercel.app>
  phases:
    - duration: 600   # 10 min
      arrivalRate: 20 # start ~20 rps
      rampTo: 200     # ramp to ~200 rps
  defaults:
    headers:
      x-test-run: "loadtest-YYYY-MM-DD"
scenarios:
  - name: "Dynamic API"
    flow:
      - get:
          url: "/api/search?q=test"
  - name: "Auth flow"
    flow:
      - get: { url: "/login" }
      - post:
          url: "/api/login"
          json: { email: "test@example.com", password: "secret" }
      - get: { url: "/account" }
```

**k6 example targeting a Route Handler with auth cookie:**

```jsx
import http from "k6/http";
import { check, sleep } from "k6";

export const options = {
  scenarios: {
    ramped: {
      executor: "ramping-arrival-rate",
      startRate: 20,
      timeUnit: "1s",
      preAllocatedVUs: 100,
      maxVUs: 300,
      // adjust durations and targets to meet your desired RPS
      // and total number of requests
      stages: [
        { duration: "5m", target: 200 }, // ramp to 200 it/s
        { duration: "10m", target: 200 },
        { duration: "3m", target: 0 }
      ]
    }
  },
  thresholds: {
    http_req_failed: ["rate<0.01"],
    http_req_duration: ["p(95)<4000", "p(99)<8000"]
  }
};

export default function () {
  const headers = { Cookie: `session=stubbed.token` };
  const res = http.get(`${__ENV.BASE_URL}/api/orders?limit=10`, { headers });
  check(res, { "status is 200/304": r => r.status === 200 || r.status === 304 });
  sleep(1);
}
```

Run with:

```bash
k6 run -e BASE_URL="<https://your-staging-deployment.vercel.app>" script.js
```

* * *

### **3\. Tests you should run (and how)**

#### **A) Functions that call external APIs or databases**

**Goal:** Validate latency percentiles, error handling, retries, and vendor rate limits.

**How:** Target Route Handlers or API routes that call your owned and managed external systems. Track p95/p99 latency and error rates.

**DB pooling:** In serverless environments, each invocation can open a new DB connection. Use connection-pooled approaches (HTTP database APIs, Prisma Accelerate/Prisma Postgres, or provider-native pooling) to avoid exhausting connections under concurrency. Verify behavior at increasing concurrency.

> Fluid compute is enabled by default for new projects (since April 23, 2025). It scales concurrency dynamically and can serve multiple invocations from a single function instance. Validate that your DB layer and external APIs scale with that concurrency.

#### **B) ISR and cache TTLs**

**Goal:** Confirm time-based revalidation, stale-while-revalidate behavior, and “thundering herd” scenarios.

**How:** In App Router, set revalidate on your fetch or route segment.

```jsx
export const revalidate = 60; // seconds

async function getData() {
  const res = await fetch("<https://api.example.com/data>", {
    next: { revalidate: 60 }, // time-based revalidation
  });
  return res.json();
}
```

> If your app uses Next.js 16 [Cache Components](https://nextjs.org/docs/app/getting-started/caching), use the `use cache` directive with `cacheLife` instead of route segment `revalidate`. For on-demand updates, call `revalidateTag(tag, 'max')` so cached content keeps being served while fresh data is fetched in the background.

**Test plan:**

1. Send a single request to warm the page.
   
2. After TTL expires, send a moderate burst. Expect stale content served while Next.js revalidates in the background, then refresh shows fresh content.
   
3. Increase concurrency to ensure only one regeneration occurs while others get stale content. Vercel's [request collapsing](https://vercel.com/docs/incremental-static-regeneration/request-collapsing) combines concurrent requests for an uncached or stale ISR page into a single function invocation per region.
   

**Review:** [Next.js caching](https://nextjs.org/docs/app/getting-started/caching), [caching without Cache Components](https://nextjs.org/docs/app/guides/caching-without-cache-components), [time-based revalidation](https://nextjs.org/docs/app/guides/incremental-static-regeneration#time-based-revalidation), and on-demand revalidation with [revalidatePath](https://nextjs.org/docs/app/guides/incremental-static-regeneration#on-demand-revalidation-with-revalidatepath) and [revalidateTag](https://nextjs.org/docs/app/guides/incremental-static-regeneration#on-demand-revalidation-with-revalidatetag).

#### **C) Concurrency and scaling of Functions**

**Goal:** Ensure application logic is safe under concurrent requests, including state, file handles, and connection limits.

**How:** Ramp up virtual users and verify no file descriptor or similar limits are hit. Check logs for spikes or failures.

> Vercel Functions have a limit of **1,024 file descriptors** shared across all concurrent executions. This limit includes file descriptors used by the runtime itself, so the actual number available to your application code will be strictly less than 1,024.
> 
> See more info [here](https://vercel.com/docs/functions/limitations#file-descriptors).

#### **D) Middleware and auth/session flows**

**Goal:** Ensure global middleware does not become a bottleneck and that auth redirects and cookies behave correctly under load.

**How:**

- Exercise routes protected by Middleware. In Next.js 16, Middleware is renamed to [Proxy](https://nextjs.org/docs/app/api-reference/file-conventions/proxy), and Vercel deploys it as [Routing Middleware](https://vercel.com/docs/routing-middleware).
  
- Keep Middleware lightweight and avoid heavy CPU or blocking I/O. It runs before the cache on every matched request. Proxy defaults to the Node.js runtime. If your Middleware uses the `edge` runtime, it is limited to an average of 50ms of CPU time under Vercel's [fair use guidelines](https://vercel.com/docs/limits/fair-use-guidelines).
  
- If you use Redis or KV for sessions, validate store hit rate and latency.
  

#### **E) Third-party integrations**

**Goal:** Payments, CMS, search, analytics resilience and fallbacks.

**How:**

- Coordinate with vendors or use sandbox endpoints.
  
- Validate backoff, retry, and circuit-breaker logic when vendors throttle or error.
  
- For rate limits, prefer vendor test modes where available.
  

#### **F) Rate limiting and WAF rules you manage**

**Goal:** Prove your protection works under bursts.

**How:**

- If using Vercel WAF, remove any configured custom bypass rules so your test traffic is identified again.
  
- Simulate realistic traffic spikes that hit your rate limit and confirm additional requests are rate-limited until the measurement period resets.
  

* * *

### **4\. Tests you should not run**

- **Do not load test Vercel’s core infra** such as raw CDN throughput or edge network capacity. That is not representative of your app’s performance and may be blocked.
  
- **Avoid benchmarking fully cached static assets**. You will mostly measure the CDN, not your code paths. Use functional flows instead.
  
- **Do not craft unrealistic traffic shapes** like instant 0 → 100k RPS spikes. Prefer staged ramps that mimic expected usage.
  
- **Do not hit production third-party endpoints** without explicit coordination. It can trigger fraud rules or bans.
  

* * *

### **5\. Implement representative scenarios**

Create small suites that exercise key user flows, such as product browsing, login, search, or other key flows in your application.

Make sure to also consider specific scenarios in which your implementation might be impacted by traffic, such as

- Retries
  
- Traffic spikes from a single IP (if rate limit rules are in place)
  
- Geo-specific marketing campaigns
  
- Authenticated endpoints
  

* * *

### **6\. Observe, verify, and iterate**

When conducting your load tests, it is vital to understand not only the result of the tests, but also how the simulated traffic impacts your application and downstream services.

- **Check logs and traces:** During the test, watch logs and traces to correlate slow endpoints and error spikes.
  
- **Watch Speed Insights and Web Analytics:** Check how new deployments affect performance and where traffic lands.
  
- **Validate caching outcomes**: Confirm time-based revalidation and on-demand invalidation with revalidatePath or revalidateTag.
  
- **Check function scaling and limits**: Ensure there is no file descriptor or memory contention under concurrency.
  
- **Verify WAF/rate-limit behavior**: Confirm that burst traffic is throttled or challenged as configured.
  

* * *

### **7\. Hardening tips for common bottlenecks**

- **Middleware**:
  
  - Keep logic minimal. It runs before cache and can add latency.
    
  - If using the `edge` runtime, respect the fair-use CPU limit (50ms on average).
    
  - Use [matchers](https://nextjs.org/docs/app/api-reference/file-conventions/proxy#matcher) to scope only where needed.
    
- **DB access**: Adopt connection-pooled or HTTP-based drivers and validate under [Fluid Compute](https://vercel.com/docs/fluid-compute) concurrency.
  
- **Caching**: Prefer revalidate on fetch or segment; use on-demand invalidation for content updates.
  
- **Security**:
  
  - Use [Vercel WAF](https://vercel.com/docs/vercel-firewall/vercel-waf) custom rules, the [Bot Protection Managed Ruleset](https://vercel.com/docs/bot-management#bot-protection-managed-ruleset), [BotID](https://vercel.com/docs/botid), and [Attack Mode](https://vercel.com/docs/vercel-firewall/attack-mode) when appropriate.
    
  - Attack Mode turns off automatically after 1, 6, or 24 hours. Choose the shortest duration that covers the attack.
    
  - To keep traffic from known, trusted IPs from being denied by your WAF rules, add a custom rule with a [bypass action](https://vercel.com/docs/vercel-firewall/vercel-waf/managed-rulesets#bypassing-custom-rules). To restrict access to a deployment by IP, use [trusted IP access with Vercel Firewall](https://vercel.com/docs/vercel-firewall/vercel-waf/trusted-ip-access).
    

> System Bypass Rules will not bypass Attack Mode. Be sure to disable it when load testing your application.

* * *

## **Expected outcome**

After following this guide, you will have:

- A reproducible, realistic load test suite that targets your application’s dynamic routes, DB/API integrations, middleware, and rate limiting.
  
- Verified ISR TTLs and stale-while-revalidate behavior under load without triggering [a thundering herd](https://en.wikipedia.org/wiki/Thundering_herd_problem).
  
- Observability dashboards and traces that correlate load to function latency, errors, and scaling, enabling you to tune code, caching, and rules with confidence.
  
- Confirmed WAF and app-level rate limiting behavior under burst scenarios.
  

* * *

## Related resources

- [Instrumentation](https://vercel.com/docs/otel)
  
- [Vercel Web Analytics](https://vercel.com/docs/analytics)
  
- [Speed Insights Overview](https://vercel.com/docs/speed-insights)
  
- [Observability Plus](https://vercel.com/docs/observability/observability-plus)
  

* * *

## How to reach out to Vercel Support

If you encounter issues not covered by this guide:

- Visit [Vercel Support](https://vercel.com/help).
  
- Check [Vercel Community](https://community.vercel.com/).
  
- As an enterprise customer, you can also open a ticket directly from your [Vercel Dashboard](https://vercel.com/dashboard).

## Reference Architecture

Choose a stack and work through the decisions behind it, with curated documentation, guides, templates, and courses to help you build.

- [Agent stack](/kb/architecture/agents): Build and operate agents with models, tools, and durable workflows.
- [Web applications](/kb/architecture/web): Choose rendering, data, authentication, and caching approaches.
- [Backends](/kb/architecture/backends): Choose a runtime, connect services, and run background work.

[Browse all stacks](/kb/architecture)

## Build with prompts

Build an app, extend an agent, or improve your project with ready-to-use prompts for your coding agent.

[Browse the prompt library](/kb/prompts) · [Read the Markdown index](/kb/prompts.md)

## Search guides from your terminal

Search the Knowledge Base and read guides as Markdown with the Vercel CLI. No login required.

```bash
# Find guides by keyword
npx vercel@latest kb search "rewrites and redirects"
npx vercel@latest kb search "AI SDK streaming"

# Show the latest guides
npx vercel@latest kb

# Print a guide as Markdown, by slug or URL
npx vercel@latest kb inspect <guide>
```
