You've read the marketing hype about serverless. Pay only for what you use, they say. Scale automatically, no server management. But when you sit down with a calculator and your actual traffic numbers, the picture gets messier.
I've migrated dozens of client workloads between VPS instances and serverless platforms. The cost differences are real, but they don't follow the simple narratives vendors push. A low-traffic API might cost you more on serverless than a $5 droplet. A high-burst workload could bankrupt your VPS while serverless handles it for pocket change. Let's break down the actual math.
What we're comparing
Serverless here means function-as-a-service platforms—AWS Lambda, Google Cloud Functions, Azure Functions, Cloudflare Workers. You write code, deploy it, and pay per invocation plus compute time. No OS to patch, no disk to monitor.
VPS means a traditional virtual private server. You rent a slice of a physical machine with guaranteed CPU, RAM, and storage. DigitalOcean, Linode, Vultr, Hetzner—the usual suspects. You run whatever you want, but you pay whether it's idle or maxed out.
The hidden variable is egress. Both charge you to send data out to the internet, but the rates differ wildly.
Tier one: the side project
Let's say you run a small API that gets 100,000 requests per month. Each request takes 200ms of compute time and returns 5 KB of data. This is a typical profile for a hobby project or internal tool.
Serverless costs
Most platforms give you a million requests free each month, so your invocations cost nothing. Compute time is where you pay. At 200ms per request across 100k invocations, you're using 20,000 seconds of compute. With 128 MB of memory allocated, that's roughly 2,500 GB-seconds.
AWS Lambda charges about $0.0000166667 per GB-second after the free tier. Your compute bill sits around $0.04. Egress is the kicker—500 GB of outbound data at $0.09 per GB after the first GB free comes to $44.91. Total monthly cost: roughly $45.
VPS costs
A basic $5/month VPS from most providers gives you 1 vCPU, 1 GB RAM, and 1 TB of bandwidth. Your 500 GB easily fits under the cap. The instance handles 100k requests without breaking a sweat. You might not even see 20% CPU utilization.
Total monthly cost: $5.
The VPS wins by a landslide here. The serverless egress charges dwarf your compute costs, and the fixed VPS price is unbeatable for steady, predictable traffic.
Tier two: the growing SaaS
Now you're at 5 million requests per month. Average execution time is still 200ms, but response size varies—some requests return 2 KB, others 50 KB. Let's average it at 10 KB per response. Traffic is uneven: 60% of requests hit during business hours, creating pronounced peaks.
Serverless costs
You're past the free tier now. Five million invocations at roughly $0.20 per million (varies by platform) costs about $1. Compute time is 1 million seconds, or 125,000 GB-seconds at 128 MB. That's roughly $2.08.
Egress is brutal. 50 TB of data leaving the platform. AWS charges $0.09/GB for the first 10 TB, then the rate drops. Even with volume discounts, you're looking at $4,000+ in bandwidth charges. Total: around $4,003.
VPS costs
A single $5 VPS can't handle this load anymore. You need something beefier—probably a $20/month instance with 2 vCPUs and 4 GB RAM, plus 3-4 TB of bandwidth included. But 50 TB of transfer exceeds what any single cheap VPS provides.
You have two choices: upgrade to a higher tier with more bandwidth (Hetzner's 40 TB plans run about $50/month), or add a CDN like Cloudflare or BunnyCDN to cache responses and reduce origin bandwidth. With a CDN caching 80% of responses, you drop origin egress to 10 TB. Your VPS plus CDN costs might total $70-$90/month.
Serverless suddenly looks expensive. The VPS approach with a CDN in front is 40-50 times cheaper.
Tier three: the traffic spike
Your app just got featured somewhere. Normal traffic is 5 million requests per month, but today you're getting 5 million requests in six hours. Your usual 200ms execution time is holding steady, but the volume is crushing.
Serverless response
Nothing changes on your end. The platform scales automatically. You serve all 5 million requests without touching a config file. Your bill for the month doubles because you handled twice the normal load in that spike window, but the service never degraded.
Cost impact: an extra $4,000 for the spike, which you can often absorb or pass to customers if this is a revenue-generating product.
VPS response
Your $50 VPS is on fire. CPU hits 100%, requests start timing out, and users see errors. You have options:
- Manually scale up to a bigger instance mid-spike, which takes 10-20 minutes and might require a brief outage.
- Set up load balancing and autoscaling ahead of time, which means running 2-3 VPS instances all month even when you only need one. That triples your baseline cost.
- Let the VPS fall over and hope the spike passes quickly.
If you pre-provision extra capacity for potential spikes, you're paying $150-$200/month in standby infrastructure. If you don't, you risk downtime during the exact moment you have the most users.
Serverless wins here. The ability to absorb unpredictable load without pre-planning is worth the premium for many workloads.
What about cold starts?
Serverless functions sleep when idle. The first request after a quiet period takes longer—sometimes 500ms to 2 seconds—while the platform provisions a container and loads your code. Subsequent requests are fast until the function goes idle again.
This matters for user-facing APIs where latency counts. If your app has steady traffic, cold starts are rare. If it's bursty or low-volume, you'll hit them constantly. Some platforms let you pay extra to keep instances warm, which eats into the cost advantage.
VPS instances don't sleep. Your process is always running, always ready. Response time is consistent.
Hidden VPS costs
The $5 VPS price tag is deceptive. You're also paying in:
- Time: OS updates, security patches, log rotation, disk space monitoring, and service restarts all land on you. Even with automation, you're spending 2-4 hours per month on maintenance across a small VPS fleet.
- Failure risk: A disk failure or host migration takes your app down until you restore from backup. Managed VPS hosting reduces this but costs 2-3x more.
- Scaling ceiling: Moving from one VPS to a load-balanced cluster is a project, not a slider. You need to refactor session handling, set up a database separately, and configure health checks.
Serverless platforms handle all of that for you. The question is whether the convenience is worth the cost multiplier at your traffic level.
Hidden serverless costs
Serverless isn't pure savings either:
- Vendor lock-in: Your code runs on proprietary runtimes with platform-specific APIs. Moving from AWS Lambda to Google Cloud Functions means rewriting parts of your app.
- Observability: Debugging distributed functions is harder than tailing a log file on a VPS. You'll end up paying for third-party monitoring tools to get the visibility you need.
- Timeout limits: Most platforms kill functions after 5-15 minutes. Long-running jobs don't fit the model—you'll need a VPS or container service for those anyway.
When serverless makes financial sense
I've seen serverless win on cost in a few scenarios:
- Bursty workloads: If your traffic varies by 10x or more between peak and off-peak, paying only for actual usage beats paying for peak capacity 24/7.
- Event-driven backends: Processing webhook callbacks, async jobs, or scheduled tasks that run sporadically costs almost nothing on serverless but requires a VPS running idle most of the time.
- Team size: If your team is two people and you'd rather write features than manage infrastructure, the productivity gain from serverless might justify the higher bill.
When VPS makes financial sense
VPS hosting wins when:
- Steady traffic: If your request rate is predictable and doesn't spike dramatically, a right-sized VPS is far cheaper than serverless at scale.
- High egress: Serving large files, video, or data-heavy APIs? Bandwidth costs on serverless will destroy your budget. A VPS with generous transfer or a cheap CDN is the move.
- Control requirements: Specific kernel modules, custom networking, background daemons, or stateful services don't fit the serverless model. You need a real server.
Hybrid approaches
You don't have to pick one. Most production architectures mix both:
- Serve your main app from a VPS or container cluster for predictable baseline traffic.
- Use serverless functions for background jobs, webhooks, and sporadic tasks.
- Put a CDN in front of everything to minimize origin bandwidth.
This gives you cost efficiency for steady load and elastic scaling for the unpredictable parts.
Pick the right tool for your traffic
The serverless-versus-VPS decision isn't ideological. It's math. At low to medium traffic with high egress, a VPS wins on cost. At unpredictable or spiky traffic with small responses, serverless wins on simplicity and elasticity. At very high steady traffic, neither wins—you're looking at dedicated hardware or colocation.
Run the numbers with your actual request counts, execution times, and bandwidth needs. Don't trust marketing calculators that assume best-case scenarios. And remember that your time is worth something—sometimes paying an extra $50/month to avoid server maintenance is the smart move, even if the raw compute costs more.
