Guide

Serverless bills per request and per GB-second. An always-on container bills for the time it stays up. Which is cheaper depends on how busy the service is. Spiky or idle traffic favors serverless. Steady, high traffic favors containers. Do the math before you choose.

The billing formula

cost ≈ invocations × price per invocation
      + GB-seconds × price per GB-second
      (+ provisioned concurrency × time, if you use it)

GB-seconds are memory in GB multiplied by duration in seconds. The rest is counting.

Worked crossover at 5 requests per second

Take an API that averages 5 requests per second all month. Each request takes 100 ms on Lambda with 1 GB of memory. This sketch ignores free tiers and data transfer.

Invocations per month   ≈ 5 × 86,400 × 30           = 12,960,000
Request charges         ≈ 13 × $0.20                 ≈ $2.60
GB-seconds per month    ≈ 12,960,000 × 0.1 s × 1 GB  = 1,296,000
Compute charges         ≈ 1,296,000 × $0.0000167     ≈ $21.64
Lambda total (ballpark) ≈ $24.20 per month

The prices are rough public list prices, as of 2025–2026. Check current numbers before you budget.

For comparison, one small always-on container at 1 vCPU and 1 GB, running all month, costs roughly $30 to $50 or more. That is before extra replicas for high availability. At 5 requests per second, the two options are in the same range. The traffic shape decides it. Serverless wins when traffic is bursty and idle much of the time, because it scales to zero.

Now raise the load to 500 requests per second with the same request time:

GB-seconds per month    ≈ 100 × 1,296,000 = 129,600,000
Compute charges         ≈ 129,600,000 × $0.0000167 ≈ $2,160 per month

At steady high volume, a small set of warm containers with an autoscaler is usually cheaper. It also puts less load on the database.

Tip

A rule of thumb: spiky or low average use favors serverless. High steady use favors containers with an autoscaler. Revisit the decision each quarter with your FinOps numbers.

Common mistakes

  • Forgetting what the sketch leaves out. Free tiers, data transfer and logging all add cost in a real budget.
  • Pricing a container at one replica. High availability needs more.
  • Trusting old prices. Check the current price list before you decide.

Check yourself

  1. At 5 requests per second, which option is cheaper? Answer: they are close. Lambda is about $24 a month, and one small container is about $30 to $50. Traffic shape decides it.
  2. Why does 500 requests per second cost so much more on Lambda? Answer: GB-seconds grow with total busy time. A hundred times the traffic means about a hundred times the compute cost.

Key takeaways

  • Serverless cost is requests plus GB-seconds.
  • Spiky or idle traffic favors serverless. Steady, high traffic favors containers.
  • Compute GB-seconds before you choose, and recheck the choice each quarter.
  • Return to the serverless overview for the full decision checklist.

Further learning

AWS Lambda pricingAWS Lambda PricingAmazon Web Services, Inc. Cloud Run pricingGoogle Cloud Cloud Programming Simplified: A Berkeley View on Serverless ComputingServerless cloud computing handles virtually all the system administration operations needed to make it easier for programmers to use the cloud. It provides an interface that greatly simplifies cloud programming, and …arXiv.org