Load test an app on Vercel
A load test against a Vercel deployment goes wrong in three ways. Vercel’s protections answer instead of your app, the CDN answers instead of your code, or the usage bill grows during the test. This page sets up a MaxoPerf test that avoids all three: you pass Vercel’s bypass header from a workspace secret, aim at routes that run your code, and read the results per route type.
For the reasoning behind each step, read Load testing Vercel without getting blocked and What a Vercel load test measures.
Before you start
Section titled “Before you start”You need a Vercel project with a Staging or dedicated Preview deployment, a MaxoPerf workspace, and a test that already runs. If you have no test yet, follow Run your first test first.
Vercel’s load-testing guide sets the ground rules:
- Coordinate with Vercel before significant load, especially volumetric tests. A test that needs 50k or more requests per second needs a ticket with Vercel’s engineering team.
- Run against a Staging or dedicated Preview deployment with production-like configuration and data, not production.
- Ramp gradually. Vercel warns against an instant jump to a very high rate that production never sees.
- You are responsible for any cost the test accrues.
Choose routes that run your code
Section titled “Choose routes that run your code”Vercel’s guide says that when you benchmark cached static assets, you mostly measure the CDN, not your code paths. Pick dynamic routes and API routes instead.
Check each candidate route with one request:
curl -sI https://your-preview-url.vercel.app/api/products | grep -i x-vercelRead x-vercel-cache in the output. HIT, PRERENDER and STALE mean the response came from cache or static storage. MISS and BYPASS mean the request reached your function or origin. Vercel notes that for dynamic routes the header often shows MISS even when the data came from its runtime cache, so MISS tells you the CDN did not answer, not that every layer behind it was cold. The x-vercel-id header lists the regions the request hit and the region the function ran in.
Keep the routes that return MISS or BYPASS and drop the ones that return HIT or PRERENDER.
Create the bypass secret in Vercel
Section titled “Create the bypass secret in Vercel”Deployment Protection (Vercel Authentication, Password Protection, Trusted IPs) and Vercel’s Firewall system mitigations answer a load generator with a challenge or a block. Vercel’s Protection Bypass for Automation, available on all plans, lets requests that carry a secret skip those checks.
- In your Vercel project settings, open the Protection Bypass for Automation section and add a secret. Vercel’s documentation lists the permissions you need and the click path.
- Copy the secret. Vercel sets one secret as the
VERCEL_AUTOMATION_BYPASS_SECRETsystem environment variable in your deployments. - If you regenerate or delete the secret later, redeploy. Vercel sets the variable at build time, so earlier deployments keep the old value.
The secret is sent as an HTTP header named x-vercel-protection-bypass. Vercel also accepts a query parameter with the same name, but URLs get logged, so use the header.
Store it as a MaxoPerf secret
Section titled “Store it as a MaxoPerf secret”- Open the workspace’s Secrets page and click Create secret. Name it
VERCEL_BYPASS. Secret names allow letters, digits and underscores, so a hyphenated name is rejected. - Paste the value from Vercel and save. MaxoPerf encrypts it and never shows it again.
Bind it to the test
Section titled “Bind it to the test”- Open the test and switch to the Dependencies tab.
- Add a Secret dependency and pick
VERCEL_BYPASS. - In Env name, type
VERCEL_BYPASS, or leave it empty to use the secret’s name. The console adds theSECRET_prefix, so the runner receivesSECRET_VERCEL_BYPASS.
Send the header
Section titled “Send the header”Read the variable in your test the same way as any other secret. The header name is the only part that is specific to Vercel.
Taurus:
headers: x-vercel-protection-bypass: ${__env(SECRET_VERCEL_BYPASS)}k6:
const params = { headers: { 'x-vercel-protection-bypass': __ENV.SECRET_VERCEL_BYPASS } };JMeter, in an HTTP Header Manager:
x-vercel-protection-bypass = ${__BeanShell(System.getenv("SECRET_VERCEL_BYPASS"))}The bypass skips Password Protection, Vercel Authentication, Trusted IPs checks, Firewall system mitigations and Bot protection challenges. It does not override active DDoS mitigations, rate limits applied during a detected attack, or challenges triggered by attack patterns. A large, sudden test can look like an attack, so ramp up.
Check the Firewall settings
Section titled “Check the Firewall settings”Vercel’s guide lists two Firewall points that the header does not solve:
- System Bypass rules do not bypass Attack Mode. Turn Attack Mode off for the duration of the test.
- System Bypass rules match on a source IP or range, and Vercel limits them to 10 rules per project on Pro and 75 on Enterprise. MaxoPerf publishes no runner IP list for managed locations, so use the header there. A private location generates load from your own network, so you know the egress IP and can put it in a rule.
Vercel advises preferring bypass rules over Pause System Mitigations, because pausing removes system mitigations for the entire project for 24 hours and you are responsible for the usage from all traffic in that window.
Label requests by route type
Section titled “Label requests by route type”A single average over every request hides the difference between a cached page and a function call. Give each request a label that names its route, so the results have one row per label.
- Taurus: set
label:on each request. - k6: pass a
nametag in the request params, for example{ tags: { name: 'GET products' } }. - JMeter: the sampler name is the label.
After the run, open the run’s Request stats tab. It lists each label with its sample count, and a COMBINED row for all labels together. Compare the labels that return MISS with any cached routes you kept, and judge latency per label, not from the COMBINED row.
If the run is blocked
Section titled “If the run is blocked”When a finished run has at least 100 samples and at least 30 percent of them were answered 403 or 429, or the target’s WAF identified itself and some requests were blocked, the run’s Overview shows a Blocked traffic notice. It gives the blocked share and the response codes, then lists fixes: allowlist the runner IPs, ask the WAF to bypass requests that carry a custom header, or lower the request rate and ramp up more slowly.
For a Vercel target, check these in order:
- The bypass secret is bound and the header name is spelled
x-vercel-protection-bypass. - You redeployed after changing the secret in Vercel.
- Attack Mode is off.
- The ramp is gradual and the rate is below what Vercel has agreed to.
Where to go next
Section titled “Where to go next”- Load testing Vercel without getting blocked: what each Vercel protection does and does not cover.
- What a Vercel load test measures: reading
x-vercel-cacheand choosing routes. - Estimate the Vercel bill from a load test: turn run totals into a spend estimate.
- Secrets and environments: the full secret binding rules.
- Read run results: the order to read a run in.