As a continuation to my post on best practices on AWS Lambda I wrote a tool which finds the right size of your existing Lambda function programmatically by continuously resizing it, firing test events at it until it finds the best size which would either:
- Save you the most money OR
- Give you the best performance
Currently, in its first version it gives auto resizing options based on best latency with configurable acceptable drop in performance (e.g. 3%) in favor of cost savings. I will be building up this tool to have more such strategies and refining it as I go.
Find the project under MIT license on github here.
You need .NET core installed wherever you run this tool, .NET core is open source and cross-platform so get one for your own OS.
The server / PC you run it on must either be running under a AWS Role having permissions to resize, get configurations and invoke Lambda functions or if you are on your PC, provide the credentials by keeping it in standard locations as AWS recommends here.
Using the tool
You can run it in command line mode by simply giving some arguments, in .NET core command line is run via the dotnet.exe file:
"C:\Program Files\dotnet\dotnet.exe" aws.lambda.sizeOptimizer.dll [-?|-h|--help] [-r |--aws-region <region>] [-n |--fn-name <functionName>] [-p |--payload-path <payloadPath>] [-64 |--use-64mb] [-l |--latency-margin <acceptableDropInPerformance>] [-ar |--auto-resize]
Running it manually
Simply run the program without giving it any arguments and it will ask for input.
Want to contribute?
I am open (and actually looking forward) to pull requests on the project.
Setting up the environment
You need Visual Studio Code, Visual studio code is a free and open source code editor developed by Microsoft. It is cross-platform and works with Windows, MAC and Linux, for more features and background on this checkout this wiki link.
In my experience with this code editor, it is by far the best free code editor that I have worked with. Its ability to go multi-platform along with being free to use while supporting all the languages that I will ever use (with plugins installed) it is a go-to IDE for anyone on a budget or a requirement of cross-platform targeting.
If you don’t have .Net core installed get it from here.
Install the c# extension for VS code from VS code marketplace.
You can optionally checkout a getting started guide that I had posted some time back.
If you liked this article, you can choose to follow this blog/subscribe to email alerts (top of sidebar or below comments in mobile) so that you know when any future posts come about.