jetty / jetty/jetty.project

Support CRaC

Open
#10,673 3 comments 0 reactions 0 assignees View on GitHub
Enhancement Low Priority Pinned
Dominant language
Java
Stars
4.1k
Forks
2k
Avg merge
3d 56m
Merged PRs (30d)
48

Description

**Jetty version(s)**
12

**Enhancement Description**

The [CRaC](crac.org) mechanism allows to checkpoint and restore a JVM to allow for fast start times. There is an [example using Jetty](https://github.com/CRaC/example-jetty) provide, but in order to make the checkpoint is stops the entire server. This means that at restore the entire server will be started again and all the expensive scanning of apps for annotations and parsing of web.xml will be done again... thus rendering the restore to be just as slow as a normal start.

I have created a [PR that might do a better job](https://github.com/CRaC/example-jetty/pull/13) by only stop/starting the connectors. However, it is unclear what other services might need to be stop/started. Perhaps that needs to be more like:
```java
@Override
public void beforeCheckpoint(Context context) throws Exception {
for (Connector c : server.getConnectors())
c.stop();
for (Scheduler s : server.getBeans(Scheduler.class))
s.stop();
server.getBean(QueuedThreadPool.class).stop();
server.dumpStdErr();
}

@Override
public void afterRestore(Context context) throws Exception {
server.getBean(QueuedThreadPool.class).start();
for (Scheduler s : server.getBeans(Scheduler.class))
s.start();
for (Connector c : server.getConnectors())
c.start();
}
```

However, in that style any currently scheduled jobs in the scheduler will be lost. So we might need to do some special handling of the scheduler queue?

Eitherway, I believe the intention is for projects like jetty to depend on and extend the [Crac API](https://github.com/openjdk/crac) so that implementations of `beforeCheckpoint` and `afterRestore` would be part of the Jetty project rather than from an example.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.