Optimize Vercel costs through tier selection, sampling, and usage monitoring.
Use when analyzing Vercel billing, reducing API costs,
or implementing usage monitoring and budget alerts.
Trigger with phrases like "vercel cost", "vercel billing",
"reduce vercel costs", "vercel pricing", "vercel expensive", "vercel budget".
Optimize Vercel costs by understanding the Fluid Compute pricing model, reducing function execution time, leveraging edge caching to avoid function invocations, and configuring spend management. Covers plan comparison, cost drivers, and monitoring.
Prerequisites
Access to Vercel billing dashboard
Understanding of current deployment architecture
Access to Vercel Analytics for usage patterns
Instructions
Step 1: Understand the Pricing Model
Vercel uses Fluid Compute pricing (for new projects):
Resource
Hobby (Free)
Pro ($20/member/mo)
Enterprise
Bandwidth
100 GB
1 TB included
Custom
Serverless Execution
100 GB-hrs
1000 GB-hrs included
Custom
Edge Function invocations
500K
1M included
Custom
Edge Middleware invocations
1M
1M included
Custom
Image Optimizations
1000
5000 included
Custom
Builds per day
6000
6000
Custom
Concurrent builds
1
1 (more available)
Custom
Fluid Compute billing breakdown:
Active CPU time: charged per ms of actual CPU usage
Provisioned memory: charged per GB-second of allocated memory
Benefit: you pay for actual work, not idle waiting (e.g., waiting for a database response)
Step 2: Identify Cost Drivers
# Check usage via API
curl -s -H "Authorization: Bearer $VERCEL_TOKEN" \
"https://api.vercel.com/v2/usage" | jq .
# Top cost drivers on Vercel:
# 1. Serverless function execution time (CPU + memory)
# 2. Bandwidth (large responses, unoptimized images)
# 3. Edge Middleware invocations (runs on EVERY request)
# 4. Image optimizations (each unique transform costs)
# 5. Build minutes (frequent deploys or slow builds)
Use Vercel's image optimization (auto WebP/AVIF conversion)
Set aggressive cache headers on static assets
Use ISR to serve static HTML instead of SSR
Compress API responses (Vercel auto-compresses with Brotli)
Step 5: Optimize Middleware Costs
Middleware runs on every matched request. Minimize its scope:
// middleware.ts — scope to specific paths only
export const config = {
matcher: [
// Only run middleware on API routes and protected pages
'/api/:path*',
'/dashboard/:path*',
// Skip static files, images, and public assets
'/((?!_next/static|_next/image|favicon.ico|public).*)',
],
};
export function middleware(request) {
// Keep logic minimal — this runs on every matched request
// Avoid: database queries, external API calls, heavy computation
// Good: cookie checks, header modifications, redirects
}
Step 6: Configure Spend Management
In the Vercel dashboard under Settings > Billing > Spend Management:
Default budget: $200/month on-demand usage
Options:
- Set custom budget limit
- Enable hard limit (pauses all projects when reached)
- Configure email alerts at 50%, 75%, 90%, 100%
# Check current usage against budget via API
curl -s -H "Authorization: Bearer $VERCEL_TOKEN" \
"https://api.vercel.com/v2/usage?teamId=team_xxx" \
| jq '{period: .period, bandwidth: .bandwidth, execution: .serverlessFunctionExecution}'