Backend Development 9 min read

Understanding CRaC: Fast JVM Startup with Checkpoint/Restore

This article explains the CRaC (Coordinated Restore at Checkpoint) technology for Java applications, describing its principles, supported environments, practical steps for enabling it with Spring Boot, and use‑case scenarios that dramatically reduce JVM startup time.

Code Ape Tech Column
Code Ape Tech Column
Code Ape Tech Column
Understanding CRaC: Fast JVM Startup with Checkpoint/Restore

During Java application development and runtime, long startup and warm‑up times are a common pain point. While AOT can help, the CRaC (Coordinated Restore at Checkpoint) project provides a new way to accelerate startup by snapshotting a running JVM and restoring it later.

What is CRaC?

CRaC is an OpenJDK project that allows taking a snapshot of a running JVM—including the application state—and storing it on disk. When needed, the JVM can be restored from this checkpoint, skipping the full startup and warm‑up phases.

How CRaC Works

CRaC builds on the user‑space checkpoint/restore tool CRIU, which freezes containers or processes on Linux. The typical workflow consists of three steps:

Create checkpoint : Capture the JVM and application state when the app reaches a stable point.

Store checkpoint : Persist the snapshot to disk.

Restore checkpoint : Load the snapshot to start the application instantly.

Application Scenarios

Cloud‑native environments : Reduce start‑up latency for micro‑services and serverless functions.

Development and testing : Quickly revert to a known state, improving developer productivity.

Disaster recovery : Restore services from the latest checkpoint to minimize downtime.

Supported Versions

CRaC is supported from Spring Boot 3.2 / Spring Framework 6.1 onward, but it relies on Linux‑specific CRIU, so it currently works only on Linux.

Practical Guide

Install a CRaC‑compatible JDK

Two main options are:

Azul Zulu 21.0.1 + CRaC (supports x64 and aarch64, JDK 17 & 21).

Liberica JDK 17 and 21 with CRaC support.

Add CRaC Dependency

In pom.xml add:

<dependency>
  <groupId>org.crac</groupId>
  <artifactId>crac</artifactId>
  <version>1.5.0</version>
</dependency>

Specify Checkpoint Location and Timing

Two approaches are available:

Automatic checkpoint

Start the app with:

java -Dspring.context.checkpoint=onRefresh -XX:CRaCCheckpointTo=./tmp_checkpoint -jar javaboy-crac-3.3.5.jar

This enables a checkpoint at the Spring LifecycleProcessor.onRefresh stage, after all non‑lazy singletons are instantiated but before the ContextRefreshedEvent .

Manual checkpoint

First start the app normally:

java -XX:CRaCCheckpointTo=./tmp_checkpoint -jar javaboy-crac-3.3.5.jar

After the app is fully started, trigger a checkpoint from another terminal:

jcmd <pid> JDK.checkpoint

This creates a checkpoint that includes both framework and application code, offering the fastest possible restart.

Restore from Checkpoint

Regardless of how the checkpoint was created, launch the app quickly with:

java -XX:CRaCRestoreFrom=./tmp_checkpoint

In summary, automatic checkpoints are easy to adopt with no code changes, while manual checkpoints provide greater flexibility for achieving the shortest start‑up time.

Additional Resources

Internet giant stability Top10

Hangzhou top‑25 internet company benefits

SpringBoot + ResponseBodyEmitter streaming

For community discussion, join the backend‑focused technical group and share recruitment or referral information.

JavaJVMstartup optimizationLinuxSpring BootCRaC
Code Ape Tech Column
Written by

Code Ape Tech Column

Former Ant Group P8 engineer, pure technologist, sharing full‑stack Java, job interview and career advice through a column. Site: java-family.cn

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.