Skip to main content
Serverless

Serverless Isn't Free: The Real Cost of Lambda and How to Escape It

Serverless is billed as pay-per-use, but the real cost is hidden in requests, memory, and cold starts. Here's how to stop overpaying and when to switch back to EC2.

We've been sold a story. The cloud giants, with their slick dashboards and reassuring marketing, want us to believe that serverless is the future of compute—a pay-per-use utopia where we only pay for what we actually consume. But if you've ever stared down a Lambda bill after a modest production spike, you know the truth: serverless is often the most expensive way to run steady, predictable workloads.

Don't get me wrong—serverless has its place. For spiky, event-driven tasks, it's a godsend. But the default advice to "just go serverless" is costing teams real money. The data backs this up. While the cloud market is booming—Synergy Research Group pegged Q2 2026 cloud infrastructure spending at $143 billion, up 43% year over year—most of that growth is in IaaS and PaaS, not pure serverless functions. Why? Because once you move past the free tier, the math gets ugly fast.

The Free Tier Trap

Every cloud provider lures you in with a generous free tier. AWS Lambda gives you 1 million requests and 400,000 GB-seconds per month (AWS Lambda Pricing). Azure Functions matches that with 1 million requests and 400,000 GB-seconds (Azure Functions Pricing). Google Cloud Functions throws in 2 million invocations and 400,000 GB-seconds (Google Cloud Functions Pricing). It feels infinite. It's not.

Here's the kicker: that free tier is designed for development and testing, not production. The moment your app gains traction, you blow past those limits and start paying per request and per GB-second. And the pricing isn't trivial. AWS charges $0.20 per million requests and $0.0000166667 per GB-second (AWS Lambda Pricing). Google charges $0.40 per million invocations and $0.0000100 per GHz-second (Google Cloud Functions Pricing).

Let me give you a concrete example. Say you're running a REST API that handles 10 million requests a month, with an average execution time of 200ms and 512MB memory. On AWS Lambda, that's 10 million requests × $0.20/million = $2.00. Compute: 10,000,000 × 0.2s × 0.5GB = 1,000,000 GB-seconds. That's $16.67. Total: $18.67. Seems cheap, right? But now add a second API, and a third. Multiply by your dev, staging, and production environments. The costs compound.

Compare that to a t3.micro EC2 instance at $0.0104/hour (AWS EC2 Price List API)—that's about $7.50 a month for always-on compute that can handle far more than a single Lambda's concurrency limit. Yes, you have to manage the server, but for steady traffic, the economics are undeniable.

Memory: The Hidden Tax

Serverless providers bill not just on execution time, but on memory allocated. AWS Lambda lets you choose between 128 MB and 10,240 MB in 1 MB increments (AWS Lambda Pricing). Azure Functions rounds memory up to the nearest 128 MB, with a max of 1,536 MB (Azure Functions Pricing). The more memory you allocate, the more you pay per GB-second—but also, crucially, the faster your function runs, because you get more CPU. So there's a sweet spot, but it's easy to overspend.

Consider this: a Lambda with 1 GB memory costs twice as much per GB-second as one with 512 MB. If your function only needs 256 MB, you're throwing money away. The problem is, most teams don't profile their functions. They set memory once and forget it. I've seen production Lambdas with 3 GB allocated for tasks that could run in 256 MB. That's a 12x cost multiplier.

And then there's the cold start problem. Serverless functions that haven't been invoked in a while suffer latency penalties as the platform spins up a new container. In practice, this means you often need to over-provision memory just to meet latency SLAs, further inflating your bill.

The Counter-Argument: "But We Don't Pay When Idle"

I hear it all the time: "With EC2, you pay for the server even when it's doing nothing. With Lambda, you only pay when you're invoked." That's true for truly sporadic workloads. If your function runs a few times a day, serverless is a no-brainer. But most production APIs have a baseline of traffic. Even a small service gets thousands of requests per hour.

Let's run the numbers. A t3.micro at $0.0104/hour runs you about $7.50 a month (AWS EC2 Price List API). If you run 10 million Lambda requests a month, you're paying $18.67, as we calculated—and that's just for one function. For the price of two or three actively used Lambdas, you could rent a dedicated server that handles hundreds of millions of requests. The idle time argument evaporates when you have sustained traffic.

Moreover, serverless isn't free to operate. You need observability tooling, log aggregation, and often a layer like AWS Lambda Extensions for tracing. Those add costs. And if you're using a managed Kubernetes service like EKS, you might think serverless containers (Fargate) are the answer. But Fargate's pricing is per vCPU and memory, and it can be far more expensive than EC2 for steady workloads.

The Escape: Know When to Go Back to Servers

So what's the solution? Stop treating serverless as a default. Start with a simple rule: if your workload has predictable, steady traffic, put it on a VM. If it's spiky, event-driven, or has long idle periods, use serverless. And when you do use serverless, right-size your memory allocation. Profile your functions, test different memory settings, and find the smallest that meets your latency requirements.

Here's a quick tip: run a load test on your Lambda with different memory settings. You'll often find that doubling memory cuts execution time in half, but the cost per GB-second stays the same—so you pay the same for half the latency. But beyond a certain point, you're just paying more for no speed gain.

Also, consider using AWS Graviton-based instances when you do move to EC2. They cost up to 20% less than comparable x86 instances (AWS Graviton). And if you're willing to commit, Savings Plans can cut costs by up to 72% (AWS Documentation). That's the kind of savings that makes a real dent in your cloud bill.

Bottom Line

Serverless is a tool, not a religion. The next time you're about to build a new service, resist the urge to default to Lambda. Evaluate your traffic patterns, run the numbers, and choose the compute model that actually fits. For steady workloads, that usually means EC2 with a Savings Plan. For intermittent tasks, serverless is fine—but only after you've right-sized your memory and set up budget alerts.

Stop paying for the illusion of pay-per-use. Start paying for what you actually need.

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 Documentation - https://docs.aws.amazon.com/ec2/

Share this article:

Comments (0)

No comments yet. Be the first to comment!