search
HomeJavajavaTutorialAWS Lambda performance with Java xvs arm- Part nitial measurements

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  
   ...

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   

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
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
JVM performance vs other languagesJVM performance vs other languagesMay 14, 2025 am 12:16 AM

JVM'sperformanceiscompetitivewithotherruntimes,offeringabalanceofspeed,safety,andproductivity.1)JVMusesJITcompilationfordynamicoptimizations.2)C offersnativeperformancebutlacksJVM'ssafetyfeatures.3)Pythonisslowerbuteasiertouse.4)JavaScript'sJITisles

Java Platform Independence: Examples of useJava Platform Independence: Examples of useMay 14, 2025 am 12:14 AM

JavaachievesplatformindependencethroughtheJavaVirtualMachine(JVM),allowingcodetorunonanyplatformwithaJVM.1)Codeiscompiledintobytecode,notmachine-specificcode.2)BytecodeisinterpretedbytheJVM,enablingcross-platformexecution.3)Developersshouldtestacross

JVM Architecture: A Deep Dive into the Java Virtual MachineJVM Architecture: A Deep Dive into the Java Virtual MachineMay 14, 2025 am 12:12 AM

TheJVMisanabstractcomputingmachinecrucialforrunningJavaprogramsduetoitsplatform-independentarchitecture.Itincludes:1)ClassLoaderforloadingclasses,2)RuntimeDataAreafordatastorage,3)ExecutionEnginewithInterpreter,JITCompiler,andGarbageCollectorforbytec

JVM: Is JVM related to the OS?JVM: Is JVM related to the OS?May 14, 2025 am 12:11 AM

JVMhasacloserelationshipwiththeOSasittranslatesJavabytecodeintomachine-specificinstructions,managesmemory,andhandlesgarbagecollection.ThisrelationshipallowsJavatorunonvariousOSenvironments,butitalsopresentschallengeslikedifferentJVMbehaviorsandOS-spe

Java: Write Once, Run Anywhere (WORA) - A Deep Dive into Platform IndependenceJava: Write Once, Run Anywhere (WORA) - A Deep Dive into Platform IndependenceMay 14, 2025 am 12:05 AM

Java implementation "write once, run everywhere" is compiled into bytecode and run on a Java virtual machine (JVM). 1) Write Java code and compile it into bytecode. 2) Bytecode runs on any platform with JVM installed. 3) Use Java native interface (JNI) to handle platform-specific functions. Despite challenges such as JVM consistency and the use of platform-specific libraries, WORA greatly improves development efficiency and deployment flexibility.

Java Platform Independence: Compatibility with different OSJava Platform Independence: Compatibility with different OSMay 13, 2025 am 12:11 AM

JavaachievesplatformindependencethroughtheJavaVirtualMachine(JVM),allowingcodetorunondifferentoperatingsystemswithoutmodification.TheJVMcompilesJavacodeintoplatform-independentbytecode,whichittheninterpretsandexecutesonthespecificOS,abstractingawayOS

What features make java still powerfulWhat features make java still powerfulMay 13, 2025 am 12:05 AM

Javaispowerfulduetoitsplatformindependence,object-orientednature,richstandardlibrary,performancecapabilities,andstrongsecurityfeatures.1)PlatformindependenceallowsapplicationstorunonanydevicesupportingJava.2)Object-orientedprogrammingpromotesmodulara

Top Java Features: A Comprehensive Guide for DevelopersTop Java Features: A Comprehensive Guide for DevelopersMay 13, 2025 am 12:04 AM

The top Java functions include: 1) object-oriented programming, supporting polymorphism, improving code flexibility and maintainability; 2) exception handling mechanism, improving code robustness through try-catch-finally blocks; 3) garbage collection, simplifying memory management; 4) generics, enhancing type safety; 5) ambda expressions and functional programming to make the code more concise and expressive; 6) rich standard libraries, providing optimized data structures and algorithms.

See all articles

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

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.