Skip to content

soujava/spring-with-crac

Repository files navigation

Exploring Spring Boot with CraC

Setup the environment

Installing a JDK with support for CRaC:

Download and install the JDK with CRaC support

  1. Download the JDK with CRaC support from Azul Zulu website:

  2. Unpack the tar.gz file and copy the JDK in a folder

    sudo tar zxvf zulu22.30.13-ca-crac-jdk22.0.1-linux_x64.tar.gz
  3. Move to the folder where the JDK installation will be located

    mv zulu22.30.13-ca-crac-jdk22.0.1-linux_x64 zulu-22.jdk
    mv zulu-22.jdk /usr/lib/jvm
  4. Set the $JAVA_HOME environment variable to the JDK with CRaC support e.g.

    export JAVA_HOME=/usr/lib/jvm/zulu-22.jdk

install the JDK with CRaC support via SDKMAN

  • Install a JDK with CRaC support via SDKMAN:

    sdk install java 22.0.1.crac-zulu

Grant permissions to run CRIU

  1. Make sure you have the permissions to run CRIU:

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

Build the application

  1. Open the project folder and run:

    ./mvnw verify
  2. Now you should find the spring-with-crac-0.0.1-SNAPSHOT.jar jar at target/ directory

  3. Create a folder named tmp_manual_checkpoint in the project folder (besides the src folder)

Start and initialize the MySQL database+

sh create-manual-checkpoint.sh <target/spring-with-crac-0.0.1-SNAPSHOT.jar or PID>
  1. Start the MySQL database using Docker Compose

    docker compose up -d

Start the application without any CRaC

  1. Start the application normally

    ./mvnw spring-boot:run
Note

A checkpoint can also be compressed (only in Azul Zulu) on the hard drive by executing:

export CRAC_CRIU_OPTS=--compress

There is a shell script for starting up the app with CRaC support:

  • start-manual-crac.sh

So you simply have to un-comment it in this shell script. Be aware that the compression at checkpoint and decompression at restoring will take longer. Meaning to say the restore will be slower when using a compressed checkpoint (on my machine used here it takes around 150ms to de-compress the checkpoint)

Start the application and create a checkpoint manually after application startup

  1. Make sure the folder tmp_manual_checkpoint exists

  2. Remove all files from the folder tmp_manual_checkpoint with:

    rm -f ./tmp_manual_checkpoint/*.*
  3. Start the application

    sh start-manual-crac.sh

Create the manual checkpoint

There are two ways of creating the checkpoint manually, calling the application jar or the pid

  1. Calling the application jar

    jcmd target/spring-with-crac-0.0.1-SNAPSHOT.jar JDK.checkpoint

    or executing the create-manual-checkpoint.sh script with the PID (can be found in the output in the 1st shell window)

    sh create-manual-checkpoint.sh target/spring-with-crac-0.0.1-SNAPSHOT.jar

    OR

    sh create-manual-checkpoint.sh <PID>
  2. Check if the checkpoint files have been stored in ./tmp_manual_checkpoint

Restore the application from the manually created checkpoint

  1. Restore the application from the stored checkpoint by executing

    sh restore-manual-crac.sh

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published