This post is a followup of a previous post where i described to how to boost the startup time of an application with Coordinated Restore at Checkpoint ( CRaC )

In this post i will do the same with the well known Spring PetClinic application. Here doing that is a bit more tricky because of how JPA works.

There is an already a great github repository for PetClinic application customized for CRaC on github

This works out of the box in case of in memory database but when i tried to switch to mysql database i experienced that non trivial changes were needed.

So i created a fork of petclinic app for CRaC with all batteries included to make it work with a production ready database as mysql.
I think this can help reduce the friction to bring in production an application where we aim to use CRaC.

  1. On Linux 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
  1. Add crac dependency
<dependency>
   <groupId>org.crac</groupId>
   <artifactId>crac</artifactId>
   <version>1.4.0</version>
</dependency>
  1. Apply those requirements from Spring ) to prevent early database interaction

Results Link to heading

startup

Starting PetClinicApplication v3.2.0-SNAPSHOT using Java 22.0.1 with PID 4630
...
Started PetClinicApplication in 4.034 seconds (process running for 4.36)

create checkpoint

Starting checkpoint

restore from checkpoint 🏃 🏎

Restarting Spring-managed lifecycle beans after JVM restore
Tomcat started on port 8080 (http) with context path ''
Spring-managed lifecycle restart completed (restored JVM running for 238 ms)

So ….. the ! enhanced PetClinic application started in 238 ms instead of 4 seconds! 🎉 😎