Reducing Java Startup Time: 4 Approaches

Transcript

Application Class Data Sharing (AppCDS)

Do you want to reduce the startup and warm-up time of your Java applications from minutes to milliseconds? In this video, we will explore four approaches to making your Java services start up faster or even almost instantly. Any application uses classes for its work, and all these application classes and core JVM classes must be loaded and initialized at application start. But this process repeats with every startup. So the idea behind application class data sharing for apps is ideas. Is to avoid repeating this process every time the application starts, but to load a set of system classes and application classes once and store this data in an archive. This archive is then used as a read-only metadata by the JVM. Reading the archive is faster than loading the classes from scratch, so the startup is faster. In addition, multiple JVM processes can use the same archive. With AppCDS, you can achieve about 40% better startup. If you use Spring Boot, you can enable ahead-of-time processing, and the application startup will be faster by more than 50%. The key advantage of AppCDS is that it enables tangible startup improvement without the need for code refactoring. Project Leyden is an open JDK project under development.

Project Leyden

The project is focused on shifting some commutations and optimizations from run time to some earlier stages, for instance, training runs. Then the application will use pre-compiled code and classes during the production run, and so the startup will be faster. Project Leyden uses apps CDS, ahead-of-time compilation and other techniques of shifting computations that will enable a reuse of transformed code without breaking the compatibility with the Java platform specification. But Java is a very dynamic language. It won't allow shifting computations randomly. So the project team will work towards introducing permitted constraints to the Java platform specification. They will be weaker than closed world constraints, where more applications and can use them. The goal is to introduce full closed world constraint in the future. Early access bills of project laden are already available. I have tried them out with a Springwood application and got three times faster startup. So we are looking towards production ready builds. Graal VM native image is the technology that uses ahead-of-time compilation to perform static analysis and convert Java code into machine code at build time. As a result, a Java app is turned into a fully compiled native executable. A single executable contains pre-initialized necessary application classes, required library classes, and statically linked code from the JDK

GraalVM Native Image

The key advantages of Graal VM native image are very rapid startup in one second or less, and immediate peak performance without warmup. One consideration when using Graal VM native image, you have to provide a metadata about all cases of dynamic features used in your application in a special config file, or else the native executable may behave unexpectedly or crash during the production run. Coordinated Restore Checkpoint, or CRaC for short, is an open JDK project. It enables you to create an image of a running and warmed up Java service, save it to the file.

Coordinated Restore at Checkpoint (CRaC)

Replicate this file among cloud instances and then restore the application from the file from the moment it was posted, like a video game. This way, the application starts in several milliseconds and at peak performance. And the JIT Compiler is still there, so dynamic performance optimizations are still possible. Some considerations when using crack. The technology preserves almost the exact state of a Java application, so the snapshot may contain sensitive data. Also, CRaC is a novel technology, and it is not subject to TCK testing yet. I encourage you to try all these solutions with your application and see which fits best.

You can find links to the relevant guides in the description box below

Summary

Java application startup can be significantly accelerated using modern tools. AppCDS stores preloaded classes in a shared archive, cutting startup time by up to 50%, while Project Leyden shifts optimizations to earlier stages with ahead-of-time compilation. GraalVM Native Image creates standalone executables for sub-second startup, and CRaC restores pre-warmed application states for instant readiness. These technologies offer versatile solutions to improve efficiency and performance.

About Catherine

Java developer passionate about Spring Boot. Writer. Developer Advocate at BellSoft

Social Media

Videos
card image
Apr 16, 2025
Spring Boot Buildpacks: Optimize, Secure, and Shrink Your Containers!

Buildpacks let you containerize Spring Boot apps without writing Dockerfiles, but the default settings aren’t always optimal. In this video, I’ll show you how to fine-tune buildpacks for faster startup, smaller images, and better security—so you get the best performance with minimal effort.

Videos
card image
Apr 1, 2025
SBOMs & Java Security: Stay Compliant, Stay Protected!

A software bill of materials or SBOM is crucial for the modern development environment full of regulations, vulnerabilities, and hidden threats. In this video, we discuss what SBOMs are and how they help dealing with compliance audits and application security. We will explore the best open-source tools for generating SBOMs and provide a tutorial on creating an SBOM for your project and analyzing it for vulnerabilities.

Further watching

Videos
card image
Nov 29, 2024
OpenJDK Projects That We Anticipate

OpenJDK is actively evolving, with projects like Leyden, Valhalla, Babylon, and Lilliput aiming to enhance Java's performance and capabilities. Leyden focuses on faster startup and warmup by reusing precompiled code, while Valhalla introduces value objects, primitive classes, and specialized generics for better memory and runtime efficiency.

Videos
card image
Jun 23, 2025
How to install Liberica Native Image Kit on Windows PC

Liberica Native Image Kit is a multilingual GraalVM-based set of utilities for creating native images. This guide will help you to install it on Windows PC.

Videos
card image
Apr 25, 2025
Java in 2025: Busting the Biggest Myths

Think Java is slow, outdated, or only for old-school enterprise apps? Think again. In this episode of Java Myth Busters, we debunk six common myths about Java, including performance issues, security concerns, and the myth that Java is dead. Discover how the JVM, Spring Boot, GraalVM, and modern JDK updates make Java one of the most powerful, scalable, and relevant languages in 2025.