AWS Lambda Architectures with .NET 6: X86 or ARM (Graviton)

AWS Lambda Architectures with .NET 6: X86 or ARM (Graviton)

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:

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.

MemoryvCPUs
128-1769 MB1
1770-3538 MB2
3539-5307 MB3
5308-7076 MB4
7077-8845 MB5
8846-10240 MB6

Let's see the results of the Pi calculation endpoint:

512 MB1024 MB2048 MB4096 MB6144 MB8192 MB
ARM420 ms383 ms356 ms366 ms358 ms350 ms
X86385 ms367 ms345 ms350 ms351 ms351 ms

And the results of the encryption endpoint:

512 MB1024 MB2048 MB4096 MB6144 MB8192 MB
ARM443 ms358 ms360 ms349 ms350 ms326 ms
X86397 ms370 ms347 ms329 ms341 ms331 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.