Lambda vs Azure Functions vs Cloud Functions pricing
Short answer: function services charge for work done, not for a server sitting idle. All four clouds bill the same two things, which are the number of requests and the run time scaled by memory, with a monthly free allowance. The details differ, and for a small app the free allowance can cover the whole function bill.
Key points
- Cost has two parts: requests, and gigabyte-seconds.
- A gigabyte-second is memory (GB) multiplied by run time (seconds).
- Waiting on a database or API is billed as run time.
- Gateways, logging and data transfer are billed on top.
- Compare pay-per-use functions with pay-per-use functions, not with always-on plans.
How are functions billed?
- Per request. A small charge for each invocation, usually quoted per million.
- Per run time and memory. You pay for how long the code runs, scaled by the memory you give it. The unit is the gigabyte-second.
| Cloud | Service | Vendor page |
|---|---|---|
| AWS | Lambda | Lambda pricing |
| Azure | Functions (consumption-based plans, including Flex Consumption) | Functions pricing |
| Google Cloud | Cloud Run functions (formerly Cloud Functions) | Cloud Run pricing |
| Oracle | OCI Functions | Functions pricing |
They are equivalent as event-driven, pay-per-use code runners. A plan that reserves always-on capacity is a different product and should not be compared with these.
What does a worked example look like?
Made-up round numbers to show the method, not real prices. A function gets 10 million requests a month. Each run takes 200 ms with 512 MB of memory.
- GB-seconds: 10,000,000 x 0.2 s x 0.5 GB = 1,000,000 GB-seconds.
- Free allowance (made up): 400,000 GB-seconds and 1 million requests.
- Billable GB-seconds: 1,000,000 - 400,000 = 600,000.
- Billable requests: 10,000,000 - 1,000,000 = 9,000,000 = 9 million.
- Compute charge at 0.00002 per GB-second (made up): 600,000 x 0.00002 = 12.00.
- Request charge at 0.25 per million (made up): 9 x 0.25 = 2.25.
- Total: 14.25 per month.
Now double the run time to 400 ms. GB-seconds become 2,000,000, billable 1,600,000, and compute becomes 32.00. The request charge does not move. Run time and memory drive the bill, not the request count. Swap in real rates from the serverless estimator and the functions compare page.
What changes the total?
- Memory setting. More memory costs more per second, but may finish faster. Test it.
- Run time. Billing is rounded to a small step. Slow calls to other services are billed as run time.
- Free allowance. Each cloud gives a monthly allowance of requests and gigabyte-seconds. See free tiers explained.
- Extras around the function. API gateway requests, logging, network and data transfer are separate. See API gateway pricing and logging and monitoring costs.
When do servers win?
At steady high load, a function can cost more than a server that is always busy. The break-even depends on request rate and run time. A function with a long run time and heavy memory use is the first to lose. Serverless or servers shows how to compare them fairly.
Which mistakes are common?
- Leaving the memory at the default without testing.
- Calling a slow database from inside a function, and paying for the wait.
- Logging every request at full detail.
- Forgetting the gateway charge for every public call.
- Comparing a pay-per-use function with an always-on plan.
Decision checklist
- Is traffic spiky or low? Functions fit well.
- Is the load steady and heavy all day? Price a server too.
- Have I measured run time and memory, not guessed?
- Did I add the gateway, logs and data out?
Next steps
The serverless estimator takes requests per month, run time and memory and prices the same workload on each cloud with its free allowance applied. For the whole application, read what a web app costs.
Frequently asked questions
How is AWS Lambda priced?
Lambda charges per request and per gigabyte-second, which is run time multiplied by the memory you configure. A monthly free allowance of both is included, and other charges such as API gateway and logging are separate.
What is a GB-second?
One gigabyte of memory allocated for one second. A function with 512 MB that runs for 200 ms uses 0.5 GB x 0.2 s = 0.1 GB-seconds.
Does more memory cost more?
Per second, yes. On many platforms more memory also gives more CPU, so the function can finish faster, and the total can stay the same or fall. Test a few settings.
When are servers cheaper than functions?
At steady high load, where a server stays busy all day, the always-on price can be lower than paying per request. The break-even depends on request rate and run time.
Is Azure Functions Flex Consumption the same as the consumption plan?
They are different plans with different meters and free grants. Microsoft now recommends Flex Consumption for new apps, so check which plan your comparison uses.