Backend Development 8 min read

Accelerate Spring Boot 3.2 Startup with CRaC: Automatic & Manual Checkpoints

This article demonstrates how Spring Boot 3.2 leverages the OpenJDK CRaC project to dramatically cut application startup time, covering required JVM, dependencies, Zulu JDK setup, automatic and manual checkpoint creation, performance benchmarks, and restoration steps, all using the Petclinic example.

Java Architecture Diary
Java Architecture Diary
Java Architecture Diary
Accelerate Spring Boot 3.2 Startup with CRaC: Automatic & Manual Checkpoints

1. Introduction

Spring 6.1 and Spring Boot 3.2 have been released and both fully support CRaC (Coordinated Restore at Checkpoint).

CRaC, an OpenJDK project, can snapshot a running JVM (including the application) to disk and later restore it, enabling millisecond‑level startup by reusing a pre‑warmed state.

To test Spring Boot 3.2’s CRaC support, the Spring Boot Petclinic sample is used.

2. Dependencies

Using CRaC in Spring Boot 3.2 requires three conditions:

CRaC‑compatible JVM

org.crac JAR dependency

A folder to store checkpoint files

2.1 Install Zulu JDK

The required JDK is Azul Zulu 21.0.1 + CRaC . Download from Azul . CRaC is currently only available on Linux.

Set permissions for CRIU on Linux:

<code>sudo chown root:root $JAVA_HOME/lib/criu
sudo chmod u+s $JAVA_HOME/lib/criu</code>

2.2 Add JAR dependency

Clone the Petclinic source and add the

org.crac:crac:1.4.0

dependency in Maven:

<code><dependency>
  <groupId>org.crac</groupId>
  <artifactId>crac</artifactId>
  <version>1.4.0</version>
</dependency></code>

3. Baseline Test

Testing on JDK 17 and JDK 21 shows that simply moving to JDK 21 reduces Petclinic startup time by about 500 ms.

Run the application:

<code>java -jar spring-petclinic-3.2.0.jar</code>

Startup time statistics:

3.1 Automatic Checkpoint with CRaC

Enable automatic checkpoint by adding the JVM system property

-Dspring.context.checkpoint=onRefresh

. During the

LifecycleProcessor.onRefresh

phase, a checkpoint is created after all non‑lazy singletons are instantiated but before the

ContextRefreshedEvent

is published.

<code>java -Dspring.context.checkpoint=onRefresh -XX:CRaCCheckpointTo=./tmp_checkpoint -jar spring-petclinic-3.2.0.jar</code>

The application creates a checkpoint in

./tmp_checkpoint

and exits.

Restore from the checkpoint:

<code>java -XX:CRaCRestoreFrom=./tmp_checkpoint</code>

Resulting startup time (from checkpoint) is an order of magnitude faster:

3.2 Manual Checkpoint

Manual checkpoints can be created at any desired moment, offering even faster restarts.

Steps:

Start the application without checkpointing:

<code>java -XX:CRaCCheckpointTo=./tmp_checkpoint -jar spring-petclinic-3.2.0.jar</code>

When the app is fully started, trigger a checkpoint from another shell:

<code>jcmd spring-petclinic-3.2.0.jar JDK.checkpoint</code>

A checkpoint file appears in

./tmp_checkpoint

and the app shuts down.

Restore the same way as the automatic case:

<code>java -XX:CRaCRestoreFrom=./tmp_checkpoint</code>

This manual checkpoint includes both framework and application code, yielding even quicker startups:

4. Special Notes

Spring Boot 3.2 fully supports CRaC without any code changes; the framework handles resource closing before the checkpoint and reopening after restore.

For other frameworks you must implement the CRaC Resource interface, closing resources in

beforeCheckpoint()

and reopening them in

afterRestore()

.

5. Conclusion

Using CRaC can dramatically reduce Spring Boot 3.2 application startup time, often by an order of magnitude, without modifying source code. Automatic checkpoints provide a simple way to achieve this, while manual checkpoints can deliver even faster restarts. Compared with GraalVM Native Image, CRaC runs on a standard JVM and allows further optimizations after restoration.

JavaperformanceSpring BootCheckpointCRaC
Java Architecture Diary
Written by

Java Architecture Diary

Committed to sharing original, high‑quality technical articles; no fluff or promotional content.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.