When you create a Lambda function, you need to configure the amount of RAM memory that will be available for use. It ranges from 128 MB to 1.5 GB. Allocating more memory means additional costs. It breaks the philosophy of avoiding provision, but at least it's the only thing you need to worry about. The good practice here is to estimate how much memory each function needs and make some tests before deploying to production. A bad provision may result in errors or higher costs.
Lambda has the following billing model:
- US$ 0.20 per 1 million requests
- US$ 0.00001667 GB-second
Furthermore, there is a permanent free tier that gives you 1 million requests and 400,000 GB-seconds per month without charges.
In our use case scenario, we have assumed 5 million requests per month with an average of 200 milliseconds per execution. We can also assume that the allocated RAM memory is 512 MB per function:
- Request charges: Since 1 million requests are free, you pay for 4 million that will cost US$ 0.80.
- Compute charges: Here, 5 million executions of 200 milliseconds each gives us 1 million seconds. As we are running with a 512 MB capacity, it results in 500,000 GB-seconds, where 400,000 GB-seconds of these are free, resulting in a charge of 100,000 GB-seconds that costs US$ 1.67.
- Total: US$ 2.47