AWS Lambda battle: x86 vs ARM(Graviton2)
As you may know, just a month ago AWS announced AWS Graviton2 Processors for AWS Lambda and says that AWS Lambda functions using the Arm/Graviton2 architecture provide up to 34 percent price-performance improvement.
In this article, we are going to check what real price-performance improvement we can see for the most common lambda use-case.
This article is a continuation of my previous article AWS Lambda battle 2021: performance comparison for all languages (cold and warm start)
Thank you so much to everyone who contributes to https://github.com/Aleksandr-Filichkin/aws-lambda-runtimes-performance. As you will see we significantly improved performance for NodeJs https://github.com/Aleksandr-Filichkin/aws-lambda-runtimes-performance/pull/6
All benchmarks were performed in November 2021
I’m not an expert in all these languages and I’m happy to see MR in GitHub repo with performance improvements. I’m going to support these repo and run the perfomance test every 3 months. I believe in opensource collaboration :)
We are going to compare performance for ARM and x86 for cold and warm states for all supported runtimes + Rust and Graalvm:
- NodeJs (14.x)
- Python (3.9)
- Java (11)
All source code is here: https://github.com/Aleksandr-Filichkin/aws-lambda-runtimes-performance
We are going to test API-Gateway -> AWS Lambda->DynamoDb flow.
We will test only POST endpoint which will save the book into the DynamoDb table in the known AWS region(us-east-2).
For the warm state, I sent 15k requests for each lambda one by one(lambda concurrency is 1, all request go to the same lambda instance).
And on the screens, you can see the duration of the last requests, which means all JIT/optimization should be done.
DotNet: ARM is a bit faster
Golang: ARM and x86 are almost the same
GraalVM: x86 is a bit faster
NodeJS: ARM is a bit faster
Python: ARM is faster
Ruby: almost the same performance
Rust ARM is faster
Java: almost the same performance
All Runtime together
To move your Lambda to ARM runtime you just need to add a new field in CF/SAM script.
- For Golang we have to use a custom runtime and compile for the ARM64 target
- For Rust, it was quite difficult to compile for ARM processor. The only working solution was https://github.com/rust-embedded/cross
For this particular test for all runtimes (except GraalVM) we see that ARM/Graviton2 processor is faster and 20% cheaper than x86.
Since the development effort is minimal (except Rust and Goland) I would recommend migrating to ARM setup as fast as possible.