Serverless Pricing and Costs: AWS Lambda and Lambda@Edge

(Note: These prices are accurate as of August 2018)

AWS Lambda has 263 separate billable line items each with their own prices. They have names like “Accelerated InterRegion Inbound using edge locations outside US, Europe or Japan, From EU (Paris) to EU (London)”, and exist for each of the 17 regions it is offered in. All told that is 4,471 separate prices you can be charged for executing Lambda.

That gets added to the 635,035 prices for EC2 services, 12,261 for Route53, and 15,283 for API Gateway. All told Amazon has over a million separate rates you can be charged for various services. It’s so complex they even have a dedicated API just to expose pricing, which is how I got these numbers (Lambda is not included in the price calculator).

Even in the simplest case, the pricing for Lambda is far from simple: A free tier followed by $0.20 per million requests plus $0.00001667 per GB-second of ‘compute time’ used per month plus the cost of the API Gateway ($3.50 per million) you use to translate HTTP requests into Lambda executions. You are also charged for any data transfer done by your Lambda ($0.09 per GB), and any Dynamo DB requests you make from it (I can’t).

What is Compute Time?

You are charged $0.00001667 per GB-second of compute time your Lambda performs. GB-second is a bit of an odd unit. It could mean the number of seconds you’re using a GB of memory, but it actually means the number of seconds of compute you’ve done, multiplied by the number of GB of memory that compute allocated.

For people who aren’t comfortable with microcents as a unit of measure I’ve compiled the numbers into a chart which shows how much memory and CPU-time you get for $1–6 per million requests:

Amazon includes a pricing table on their page which excludes the $0.20/million base charge, but I’ve included it in my numbers.

Of course, a ms of CPU time can mean many different things. A ms of compute on an Apple II represented 3000 clock cycles. On the i7 in my laptop it’s 4 million cycles. In Amazon’s case, they actually scale up the speed of the CPU they provide based on how much memory you allocate. In other words your performance is memory * CPU time where CPU timegets smaller the more memory you use. This CPU boost continues until you have what looks like a full core, after which it grants you a second core which your application may or may not benefit from depending on its composition.

To compensate for that I’ve adjusted my chart to show how much actual CPU time you’re getting based on the mid-grade server processors we used in our comparison testing.

As you can see from the chart, it doesn’t, from a cost perspective, matter if you elect to run a 1024 MB Lambda for 100ms, or a 128 MB Lambda for 800ms, you get the same amount of compute and pay the same amount. Above 1024 MB though you reach the performance of a full processor core and begin getting the power of a second core (if your application is multithreaded).


CPU time is rounded up to the nearest 100ms, meaning even the simple Lambda which returned the current time we used in our tests cost us $0.41 / million invocations. Of course, your Lambda will rarely execute with a number of ms of CPU that rounds perfectly. Much more commonly you’ll use some odd number of ms which Amazon will round up to calculate how much to charge you. Given that they always round up, that means you will be overpaying by an average of 50ms of CPU for every invocation:

API Gateway

AWS Lambda’s can perform a wide variety of tasks within Amazon. We’re interested in their use for building Serverless web applications specifically. For that purpose, a Lambda can’t be used directly, it needs some HTTP server which is willing to translate a request into a call to the Lambda’s invoke API. By far the most common way to do this is with Amazon's API Gateway product.

API Gateway is billed at $3.50 per million requests, a price which often exceeds the cost of the Lambda itself. Here is our chart from above adjusted to include API Gateway:

You’ll notice the $1, $2, and $3 lines have disappeared from the chart. The absolute minimum is $3.91 / million requests if your Lambda consumes very little CPU.

You’ll also have to pay for your traffic, and an additional hourly fee if you wish to use caching.

Route 53

Amazon’s Route53 DNS service isn’t free. You’ll pay $0.40 per million DNS requests for the first billion. That brings our total minimum cost to $4.31 / million.

More Costs

Tabulating all the costs can be somewhat exausting. CloudWatch logs are $0.50 per GB. The $0.09 per GB of traffic charges will start to add up.


Amazon also offers a way of running code through their CDN service, Cloudfront. Both the fixed and variable costs are exactly tripled when compared to Lambda, making them roughly 10x Cloudflare Workers.

Of course, for HTTPS requests Cloudfront itself costs $1 / million requests and that has to be purchased to use Lambda@Edge. You also pay bandwidth costs which can easily dwarf that price. If your site is 1 MB, you’ll end up paying as much as $85 / million just in Cloudfront bandwidth, $250 / million in regions like South America. Plus an additional $20 / million for requests which have to go back to your origin.

Here’s what that looks like for just the compute component:

PS: I work at Cloudflare, where we have a product called Workers. I won’t shill too much for it here, but you might want to take a look.

Product Strategy at Cloudflare

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store