AWS Lambda Adopts Java 21
Written by Nikos Vaggalis   
Monday, 27 November 2023

AWS Lambda functions can now use all the new and useful language features as well as performance improvements introduced in Java 21 as part of the Amazon Corretto JDK implementation.

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 21 are now usable on Lambda too. These include:

430: String Templates (Preview)
431: Sequenced Collections
439: Generational ZGC
440: Record Patterns
441: Pattern Matching for switch
442: Foreign Function & Memory API (Third Preview)
443: Unnamed Patterns and Variables (Preview)
444: Virtual Threads
445: Unnamed Classes and Instance Main Methods (Preview)
446: Scoped Values (Preview)
448: Vector API (Sixth Incubator)
449: Deprecate the Windows 32-bit x86 Port for Removal
451: Prepare to Disallow the Dynamic Loading of Agents
452: Key Encapsulation Mechanism API
453: Structured Concurrency (Preview)

As we examined in "Java 21 Now Feature Complete", one highlight of the new version is Jep 444 which brings full support for virtual threads, which are lightweight threads that significantly reduce the effort of writing, maintaining, and observing high-throughput concurrent applications.

The aim of the developers in adding virtual thread support was to enable server applications written in the simple thread-per-request style to scale with near-optimal hardware utilization. Since they were introduced in JDK 19, virtual threads have been changed so they always support thread-local variables.

A preview has also been included of string templates. These complement Java's existing string literals and text blocks by coupling literal text with embedded expressions and template processors to produce specialized results.

Other improvements include support for sequenced collections with a defined encounter order;and a preview of support for unnamed patterns, which match a record component without stating the component's name or type, and unnamed variables, which can be initialized but not used.

That aside, you can use the full range of AWS deployment tools, including the Lambda console, AWS CLI, AWS Serverless Application Model (AWS SAM), CDK, and AWS CloudFormation to deploy and manage serverless applications written in Java 21.

You can get hold of the AWS certified container images for Java which are regularly updated with security patches and other updates and come optimized by changing the components or dependencies included in them. And of course those images come with SnapStart support:

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

What will have the greatest impact though is the use of Virtual Threads, something that will maximize Lambda's performance.

 

More Information

Official Anouncement

Related Articles

Java 21 Now Feature Complete

AWS Lambda Updated With SnapStart

AWS Lambda Adopts Python 3.11 

 

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.

Banner


The Advent of SQL 2024 Has Commenced
11/12/2024

It's Advent - the time of year when we countdown the days to Christmas - and if your are a programmer complete daily coding challenges with the Advent of Code, the Advent of Perl, the Advent of Java,  [ ... ]



Windows 11 Adoption Takes A Downturn
11/12/2024

With Windows 10 End of Life only ten months away, Microsoft is stepping up its campaign to get Windows users to upgrade to Windows 11. But while Windows 11 had been gaining users at a steady rate at t [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Monday, 11 December 2023 )