Why I Almost Drowned in Serverless Hype
I remember the day I saw the Lambda free tier: one million requests and 400,000 GB-seconds of compute per month (AWS Lambda Pricing). I thought, "Great, my app will cost nothing!" Then I ran a real workload and watched the bill climb past what a small EC2 instance would have cost. The problem isn't that serverless is expensive per se—it's that we treat it as a default instead of a tool. In this article, I'll share a practical how-to for deciding when serverless is worth it and when you should switch to a virtual machine.
Who This Is For
This is for developers and small teams who are building on AWS, Azure, or Google Cloud and are tempted to go all-in on serverless because it sounds modern. You've probably read that serverless means no servers to manage, which is true, but it also means you're paying for every millisecond of execution and every request. If you have a bursty workload that needs to scale to zero, serverless is great. If you have a steady, always-on service, you're likely overspending. Let me show you how I evaluate my own projects.
Step 1: Map Your Workload's Rhythm
Before picking a compute service, I look at the traffic pattern. For a cron job that runs once a day, Lambda is perfect—I'm paying for a few seconds of compute. But for a REST API that's hit every second, Lambda would rack up requests and GB-seconds quickly. The free tiers are generous: Lambda gives you one million requests and 400,000 GB-seconds per month (AWS Lambda Pricing). Azure Functions gives the same: one million requests and 400,000 GB-seconds monthly (Azure Functions Pricing). Google Cloud Functions offers two million invocations and 400,000 GB-seconds (Google Cloud Functions Pricing). That sounds like a lot, but a modest API handling 10 requests per second uses about 26 million requests a month—that's 26 times the free tier. After that, you're paying $0.20 per million requests on Lambda (AWS Lambda Pricing). That's $5.20 just for requests, plus compute time. Meanwhile, a t3.micro instance costs $0.0104 per hour (AWS EC2 Price List API)—about $7.50 a month for 24/7 uptime. So for a steady API, the VM wins on price, and you don't have to worry about cold starts.
Step 2: Check the Price Per Compute Unit
If you do go serverless, you need to understand how you're billed. Lambda charges $0.0000166667 per GB-second (AWS Lambda Pricing). That means a function with 1 GB of memory running for one second costs that tiny amount. Multiply it out: a 1 GB function running for 100 seconds an hour, 24/7, costs about $1.20 a day—$36 a month. That's more than a t3.micro. For containerized workloads, Fargate bills you per vCPU and memory per second (AWS Fargate). It's also not cheap for always-on. So I use this rule: if my service is idle most of the time, serverless shines. If it's active all day, I look at EC2 or even a managed Kubernetes cluster, where you only pay for nodes (AWS EKS).
Step 3: Consider the Hidden Costs of Serverless
One hidden cost is the per-request pricing. Even if your compute time is low, a high request rate can burn through your free tier. For example, a webhook that receives 100,000 requests a day is 3 million a month—triple the free tier. On Lambda, that's $0.60 in requests alone (AWS Lambda Pricing). On Azure Functions, the same (Azure Functions Pricing). On Google, it's $0.40 per million after the free 2 million (Google Cloud Functions Pricing). That's not huge, but it adds up. Another hidden cost is memory allocation. Lambda lets you set memory from 128 MB to 10,240 MB (AWS Lambda Pricing). If you set it high for a quick task, you're paying more per GB-second. I once set a function to 1,024 MB for a simple image resize—that cost 8x more than if I'd used 128 MB. So I always start with the minimum memory that meets my needs.
Step 4: Know When to Switch to a VM
If your workload is steady and you can tolerate a bit of management, switch to a VM. AWS Graviton instances are a great middle ground: they cost up to 20% less than comparable x86 instances (AWS Graviton). For example, m7g.large (2 vCPU, 8 GiB) is $0.0816/hour, while m7i.large is $0.1008/hour (AWS EC2 Price List API). That's a 19% discount. If you have a long-running service, also consider Savings Plans: Compute Savings Plans give up to 66% off, and EC2 Instance Savings Plans up to 72% (AWS Documentation). That can make a VM much cheaper than serverless. But if you're still in development, the free tiers are great for experimentation. AWS gives $200 in credits for 6 months (AWS Free Tier), Azure gives $200 for 30 days (Azure Free Account), and Google gives $300 for 90 days (Google Cloud Functions Pricing).
What Can Go Wrong
The biggest trap is assuming serverless is always cheaper. I've seen teams build a microservices architecture on Lambda and then wonder why their bill is $500 a month when a single EC2 instance would have cost $50. Also, beware of the 'always-on' serverless pattern: a function that polls a queue every second runs 86,400 times a day—that's 2.6 million invocations a month, blowing past the free tier (AWS Lambda Pricing). And if you use Fargate for a 24/7 service, you're paying for the vCPU and memory the entire time, which is often more expensive than a reserved instance.
Quick tip: Use serverless for event-driven, bursty, or low-utilization workloads. Use a VM for steady, high-utilization workloads. Don't let the 'serverless' label cloud your judgment.
The Bottom Line
The most important thing to remember is that 'serverless' is a billing model, not a magic discount. It's perfect for some jobs, but for others, a boring old VM is your cheapest, most predictable compute. So before you deploy your next function, ask yourself: how often is this code actually running? If the answer is 'all the time,' you're better off with a VM. If it's 'rarely,' go serverless. That's the pragmatic approach that has saved me from bill shock.
Sources
- AWS Lambda Pricing - https://aws.amazon.com/lambda/pricing/
- Azure Functions Pricing - https://azure.microsoft.com/en-us/pricing/details/functions/
- Google Cloud Functions Pricing - https://www.srvrlss.io/provider/google-cloud-functions/
- AWS EC2 Price List API - https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/us-east-1/index.json
- AWS Graviton - https://aws.amazon.com/ec2/graviton/
- AWS Fargate - https://aws.amazon.com/fargate/
Comments (0)
Please sign in to post a comment.
Don't have an account? Create one
No comments yet. Be the first to comment!