Home Java javaTutorial AWS Lambda performance with Java xvs arm- Part nitial measurements

AWS Lambda performance with Java xvs arm- Part nitial measurements

Jul 29, 2024 pm 05:59 PM

AWS Lambda performance with Java  xvs arm- Part nitial measurements

Introduction

Until now I haven't measured the performance (warm and cold start times) of the Lambda functions using Java 21 runtime for some use cases (like making DynamoDB request) for arm64 architecture because it hasn't supported SnapStart. Lambda with Java 21 runtime with x86_64 architecture with SnapStart enabled will outperform (even more so with additional priming optimization) Lambda with with arm64 architecture. But on July 18, 2024, AWS announced that AWS Lambda now supports SnapStart for Java functions that use the ARM64 architecture. So now it made sense for me to start measuring the cold and warm start times also considering the choice of the architecture of the Lambda function. It's known that with the current AWS Lambda pricing memory setting and execution duration, Lambda with arm64 architecture will be approx. 25% cheaper than Lambda with x86_64 architecture.

I decided to create the separate article series for it and not to add this topic to my ever growing AWS Lambda SnapStart series.

Measuring the cold and warm starts for the example application

In our experiment we'll re-use the application introduced in article AWS Lambda SnapStart - Measuring Java 21 Lambda cold starts. Here is the code for the sample application. There are basically 2 main Lambda functions which both respond to the API Gateway requests to create the product with the given id (see PutProductFunction Lambda function) and retrieve the product by the given id (see GetProductByIdFunction Lambda function). You can use both Lambda functions with and without SnapStart enabled. There is an additional Lambda function GetProductByIdWithPrimingFunction which I wrote to independently measure the effect of DynamoDB request priming for the SnapStart enabled Lambda function. You can read more about the effect of priming in my article AWS Lambda SnapStart - Measuring priming, end to end latency and deployment time .

To enable SnapStart on all Lambda functions please uncomment the following in the SAM template :

Globals:
  Function:
    CodeUri: target/aws-pure-lambda-snap-start-21-1.0.0-SNAPSHOT.jar
    ...
    SnapStart:
     ApplyOn: PublishedVersions  
   ...
Copy after login

If I'd like to use SnapStart only for the individual, but not all Lambda functions you have to apply this SnapStart definition on the Lambda function level instead of the global function level.

All Lambda functions have the following settings as the starting point:

  • 1024 MB memory setting
  • Default HTTP Apache client used to talk to the DynamoDB database
  • Java compilation option "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" which proved to provide very good trade off between the cold and warm start times

In the SAM template I added the possibility to define the Lambda architecture in the global Lambda function section like:

Globals:
  Function:
    CodeUri: target/aws-pure-lambda-snap-start-21-1.0.0-SNAPSHOT.jar
    ...
    Architectures:
      #- arm64
      - x86_64   
Copy after login

Just uncomment the architecture you'd like to use for your Lambda functions.

Even if Java is "write once, run everywhere", I anyway compiled and built the application jar file for my arm64 measurements on the t4g AWS EC2 instance with Graviton processor (which is based on arm64/aarch64 architecture) by previously installing Amazon Corretto 21 for Linux aarch64. You can find this jar here.

I've also re-measured everything for x86_64 architecture once again to have the comparable results using the same Corretto Java 21 latest runtime version which at the time of my measurements was Java 21.v17 .

The results of the experiment below were based on reproducing more than 100 cold and approximately 100.000 warm starts. For it (and experiments from my previous article) I used the load test tool hey, but you can use whatever tool you want, like Serverless-artillery or Postman. It's also important to be aware that I started the measurements right after the fresh source code (re-) deployment of the application. Please note that there is also Impact of the snapshot tiered cache on the cold starts , where the first invocations are generally slower, and subsequent ones become quicker until certain number of invocations is reached.

