Why architecture matters here
GraalVM architecture matters because AOT compilation changes Java's economics for cold-start-sensitive workloads. Instant startup (~30ms) + low memory (~50-100 MB) makes Java competitive with Go for serverless. But peak throughput can be lower than JIT-compiled JVM.
Cost is engineering — reflection config, framework compatibility. Frameworks like Micronaut and Quarkus greatly reduce this.
Reliability of AOT-compiled apps is high — no JIT warmup surprises.
The architecture: every piece explained
Walk the diagram top to bottom.
Java code. Standard bytecode; but must be AOT-compatible (limited reflection etc).
GraalVM Compiler. Advanced JIT + AOT compiler; often produces better optimized code than HotSpot's C2.
Native Image. AOT compiles to standalone executable. No JVM at runtime.
Instant startup. Millisecond boot; no class loading, no JIT warmup.
Low memory. 10-30% of JVM footprint typically. No JIT compiler in memory.
Reflection config. AOT can't discover reflection at runtime; must be listed in config. Tracing agent helps generate.
Truffle framework. Language implementation framework — Python, Ruby, JS all run on Graal via Truffle.
Serverless fit. Lambda cold starts drop from seconds to milliseconds.
Peak throughput. Sometimes less than JIT — HotSpot has decades of optimizations.
Frameworks. Micronaut + Quarkus designed for AOT; Spring Boot 3 supports.
End-to-end Native Image build + run
Trace a build. Java app using Quarkus. Build with `mvn package -Pnative`. GraalVM Native Image starts.
Classpath analysis: which classes reachable? Only reachable ones compiled.
Reflection config consulted: which reflective accesses to support? Compile those hooks.
Native compilation: converts bytecode to machine code; embeds runtime (garbage collector, etc.).
Output: 60 MB executable, no JVM needed to run.
Deploy to Lambda. Cold start: 40ms vs 2s for JIT JVM. Warm invocation: comparable or slightly slower than JIT.
Alternative: Spring Boot 3. Similar but needs more reflection config initially. Tracing agent runs app under HotSpot with agent that logs reflection uses; config generated; native build with that config.
Peak throughput: benchmarks against JIT show native is 80-95% of peak; sometimes even better.