Serverless vs VPS Cost Guide
Compare serverless function pricing with a fixed-price VPS cluster, using per-request and GB-second rates, and find the crossover point.
Last updated 2026-11-26
Serverless platforms charge for each request and for the compute time each request uses. A virtual private server (VPS) charges a fixed monthly price per machine. Neither is always cheaper. The crossover point depends on how many requests you serve, how long each one runs, how much memory it reserves, and what your database costs.
The published rates
AWS Lambda, the most widely used serverless function service, publishes two compute rates for the US regions: $0.20 per million requests, and $0.0000166667 per GB-second of compute. Its free tier includes 1 million requests and 400,000 GB-seconds a month. A GB-second is the memory allocated, in GB, multiplied by the duration in seconds. Lambda defines 1 GB as 1,024 MB.
The formulas
GB-seconds = requests x (duration in seconds) x (memory in MB / 1,024)
serverless compute = max(0, requests - 1 million) x $0.20 per million
+ max(0, GB-seconds - 400,000) x $0.0000166667
VPS cost = nodes x price per node
nodes = max(1, ceil(requests x (duration in ms / 200) / 12 million))The node formula is a planning heuristic, not a published rate. It assumes each node handles about 12 million requests a month at a 200 ms average duration, and that longer requests reduce that capacity. Benchmark your own workload before relying on it.
A worked example
A team runs 5 million requests a month, each taking 200 ms with 512 MB of memory, plus a database of 50 GB.
- GB-seconds: 5,000,000 × 0.2 s × (512 ÷ 1,024) GB = 500,000
- Request charge: (5 − 1) × $0.20 = $0.80
- Compute charge: (500,000 − 400,000) × $0.0000166667 = $1.67
- Database: 50 GB × $0.25 = $12.50 (a planning assumption; check your provider's price)
- Serverless total: $14.97 per month
- VPS at one node: $24 + (50 − 40) × $0.10 = $25 (planning assumption)
Notice where the money goes. Compute is only $2.47 of the serverless bill, and the database is most of the rest. The database price is an assumption in this model, so a different database price can change the answer. At 25 million requests a month, the serverless total is about $52.30, which is still below the modelled VPS cost once the cluster grows to three nodes.
Common mistakes
- Forgetting the free tier. Small workloads can cost nothing in compute. Include it in the comparison.
- Using the average duration from a dashboard without checking it. Averages hide slow endpoints, and slow requests use most of the GB-seconds.
- Ignoring memory settings. Lambda bills memory as well as time, so an over-provisioned function costs more even if it is fast.
- Leaving out data transfer. Traffic leaving the cloud is billed separately on both platforms and is not part of this comparison.
What to do next
Pull request count, average duration and memory from your own function logs, use your database provider's published storage price, and run the calculator at your current traffic and at two or three times that level.