Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

How should Project Leyden's startup and warm-up work affect your platform's choice between JVM with AOT cache, GraalVM native image and CRaC for fast-scaling services?

GraalVM native image gives the fastest startup and smallest memory, but at the price of a closed-world model, long builds and reflection configuration. Leyden-style AOT caches keep the normal JVM with full compatibility and still improve startup and warm-up after a training run, while CRaC restores a checkpointed, already-warm process but needs runtime support and care with secrets and open connections. I would measure startup, time to peak performance, memory and build complexity on our own workloads, prefer the least disruptive option that meets the scaling need, and revisit as Leyden delivers more.

Why this question is asked

Services that scale out quickly, under sudden traffic or in scale-to-zero platforms, care about how fast a new instance becomes useful, and the classic JVM is slow at that: it loads and links thousands of classes and then needs time for the JIT to warm up. There are now three serious ways to fix it, each with different trade-offs, and Project Leyden is changing the balance. Interviewers ask this design question to see whether we understand what each option really does and can choose one for a platform. In this answer, we will recap why JVM startup is slow, explain each of the three options, compare them, and lay out how to decide.

1Why a Normal JVM Starts Slowly and Warms Up Slowly

When a Spring Boot service starts, the JVM loads, verifies and links several thousand classes, and Spring scans, creates and wires hundreds of beans. That is startup time: often several seconds before the first request is served. Then the code runs in the interpreter at first, and the JIT compiler gradually compiles the hot methods using profiles it collects as the code runs. That is warm-up: tens of seconds to minutes before the service reaches its peak speed.

For a long-running service, neither matters much. For a service that adds instances when traffic spikes, or a function that starts per request, both matter a lot: a new instance that is slow for its first minute does not help with a spike that lasts two minutes.

2GraalVM Native Image

Native image compiles the whole application ahead of time into a native executable. At build time it analyses everything reachable from main, compiles it, and even runs some initialisation, then writes a binary with no JIT and no class loading at run time. The result starts in tens of milliseconds and uses much less memory.

The price is the closed-world assumption: everything the program will ever use must be known at build time. Reflection, dynamic proxies, resources and serialization must be declared, through configuration or Spring's AOT processing and RuntimeHints, and libraries that generate classes at run time may not work. Builds take minutes and need a lot of memory. Peak throughput can be lower than a warmed-up JIT unless we use profile-guided optimisation. And debugging and profiling use different tools from the ones we know.

Java
# Spring Boot native image build (GraalVM installed)
./mvnw -Pnative native:compile
# build takes minutes; binary starts in well under a second
# A class used only through reflection must be registered:
class Hints implements RuntimeHintsRegistrar {
public void registerHints(RuntimeHints hints, ClassLoader cl) {
hints.reflection().registerType(LegacyPlugin.class, MemberCategory.INVOKE_PUBLIC_METHODS);
}
}

3Leyden's AOT Cache on the Normal JVM

Project Leyden takes a different path: it keeps the normal JVM, with its full dynamic behaviour, and moves some work to a training run. We run the application once with a representative workload, and the JVM records which classes were loaded and linked and how methods behaved. It writes that into an AOT cache file. Later runs map the cache and skip much of the loading, linking and early profiling work.

In Java 24 this arrived as AOT class loading and linking, and Java 25 added a simpler one-step command and AOT method profiling, which helps the JIT reach peak speed sooner. The gain depends on the application, so we measure ours. Because it is the same JVM, compatibility is complete: reflection, agents, dynamic proxies and our usual tools all work.

Java
# Java 25: training run produces the cache
java -XX:AOTCacheOutput=app.aot -jar app.jar # exercise typical requests, then stop
# Production runs use it; same JVM, same jar
java -XX:AOTCache=app.aot -jar app.jar
# the cache must match the same JDK build and the same class path

4CRaC: Checkpoint and Restore

CRaC, Coordinated Restore at Checkpoint, takes a snapshot of a running, warmed-up JVM process and restores it later. We start the service, warm it up, and take a checkpoint; new instances are restored from that image and are immediately at full speed, because the JIT-compiled code and the heap come back as they were.

It needs support in the runtime, which today means JDK builds that include CRaC, such as Azul Zulu with CRaC or some other vendors' builds, and it relies on Linux checkpoint tooling. The application must be ready for it: open files, sockets and connection pools must be closed before the checkpoint and reopened after restore, which frameworks such as Spring Boot help with through a lifecycle hook. And the snapshot contains the whole heap, so any secrets, tokens or keys in memory at checkpoint time are inside the image; we must keep secrets out until after restore, protect the images, and make sure each restored instance gets its own random seeds and identifiers.

