Skip to main content

How to Checkpoint an Atoti application

First, if you want to be able to snapshot your application, you must provide the path of the generated checkpoint when you launch your Java application with the following VM argument:

java -XX:CRaCCheckpointTo=/path/to/crac/image -jar myApp.jar

Generate a checkpoint, whether:

  • manually from outside the application with the following command: jcmd <myApp.jar/PID> JDK.checkpoint
    The execution of this command ends quickly but your application is still paused while its state is being copied to the disk.

  • automatically after Spring initialization but right before the application is started by adding this system property while launching your application: -Dspring.context.checkpoint=onRefresh
    It is not recommended as manual checkpoints usually provide better performance, as explained in the official documentation.

  • or programmatically within your application with the CRaC API: org.crac.Core.checkpointRestore()
    This method triggers a checkpoint and returns when the restore is completed.

warning

Do not try to manually close the application during the checkpoint process.

If you need the CRaC API, you must import the dependency in your project with Maven:

<dependency>
<groupId>org.crac</groupId>
<artifactId>crac</artifactId>
<version>${crac.version}</version>
</dependency>

The version is defined by Spring Boot.

See the official guide to running CRaC in Docker.