An AWS Lambda function that uses the .NET 6 runtime can run on two architectures:
arm64
- 64-bit ARM architecture using AWS Graviton2 processors.x86_64
- 64-bit x86 architecture using standard x86 processors.
When choosing between x86 and ARM for AWS Lambda, performance, cost, and compatibility should be considered crucial factors in making a decision. Regarding compatibility, if we use .NET 6, our code is likely to be compatible with both x86 and ARM architectures. About performance and cost, the article AWS Lambda Functions Powered by AWS Graviton2 Processor – Run Your Functions on Arm and Get Up to 34% Better Price Performance, states the following:
First, your functions run more efficiently due to the Graviton2 architecture. Second, you pay less for the time that they run. In fact, Lambda functions powered by Graviton2 are designed to deliver up to 19 percent better performance at 20 percent lower cost.
The cost can be easily checked in the AWS official documentation. Today, we can say that the ARM architecture is approximately 20% to 25% cheaper than the x86 architecture. Regarding performance, we executed two different Lambda functions:
Pi calculation using the Leibniz series.
RSA encryption of 50 random strings in parallel.
All source code is here.
Under different memory configurations (from 512 MB to 8192 MB), during 5 minutes each time. It should be noted that the first Lambda function is designed to operate with only one vCPU, while the second one can utilize more than one vCPU. About vCPU, the documentation states:
At 1,769 MB, a function has the equivalent of one vCPU (one vCPU-second of credits per second).
The following table illustrates the number of vCPUs according to memory usage.
Memory | vCPUs |
128-1769 MB | 1 |
1770-3538 MB | 2 |
3539-5307 MB | 3 |
5308-7076 MB | 4 |
7077-8845 MB | 5 |
8846-10240 MB | 6 |
Let's see the results of the Pi calculation endpoint:
512 MB | 1024 MB | 2048 MB | 4096 MB | 6144 MB | 8192 MB | |
ARM | 420 ms | 383 ms | 356 ms | 366 ms | 358 ms | 350 ms |
X86 | 385 ms | 367 ms | 345 ms | 350 ms | 351 ms | 351 ms |
And the results of the encryption endpoint:
512 MB | 1024 MB | 2048 MB | 4096 MB | 6144 MB | 8192 MB | |
ARM | 443 ms | 358 ms | 360 ms | 349 ms | 350 ms | 326 ms |
X86 | 397 ms | 370 ms | 347 ms | 329 ms | 341 ms | 331 ms |
The graph below provides a summary of the results:
As we can see, the difference in performance is minimal, with perhaps a slight advantage for the X86 architecture, especially at lower levels of memory. In summary, running Lambda functions on ARM can provide significant cost savings, but the performance differences between the two architectures are minimal. To make the best choice, evaluate your specific workloads on both architectures to determine the optimal option. Thanks, and happy coding.