|
1 | 1 | [[checkpoint-restore]]
|
2 | 2 | = JVM Checkpoint Restore
|
3 | 3 |
|
4 |
| -The Spring Framework integrates with checkpoint/restore as implemented by https://github.com/CRaC/docs[Project CRaC] in order to allow implementing systems capable to reduce the startup and warmup times of Spring-based Java applications with the JVM. |
| 4 | +The Spring Framework integrates with checkpoint/restore as implemented by https://github.com/CRaC/docs[Project CRaC] in order to allow implementing systems capable of reducing the startup and warmup times of Spring-based Java applications with the JVM. |
5 | 5 |
|
6 | 6 | Using this feature requires:
|
7 | 7 |
|
8 | 8 | * A checkpoint/restore enabled JVM (Linux only for now).
|
9 |
| -* The presence in the classpath of the https://github.com/CRaC/org.crac[`org.crac:crac`] library (version `1.4.0` and above are supported). |
10 |
| -* Specifying the required `java` command line parameters like `-XX:CRaCCheckpointTo=PATH` or `-XX:CRaCRestoreFrom=PATH`. |
| 9 | +* The presence of the https://github.com/CRaC/org.crac[`org.crac:crac`] library (version `1.4.0` and above are supported) in the classpath. |
| 10 | +* Specifying the required `java` command-line parameters like `-XX:CRaCCheckpointTo=PATH` or `-XX:CRaCRestoreFrom=PATH`. |
11 | 11 |
|
12 |
| -WARNING: The files generated in the path specified by `-XX:CRaCCheckpointTo=PATH` when a checkpoint is requested contain a representation of the memory of the running JVM, which may contain secrets and other sensitive data. Using this feature should be done with the assumption that any value "seen" by the JVM, such as configuration properties coming from the environment, will be stored in those CRaC files. As a consequence, the security implications of where and how those files are generated, stored and accessed should be carefully assessed. |
| 12 | +WARNING: The files generated in the path specified by `-XX:CRaCCheckpointTo=PATH` when a checkpoint is requested contain a representation of the memory of the running JVM, which may contain secrets and other sensitive data. Using this feature should be done with the assumption that any value "seen" by the JVM, such as configuration properties coming from the environment, will be stored in those CRaC files. As a consequence, the security implications of where and how those files are generated, stored, and accessed should be carefully assessed. |
13 | 13 |
|
14 |
| -Conceptually, checkpoint and restore match with xref:core/beans/factory-nature.adoc#beans-factory-lifecycle-processor[Spring `Lifecycle` contract] for individual beans. |
| 14 | +Conceptually, checkpoint and restore align with the xref:core/beans/factory-nature.adoc#beans-factory-lifecycle-processor[Spring `Lifecycle` contract] for individual beans. |
15 | 15 |
|
16 |
| -== On demand checkpoint/restore of a running application |
| 16 | +== On-demand checkpoint/restore of a running application |
17 | 17 |
|
18 | 18 | A checkpoint can be created on demand, for example using a command like `jcmd application.jar JDK.checkpoint`. Before the creation of the checkpoint, Spring Framework
|
19 |
| -stops all the running beans, giving them a chance to close resources if needed by implementing `Lifecycle.stop`. After restore, the same beans are restarted, with `Lifecycle.start` allowing to reopen resources when relevant. For libraries not depending on Spring, checkpoint/restore custom integration can be provided by implementing `org.crac.Resource` and registering the related instance. |
| 19 | +stops all the running beans, giving them a chance to close resources if needed by implementing `Lifecycle.stop`. After restore, the same beans are restarted, with `Lifecycle.start` allowing beans to reopen resources when relevant. For libraries that do not depend on Spring, custom checkpoint/restore integration can be provided by implementing `org.crac.Resource` and registering the related instance. |
20 | 20 |
|
21 | 21 | WARNING: Leveraging checkpoint/restore of a running application typically requires additional lifecycle management to gracefully stop and start using resources like files or sockets and stop active threads.
|
22 | 22 |
|
23 | 23 | NOTE: If the checkpoint is created on a warmed-up JVM, the restored JVM will be equally warmed-up, allowing potentially peak performance immediately. This method typically requires access to remote services, and thus requires some level of platform integration.
|
24 | 24 |
|
25 | 25 | == Automatic checkpoint/restore at startup
|
26 | 26 |
|
27 |
| -When the `-Dspring.context.checkpoint=onRefresh` Java system property is set, a checkpoint is created automatically during |
28 |
| -the startup at `LifecycleProcessor.onRefresh` level. At this phase, all non-lazy initialized singletons are instantiated, |
29 |
| -`InitializingBean#afterPropertiesSet` callbacks have been invoked, but the lifecycle has not started and |
| 27 | +When the `-Dspring.context.checkpoint=onRefresh` JVM system property is set, a checkpoint is created automatically at |
| 28 | +startup during the `LifecycleProcessor.onRefresh` phase. After this phase has completed, all non-lazy initialized singletons have been instantiated, and |
| 29 | +`InitializingBean#afterPropertiesSet` callbacks have been invoked; but the lifecycle has not started, and the |
30 | 30 | `ContextRefreshedEvent` has not yet been published.
|
31 | 31 |
|
32 | 32 | WARNING: As mentioned above, and especially in use cases where the CRaC files are shipped as part of a deployable artifact (a container image for example), operate with the assumption that any sensitive data "seen" by the JVM ends up in the CRaC files, and assess carefully the related security implications.
|
33 | 33 |
|
34 |
| -NOTE: Here checkpoint/restore is a way to "fast-forward" the startup of the application to a phase where the application context is about to start, but does not allow to have a fully warmed-up JVM. |
| 34 | +NOTE: Automatic checkpoint/restore is a way to "fast-forward" the startup of the application to a phase where the application context is about to start, but it does not allow to have a fully warmed-up JVM. |
0 commit comments