How to Run AWS Lambda Cheaper?

Maciej Matecki
AWS in Plain English
2 min readJun 19, 2021

--

Photo by NeONBRAND on Unsplash

With AWS Lambda, you pay per invocation of your function. But it’s very much different if you give your Lambda 256M of memory or 3GB of memory.

Using the AWS pricing calculator (https://aws.amazon.com/lambda/pricing/), we can find out that the Lambda function running for 250ms with 256M memory will cost $1.24 per 1M of invocations. The same Lambda with 3GB of memory will cost $12.70 per 1M of requests. It makes a huge difference.

But it’s not as simple as that. Our Lambda’s execution time can be shorter if we provide more memory, or maybe it’ll be almost the same. If it’s the same, it’s not worth paying more.

Anyway, one thing is sure — Lambda, which uses more memory and runs longer, costs more. By manipulating assigned memory, we can have an impact on the time of execution and final cost. The optimisation process can be extensive, but we are lucky enough to have a great tool to make this process super easy.

This tool is AWS Lambda Power Tuning. It uses step functions to run your Lambda with different parameters. The outcome is perfect visualisation which shows you the cost based on the memory assigned to your function. Having this, you can easily find an optimal configuration from a cost perspective and meet your performance expectations.

More content at plainenglish.io

--

--