Now lets put all measurements for "get product by existing id" (Lambda functions GetProductByIdFunction and GetProductByIdWithPrimingFunction for SnapStart enabled and priming measurements) case together.

Cold (c) and warm (m) start time in ms:

Approach c p50 c p75 c p90 c p99 c p99.9 c max w p50 w p75 w p90 w p99 w p99.9 w max
x86_64, no SnapStart enabled 3554.30 3615.21 3666.15 3800.47 4108.61 4111.78 5.42 6.01 6.88 14.09 40.98 1654.59
arm64, no SnapStart enabled 3834.81 3904.42 3983.26 4047.47 4332.13 4335.74 5.96 6.66 7.69 16.01 43.68 1844.54
x86_64, SnapStart enabled without priming 1794.09 1846.86 2090.54 2204.27 2239.80 2240.08 5.37 5.96 6.93 15.88 51.64 1578.34
arm64, SnapStart enabled without priming 1845.01 1953.18 2591.70 2762.91 2793.45 2795.8 5.91 6.56 7.63 16.75 63.52 1779.14
x86_64, SnapStart enabled with DynamoDB request priming 803.18 870.18 1103.78 1258.19 1439.95 1440.67 5.55 6.25 7.45 15.50 63.52 448.85
arm64, SnapStart enabled with DynamoDB request priming 910.14 1001.79 1376.62 1623.44 1684.60 1686.19 6.05 6.72 7.81 16.66 74.68 550.59

Conclusion

In this article we compared measurements of the cold and warm start times of the Lambda function connecting to DynamoDB database for 3 use cases:

  • without SnapStart enabled on the Lambda function
  • with SnapStart enabled on the Lambda function but without priming optimization
  • with SnapStart enabled on the Lambda function and with priming of the DynamoDB request

We saw that by using the x86_64 architecture all cold and warm start times were lower comparing to arm64 architecture. But as arm64 architecture Lambda pricing is 25% cheaper than x86_64 architecture , it introduces very interesting cost-performance trade off.

For our measurements, for all 3 use cases:

  • Lambda cold start times with arm64 architecture were for many percentiles only 10-20% (and only in very rare cases 25-27%) slower compared to x86_64 architecture.
  • Lambda warm start times with arm64 architecture were for many percentiles only 5-10% slower compared to x86_64 architecture.

So, the choice of arm64 architecture is quite reasonable for this sample application. As SnapStart support for arm64 architecture has only been introduced recently, I also expect some performance improvements in the future. Please do your own measurements for your use case!

In the next part of the article we'll do the same performance measurements but setting the Lambda memory to different values between 256 and 2048 MBs and compare the results.

The above is the detailed content of AWS Lambda performance with Java xvs arm- Part nitial measurements. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1668
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Apr 19, 2025 pm 04:51 PM

Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

How do I convert names to numbers to implement sorting and maintain consistency in groups? How do I convert names to numbers to implement sorting and maintain consistency in groups? Apr 19, 2025 pm 11:30 PM

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

How to simplify field mapping issues in system docking using MapStruct? How to simplify field mapping issues in system docking using MapStruct? Apr 19, 2025 pm 06:21 PM

Field mapping processing in system docking often encounters a difficult problem when performing system docking: how to effectively map the interface fields of system A...

How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? Apr 19, 2025 pm 11:45 PM

Start Spring using IntelliJIDEAUltimate version...

How to elegantly obtain entity class variable names to build database query conditions? How to elegantly obtain entity class variable names to build database query conditions? Apr 19, 2025 pm 11:42 PM

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

How to safely convert Java objects to arrays? How to safely convert Java objects to arrays? Apr 19, 2025 pm 11:33 PM

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products? E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products? Apr 19, 2025 pm 11:27 PM

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

How to use the Redis cache solution to efficiently realize the requirements of product ranking list? How to use the Redis cache solution to efficiently realize the requirements of product ranking list? Apr 19, 2025 pm 11:36 PM

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

See all articles