Skip to main content
Serverless

Serverless Isn't Free: Pick Compute That Fits the Job

Serverless sounds cheap, but Lambda's free tier hides costs. Compare Fargate, Functions, and spot VMs before you commit.

We keep hearing that serverless is the future and that you're throwing money away if you're still managing servers. But here's the contrarian take: serverless is often the most expensive way to run a steady workload. The free tiers are generous, but once you exceed them, the per-request and per-GB-second pricing can bite you. For a predictable, always-on service, a properly sized VM with a savings plan will likely beat Lambda on cost. (AWS Lambda Pricing)

This guide is for the working practitioner—the engineer or architect who has to make a real choice for a real workload. We're going to walk through the decision process step by step, comparing the serverless options from AWS, Azure, and Google, and showing when to pick one over a traditional VM. We'll use real numbers from the fact base, so you can see the trade-offs clearly.

1. Know Your Workload's Shape

Before you even look at pricing, understand your traffic pattern. Is it spiky, with long idle periods? Or is it a steady stream of requests? Serverless shines when you have unpredictable bursts and low average utilization—you pay only for what you use. But if you have a constant 1,000 requests per second, you're paying per request forever, and a VM might be cheaper. Also, consider your latency requirements: serverless functions have cold starts, though modern providers have mitigated that. For a low-latency, always-on API, a VM might be better.

2. Compare Free Tiers Generously

All three major clouds give you a free taste, and it's worth knowing the limits. AWS Lambda gives you 1 million requests and 400,000 GB-seconds per month (AWS Lambda Pricing). Azure Functions matches that: 1 million requests and 400,000 GB-seconds (Azure Functions Pricing). Google Cloud Functions offers 2 million invocations and 400,000 GB-seconds (Google Cloud Functions Pricing). For a small project, these free tiers are plenty. But if you grow, you'll hit the paywall fast. Also, don't forget the free VM offers: AWS has a free tier with 750 hours of a t2.micro or t3.micro for a year, and Google gives you an e2-micro VM for 720 hours a month (Google Compute Engine Pricing Guide). That's enough for a tiny always-on service.

3. Look Past the Free Tier: Lambda Pricing

Once you exceed the free tier, Lambda charges $0.20 per million requests and $0.0000166667 per GB-second (AWS Lambda Pricing). That GB-second is sneaky: it depends on memory allocation, which you can set from 128 MB up to 10,240 MB (AWS Lambda Pricing). Double the memory, double the cost per second. So a function with 1 GB of memory running for 1 second costs $0.0000166667. For 1 million seconds that's $16.67, plus requests. If you run a function that averages 100 ms, that's 10 million executions a month for a steady 10 requests per second—that's $2 for requests plus $1.67 for compute, about $3.67. A t3.micro VM at $0.0104/hour (AWS EC2 Price List API) costs $7.49 a month. So Lambda wins at low utilization, but if you hit 100 requests per second, Lambda costs $36.70, and the t3.micro is still $7.49. The crossover is around 20 requests per second. That's the kind of math you need to do.

4. Consider Containers on Fargate

AWS Fargate runs containers without managing servers, and it scales to 16 vCPU and 120 GB of memory per task (AWS Fargate). It's a middle ground: you package your app as a container, but you don't care about the underlying host. Pricing is per vCPU and GB per hour, but it's not in our fact base. However, we know that Fargate is often cheaper than Lambda for long-running processes because you're not paying per request. Azure Container Apps also has an always-free tier of 180,000 vCPU-seconds, 360,000 GiB-seconds, and 2 million requests per month (Azure Free Account). That's a nice free tier for containers.

5. Don't Forget Spot Instances for Fault-Tolerant Work

If your workload can handle interruptions, EC2 Spot Instances give you up to 90% off On-Demand (AWS EC2 Spot). That's a massive discount. They're perfect for batch processing, CI/CD, or any stateless service. The catch is a two-minute warning before termination (AWS Documentation). So if you design for that, you can save a bundle. For example, a t3.micro On-Demand is $0.0104/hour; a spot price can be as low as $0.001/hour, though it fluctuates. That's $0.72 a month. For a development environment, that's hard to beat.

6. Compare the Big Three: AWS, Azure, Google

Let's put it all in a table. We'll compare the serverless options and a baseline VM.

ProviderServerless OptionFree Tier (Requests/GB-sec)Pay-as-you-go Price (per million req / per GB-sec)Baseline VM (price/hour)
AWSLambda1M / 400K$0.20 / $0.0000166667t3.micro $0.0104
AzureFunctions1M / 400KNot in fact baseNot in fact base
GoogleCloud Functions2M / 400K$0.40 / $0.0000025 per GB-sece2-micro free tier

Notice the GB-sec price: Google charges $0.0000025 per GB-sec (Google Cloud Functions Pricing). That's much cheaper than AWS's $0.0000166667. But Google also charges $0.40 per million invocations, double AWS. So for request-heavy workloads, AWS wins; for compute-heavy, Google wins. Azure's pricing isn't in our fact base, but they have a similar model. Also, Azure Functions memory is capped at 1,536 MB (Azure Functions Pricing), while Lambda goes up to 10,240 MB.

7. Make the Call: Serverless vs. VM

So here's our recommendation: for a brand-new project with unknown traffic, start with serverless—it's cheap to start and scales automatically. But as soon as you see steady utilization, move to a VM with a savings plan. For example, if you're running a t3.micro for 24/7, that's $7.49/month On-Demand. With a 1-year Compute Savings Plan, you can get up to 66% off (AWS Documentation), bringing it to $2.55/month. That's less than Lambda for even moderate traffic. And for fault-tolerant batch work, use Spot Instances to cut costs by up to 90% (AWS EC2 Spot).

What Can Go Wrong

Here's the pitfall: you pick serverless for everything, and then you get a surprise bill. Because serverless pricing is per request and per GB-second, a small code inefficiency—like a function that runs 500 ms instead of 100 ms—can quintuple your compute cost. Also, watch out for memory allocation: if you set your Lambda to 1 GB but only need 128 MB, you're paying 8x more for compute. And don't forget that Azure Functions rounds memory up to the nearest 128 MB (Azure Functions Pricing), so a 129 MB function costs as much as 256 MB. That's a hidden cost.

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 Spot - https://aws.amazon.com/ec2/spot/
  • AWS Documentation - https://docs.aws.amazon.com/ec2/
  • AWS EC2 Price List API - https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/us-east-1/index.json

Share this article:

Comments (0)

No comments yet. Be the first to comment!