|AWS Lambda Adopts Java 17|
|Written by Nikos Vaggalis|
|Monday, 15 May 2023|
AWS Lambda functions can now use all the new and useful language features as well as performance improvements introduced in Java 17 as part of the Amazon Corretto JDK implementation.
The Corretto 17 build was available from September 2022, but the support for it by Lambda functions wasn't until this April, 2023. Till now the highest Java version that Lambdas could run on was 11. Consider that Corretto 11 wasn't supported by Lambda until after 8 months of its release, thus Lambdas are a little slow to pick up the latest changes.
Corretto includes patches from Amazon that have proven useful in running their own services, but other than that it is at par with the rest of OpenJDK distros (TCK tested) and therefore can be used interchangeably. These patches include security fixes, performance enhancements, garbage collection scheduling, preventing out-of-memory situations, as well as improved monitoring, reporting, and thread management. What is important here is that Amazon upstreams its patches to OpenJDK, thus benefiting the whole OpenJDK league. This means the language features and performance gains that come with version 17 are now usable on Lambda too. These include:
Runtime JVM configuration changes
That aside, the 17 runtime also supports AWS Lambda SnapStart, which is a service that solves the problem of function inisialitzation, as described in AWS Lambda Updated With SnapStart:
For a Lambda function to be initialized , it involves downloading the function’s code, starting the runtime and any external dependencies, and running the function’s initialization code. Ordinarily, for a Lambda function, this initialization happens every time your application scales up to create a new execution environment.
With SnapStart, the function’s initialization is done ahead of time when you publish a function version. Lambda takes a Firecracker microVM snapshot of the memory and disk state of the initialized execution environment, encrypts the snapshot, and caches it for low-latency access. When your application starts up and scales to handle traffic, Lambda resumes new execution environments from the cached snapshot instead of initializing them from scratch, improving startup performance.
Generally upgrading to Java 17 is recommended because it is faster than 8 or 11. Framework developers want to pass on the performance improvements to customers, as well as wanting to use the improvements of the Java language in their code.
It's interesting to know that there was also an Amazon Corretto 18 release back in March 2022 which has been abolished in favor of 17 because 19 wasn't LTS, and now can't even be found on the official Corretto repo. Still you can find the official announcement here.
So in the end why go for Amazon's build of the JDK and not opt for one of the many chocies available nowdays?
The main difference is that the various distros:
may contain backported fixes and enhancements we deem important to our customers and our internal users, which may have not yet been formally backported upstream
As such the Microsoft build of OpenJDK is recommended when running Java applications on Azure. Red Hat is the OpenJDK to choose if you're on Red Hat Enterprise Linux, while there's Liberica JDK which is the runtime of choice by VMware for Spring Boot and Spring Native. There's also the vastly popular Adoptium and Azul Zulu.
So given that guideline, stick to Corretto if you run Java applications on Amazon Linux 2 in AWS.
AWS Lambda now supports Java 17
Amazon Corretto 18 is now generally available
AWS Lambda Updated With SnapStart
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
or email your comment to: email@example.com
|Last Updated ( Monday, 15 May 2023 )|