In this article we’ll go through the ins and outs of AWS Lambda pricing model, how it works, what additional charges you might be looking at and what’s in the fine print.
Money makes the wold go round. Unfortunately, it is a necessity in almost all spheres of life. You can live without it or with lesser amounts of it, but it makes it all harder. If you wish to have it, first, you need to give it, as always. Even AWS Lambda is not free.
Simply put, you have an idea and are on a breakthrough to make it happen. You need to use AWS Lambda to make it easier, prettier, or for whatever reason, easier to maintain. You need to pay for AWS Lambda. In that way, your product will see the light of the day, which will eventually bring the money back to you. To be able to earn, you need to invest first.
A good thing with AWS Lambda prices is that you will only pay for what you use. There are no pre-set packages of their service where you will end up paying for something that you might not use at all. That’s why AWS Lambda decided to make it as simple as possible, which is a fantastic feature.
How does AWS Lambda charge for their services?
AWS Lambda is charging its users by the number of requests for their functions and by the duration, which is the time the code needs to execute. When your code starts running in response to an event, AWS Lambda counts a request. It will charge the total number of requests across all of the functions used. Duration is calculated by when your code started executing until it returns or is terminated, rounded up to the closest 1 millisecond. The AWS Lambda pricing depends on the amount of memory the user used to allocate to the function.
AWS Lambda pricing model explained
Usually, a Lambda invocation isn’t a stand-alone. A Lambda function gets triggered by events coming from an API Gateway, S3 bucket, or almost any other AWS service. These services have their costs additional to Lambda, and some of them come with free tiers.
AWS Lambda free tier
The Lambda Free Tier includes 400,000 GB-seconds of compute time every month. It doesn’t expire automatically at the end of the annual AWS Free Tier term. It is available indefinitely to both existing and new AWS customers.
400,000 seconds are over 110 hours of Lambda compute time per month, and that is only if you configure them with exactly 1 GB of memory.
With the default configuration of 128 MB, you would get 880 hours, with 256 MB still 440 hours per month.
But keep in mind that this also goes the other way around. If you configure 10 GB of memory, you only get one-tenth of time in the free tier, so 11 hours per month.
Let’s look at some example calculations:
If we ignore the free tier savings and run a function for one second (1000 milliseconds) and 128 MB of memory one million times, it will cost you $2.10. One millisecond at 128 MB memory costs $0.0000000021, times thousand gives us the second price of $0.0000021, and that times one million gives us $2.10.
Now, let’s see how much we would pay with the free tier. First, we have to convert the (1) GB-seconds into 128 MB-seconds because we don’t use 1 GB of memory in this example. 128 MB is one-eight of 1 GB, so we can simply multiply the value with 8.
400,000 GB-secconds = 3,200,000 128MB-seconds
Our function runs 1,000,000 128MB-seconds a month, so it’s within the 3,200,000 we’re allowed to run in the free tier, and we don’t pay a cent for it.
If your function would use the maximum memory configuration of 10.240 MB, the same one-second * one million invocations example would cost $166.70 because now you would pay more per millisecond, instead of $0.0000000021, one millisecond costs $0.0000001667.
We can also check how much the free tier would save us by dividing the (1) GB-seconds to 10GB-seconds by 10.
400,000 GB-seconds = 40,000 10GB-seconds
1,000,000 10GB-seconds – 40,000 10GB-seconds = 960,000 10GB-Seconds
The free tier saves us 40,000 10GB-seconds here, which is about $6.5.
API Gateway free tier
The API Gateway Free Tier, for Lambda functions triggered by API Gateway requests, includes 1 million free requests per month. After they’ve been spent, this tier will cost $0.20 per 1 million requests or $0.0000002 per a single request. The API Gateway free tier expires after 12 months.
For our examples from before, if we assume the event source was API Gateway, we don’t need to change the calculation in the first 12 months because we only make 1 million free requests. After that, we need to add $0.20 to the end price.
In the 10 GB memory example, this doesn’t change the bill much, but the first example with 128 MB would still cost us money, even if we don’t leave the Lambda free tier.
Dashbird’s Lambda cost calculator
If this information was helpful, but it still gives you a hard time calculating the price you’d need to pay, use our AWS Lambda cost calculator. It might help determine the costs you need to pay for AWS Lambda services based on personal usage. Follow this link and calculate your own AWS Lambda prices.
Additional charges within AWS Lambda pricing
People mostly do not like the fine print, and usually, they do not read it through. That is why we at Dashbird have read it all, and we wish to deliver it to you. That way, you will avoid any unnecessary and unpleasant experiences.
To avoid unnecessary situations, you need to know everything there is to know about pricing models, additional charges, etc. Are there any additional charges in AWS Lambda pricing models? Yes, there are. Read this carefully, and there will be no unpleasant surprises.
The possibility of additional costs to incur is significantly higher if you have used any other AWS services or data transfers. You will be charged regardless of the chosen tier. In the example, if your function is reading and writing data to or from Amazon S3, you will be charged for the read/write requests and all of the data stored within Amazon S3.
We will list some of the cases that will be charged additionally, and that way, you can follow up with all the changes made. If your Lambda function starts the external data transfers, you will be billed at the EC2 data transfer rate.
Also worth mentioning is that Amazon DynamoDB charges for data storage, throughput capacity, and data transfer. On the other hand, Amazon S3 is charging for storage, requests, and data transfers.
AWS Lambda pricing examples
The AWS Lambda pricing example will be presented in this section made by the AWS Lambda prices already mentioned.
You allocated 512 MB of memory to your function and executed it 3 million times during one month. Considering that it ran for 1 second each time, you’d be billed upon monthly compute time (in this case = $18.34) and by monthly requests (in this case = $0.40). Therefore, the total billed sum would be $18.74 per month.
That being said, AWS Lambda is amazing for cutting costs, and we’ve had plenty of examples where companies have managed to save big bucks by switching to Serverless. Coca-Cola North America has seen a lot of benefit from going serverless on their vending machines division, so much so that they’ve made serverless a requirement for their development division.
Knowing what you need and how much it might cost are the first steps to fulfilling your ideas and bring them to life.