Java / JVM Architecture (Java21) Interview questions
When should you choose AOT-style CDS archives versus JIT warm-up in a production deployment?
The choice comes down to whether your workload's cost is dominated by startup latency or by sustained steady-state throughput.
CDS/AppCDS archives trade a build-time packaging step, generating and shipping the .jsa file alongside your application, for a much faster cold start, since class parsing, verification, and even some JIT-related setup work is pre-computed and memory-mapped in rather than redone. This matters most for short-lived processes: serverless functions, scale-to-zero containers, CLIs invoked repeatedly, and any environment where the JVM spends a meaningful fraction of its total lifetime just starting up.
Relying purely on ordinary JIT warm-up means every request pays a "warm-up tax": code runs interpreted, then C1-compiled, then finally C2-optimized, over some initial period before reaching peak throughput - acceptable, even preferable, for a long-running, always-on service where that ramp-up is a tiny fraction of the process's total uptime and isn't worth the operational overhead of maintaining an archive that can go stale whenever dependencies or classes change.
In practice, many production systems combine both: an AppCDS archive to shrink the time to the first successfully served request, plus tiered JIT compilation running as normal underneath to reach full native-code performance shortly after startup - the two techniques address different points on the startup-to-steady-state curve rather than competing with each other.
More Related questions...