Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Step up the performance game with Spring Boot a...

Step up the performance game with Spring Boot and Project Leyden

Spring Boot includes support for CDS for improved memory efficiency and startup speed. With Project Leyden the Java Platform team at Oracle collaborates with the Spring team to deliver even more impressive performance gains. In this talk, we’ll take a look at Project Leyden, how it works and how you can leverage it today with JDK 24 to gain performance benefits and reduce the hosting costs of your applications.

Avatar for Moritz Halbritter

Moritz Halbritter

May 26, 2025
Tweet

More Decks by Moritz Halbritter

Other Decks in Programming

Transcript

  1. We’re going to take a look at 3 variants CDS

    AOT Cache AOT Cache with profiling and code compilation
  2. Workflow Training run Cache Deployment run Startup Fast startup even

    on cheap servers or scale to zero Memory More applications on less servers Warmup Peak performance immediately
  3. java -Dspring.context.exit=onRefresh Start Exit on Refresh non-lazy singletons instantiated afterPropertiesSet

    invoked Lifecycle start invoked ContextRefreshedEvent published Running
  4. Self-extracting executable JARs my-app.jar 35 MB java -Djarmode=tools -jar my-app.jar

    extract my-app/ lib/ my-app.jar 0.7 MB Library jars as files for optimized class loading Application classes + manifest file defining the classpath java -jar my-app/my-app.jar
  5. CDS requirements JVM The same JVM must be used. Classpath

    Must be specified as a list of jars. No directories, no wildcard, no nested jars. Deployment classpath must be a superset of the training one. Files The timestamps of the jars must be preserved. Training run When/how to do the training run? Application may try to connect to remote services like databases.
  6. CDS support in Buildpacks Spring Boot Buildpacks + mvn spring-boot:build-image

    gradle bootBuildImage = The CDS training run is performed transparently when building the container image, ensuring that the same JVM is used
  7. AOT Cache and Spring AOT are different - but combine

    well AOT Cache JVM feature developed via Project Leyden to improve the efficiency of the JVM. It supersedes CDS. Spring AOT Spring feature mandatory for GraalVM native images support. Can also be used on the JVM to speed up the startup process and lower the memory consumption. Precomputes the bean arrangement for specific Spring profiles [1]. [1] https://github.com/sdeleuze/demo-profile-aot