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) 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 InformationRelated ArticlesAWS 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.
Comments
or email your comment to: comments@i-programmer.info |
Last Updated ( Monday, 11 December 2023 ) |