Three ways to start fast
AspectNative imageJVM with AOT cacheCRaC
StartupFastest (tens of ms)Faster than plain JVMVery fast (restore)
Time to peak speedImmediate, peak may be lowerSooner than plain JVMImmediate, already warm
MemoryLowestLike a normal JVMLike a normal JVM
CompatibilityClosed world; config for reflectionFull JVM behaviourFull, but resources must handle restore
Build and opsLong builds, new toolingTraining run in the pipelineCheckpoint images, special JDK, Linux
RisksLibrary support gapsCache must match JDK and jarSecrets and connections in the snapshot

5How to Decide for the Platform

We decide with measurements on our own services, not with benchmarks from talks. For a few representative fast-scaling services we measure four things for each option: time to first successful request, time to reach peak throughput, memory per instance, and build complexity (build time, extra configuration, CI resources). We also count how many of our libraries and agents work with each option.

Then we prefer the least disruptive option that meets the scaling need. If the need is a new instance useful within a few seconds, the AOT cache on the normal JVM may be enough, and it costs only a training step in the pipeline. If the need is scale to zero with startup in milliseconds, or very small memory, native image is the right tool for those specific services, and we accept the closed-world work. CRaC fits when we need instant peak performance and can control the runtime and handle checkpoint security; it is the most operationally demanding of the three.

Step throughChoosing a startup option for a service
  1. Measure plain JVM startup and warm-upbaseline for the service
  2. Does the plain JVM meet the scaling need?
    YesKeep itNoTry the AOT cache
  3. Does the AOT cache meet it?
    YesAdopt: add a training run to the pipelineNoConsider native image or CRaC
  4. Need millisecond start or tiny memory?
    YesNative image for this serviceNoCRaC if runtime and secrets can be handled

4 steps in order. Play them, or step through them one at a time.

6Revisiting as Leyden Delivers More

Leyden is still delivering. Its roadmap includes caching more of the work done at startup, such as compiled code, which would narrow the gap with native image while keeping full compatibility. So a decision made today should be reviewed at each LTS. Services that adopted native image only for startup may be able to return to the normal JVM later, and simplify their builds.

For a platform, that suggests a default of the normal JVM with an AOT cache built in the pipeline, native image as an approved option for specific services with clear needs, and CRaC as an exception with its own security review.

7Follow-up questions

Does Spring Boot support all three?

Spring Boot supports native images through its AOT processing and the GraalVM build tools, supports CRaC through a checkpoint-on-refresh option on a CRaC-enabled JDK, and has support for class data sharing and AOT caches in recent versions; check your Boot version's documentation for the exact properties.

Is the AOT cache the same as class data sharing?

It grew out of it. Class data sharing (CDS) stored parsed class metadata; Leyden's AOT cache extends that idea to linked classes and method profiles.

What breaks an AOT cache?

A different JDK build, a different class path or changed jars. The JVM checks this and ignores a cache that does not match, so it fails safe, but we lose the speed-up. So the cache is built in the same pipeline step that builds the image.

8Conclusion

In this answer, we saw that native image gives the fastest startup and smallest memory at the cost of a closed world, long builds and reflection configuration; that Leyden's AOT cache keeps the normal JVM and full compatibility while improving startup and warm-up after a training run; and that CRaC restores a warm process but needs runtime support and care with secrets and connections. We decide by measuring startup, time to peak, memory and build complexity, prefer the least disruptive option, and revisit as Leyden delivers more.

What to say in the interviewAbout 90 seconds aloud

Open with

I would frame it as three options with different costs. GraalVM native image compiles the app ahead of time into a binary, so it starts in tens of milliseconds with the smallest memory, but it assumes a closed world: reflection, proxies and resources need configuration or Spring's AOT hints, builds take minutes, some libraries do not work, and peak throughput can be lower.

Then, if they want more

Leyden's AOT cache keeps the normal JVM: a training run records loaded and linked classes and method profiles, and later runs start and warm up faster with full compatibility; in Java 25 it is a single flag to create the cache.

CRaC checkpoints a warmed-up process and restores it, so new instances are instantly at peak, but it needs a CRaC-enabled JDK on Linux, connections must be closed and reopened around the checkpoint, and secrets in memory end up in the snapshot.

For the platform I would measure time to first request, time to peak, memory and build complexity on our real services, and pick the least disruptive option that meets the need. That usually means the normal JVM with an AOT cache by default, native image for services that truly need millisecond starts, and CRaC as a reviewed exception. And I would revisit at each LTS as Leyden delivers more.

About this answer

Last updated
12 November 2026
Versions it names
Java 25, Java 24
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "How should Project Leyden's startup and warm-up work affect your platform's choice...": https://scrivio-interview-library.netlify.app/java/java-versions/9feea780a9/