Scrivio Interview library
ScenarioIntermediate7 min read · updated 12 November 2026

Your team moves a Spring Boot service to Quarkus native images to cut cloud cost. Startup is 50 ms, but some features fail at run time and peak throughput is lower than on the JVM. Explain why and how you would decide which mode to run.

A native image is built with a closed-world assumption: only the code, reflection targets, proxies and resources the build can see are included, so anything a library discovers dynamically at run time is simply missing. Quarkus extensions register most of this, other libraries need @RegisterForReflection or configuration files. Peak throughput is lower because a native image has no JIT using live profiles. I would choose native for scale-to-zero, short-lived and memory-tight workloads and the JVM for long-running high-throughput services, deciding by measuring both on real load including build and CI cost.

Why this question is asked

Native images promise tiny startup times and memory, and that promise is real. But teams that move a whole service to native often meet two surprises at once: features that worked on the JVM fail in production, and the service handles fewer requests per second under steady load. Interviewers ask this scenario because it checks whether we understand what ahead-of-time compilation gives up, not only what it gains. In this answer, we will recap how a native image is built, explain the run-time failures and how to fix them, explain the throughput gap, and then build a decision method for which mode to run.

1A Quick Recap of Native Images

GraalVM's native-image tool, and Mandrel, a GraalVM distribution focused on Quarkus, compile a Java application ahead of time into a standalone executable. The tool starts from the main method and follows every call it can find, a points-to analysis, and compiles only the reachable code. Static initialisers that are safe to run early are executed during the build, and their results are stored in the image heap, which is why the executable starts in milliseconds.

That analysis works under a closed-world assumption: everything the program will ever use must be known at build time. There is no class loading of new code at run time and no JIT compiler, the component that compiles hot methods to machine code while the program runs.

2Why Some Features Fail at Run Time

Java libraries love dynamic features. Jackson finds fields and constructors by reflection, some libraries create dynamic proxies for interfaces, and many load files such as templates or certificates from the classpath by name. The build analysis cannot see these targets, because they are only named by strings or decided at run time. So they are not in the image, and the call fails when it finally happens, often on a rarely used path that tests did not cover.

Java
// Works on the JVM, fails in the native image if nothing registered PartnerEvent:
PartnerEvent e = mapper.readValue(json, PartnerEvent.class);
// native: an exception saying no creator or no properties were found for PartnerEvent
InputStream rules = getClass().getResourceAsStream("/rules/vat.csv");
// native: null, because the resource was not included
// Fixes
@RegisterForReflection
public class PartnerEvent { public String id; public Instant at; }
# application.properties
quarkus.native.resources.includes=rules/*.csv

Quarkus extensions already do this registration for the libraries they cover. The Quarkus REST and Jackson extensions register the classes used as request and response bodies, Hibernate registers entities, and so on. Failures usually come from libraries added without an extension, or from types reached only indirectly, such as a class deserialised from a field typed as Object. Besides @RegisterForReflection, GraalVM's reachability metadata files (reflect-config and similar JSON, now consolidated in newer versions; check yours) and the tracing agent, which records dynamic access while tests run on the JVM, help find what is missing. The lasting fix is to run the integration test suite against the native executable in CI, which Quarkus supports with @QuarkusIntegrationTest.

3Why Peak Throughput Is Lower

On the JVM, code starts interpreted and the JIT compiler then recompiles hot methods using profiles collected while the application runs: which branches are taken, which concrete types reach a call site, which loops are long. With that information it inlines aggressively and removes checks, and after a few minutes of warm-up the code is very well optimised for our actual traffic.

A native image is compiled once, before any real traffic, so the compiler must optimise for every possible input. The code is fast from the first request but usually does not reach the JVM's warmed-up peak; differences of 10 to 40 percent in requests per second are commonly reported, depending on the workload. The garbage collector matters too: the community edition of GraalVM uses the simple Serial GC in native images, while Oracle GraalVM offers G1 and profile-guided optimisation, where we run an instrumented build under load and feed the profile into the final build. Check current GraalVM editions and options, because this area changes often.

JVM mode against native mode for the same service
PropertyJVM modeNative mode
Startupabout 1 stens of ms
Memory at idlehundreds of MBtens of MB
Peak throughputhighest after warm-upoften lower, no live profiles
First-request latencyslow until JIT warms upfast from the start
Dynamic featuresall workmust be registered at build
Build timeseconds to a minuteseveral minutes, GBs of RAM
Illustrative orders of magnitude; measure your own service.

4Deciding Which Mode to Run

The choice follows the shape of the workload. Native mode pays off when startup and idle memory dominate: functions and services that scale to zero and start on demand, jobs that run for seconds, sidecars and command-line tools, and services with many small replicas where memory per pod sets the bill. JVM mode pays off for long-running services under steady high load, where startup happens once a week and throughput per CPU sets the bill.

Our service lowered its startup to 50 ms, but if it runs 20 replicas around the clock at high load, those 50 ms were saved only a few times a month, while lower throughput costs CPU every second. Costs outside production count too: native builds take several minutes and need a lot of memory, which slows every pull request and raises CI spend.

Step throughChoosing JVM or native for one service
  1. Scales to zero or starts often?
    YesNative is a strong candidateNoCheck memory pressure
  2. Memory per pod sets the cost?
    YesNative is a candidateNoPrefer the JVM
  3. Load test both buildsthroughput per CPU, p99, memory
  4. Add build and CI costnative build minutes per pipeline
  5. Native cheaper overall and all paths tested?
    YesRun nativeNoRun JVM mode

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

The decision is per service, made from measurements, not from startup time alone.

5Measuring Both on Real Load

We build both variants from the same code and run the same load test: a realistic traffic mix replayed for at least 30 minutes, long enough for the JVM to warm up, at the replica count we use in production. We record requests per second per CPU core, p99 latency, memory and startup time, then convert them into cost: replicas needed for peak traffic times cost per replica, plus CI minutes. Running the native integration tests at the same time shows whether any path still fails. With those numbers the decision is usually obvious, and it can differ between services in the same estate.

6Follow-up questions

Can a JVM service get some of native's startup benefits without going native?

Yes, to a degree. Class data sharing archives and the AOT cache features of recent JDKs (Project Leyden, starting in Java 24) store loaded and linked classes and profiling data from a training run, which can cut startup time substantially while keeping the JIT. CRaC, where supported, restores a checkpointed warm JVM. These keep full dynamic features, so they are worth trying first for long-running services.

How do you keep native builds from slowing down every pull request?

Run JVM-mode tests on every pull request and build and test the native executable on the main branch, nightly or before release, using a larger CI runner or a container build. Caching the dependency layers helps. Failures found nightly are fixed before release, without making developers wait several minutes on each change.

Does lower peak throughput always matter?

Only if the service runs near its CPU limit. Many services spend most of their time waiting on databases and other services, and their throughput is limited by those. For them, a native image's lower peak may make no visible difference, while its memory savings are real, which is why measuring the actual service matters more than general benchmarks.

7Conclusion

In this answer, we explained both surprises of the move to native images. The closed-world build leaves out reflection targets, proxies and resources it cannot see, so features fail at run time unless an extension, @RegisterForReflection or configuration files register them. Without a JIT using live profiles, peak throughput is often lower than a warmed-up JVM. Native suits scale-to-zero, short-lived and memory-constrained workloads, the JVM suits long-running high-throughput services, and the decision comes from measuring both on real load, including build and CI cost.

What to say in the interviewAbout 80 seconds aloud

Open with

Both effects come from how native images are built. The native-image tool does a closed-world analysis: it starts from main, follows what it can see, and includes only that.

Then, if they want more

Anything a library finds dynamically, classes created by reflection, dynamic proxies, resources loaded by name, isn't in the image unless it was registered, so those paths fail at run time, often on rarely used code.

Quarkus extensions register what their libraries need, and for the rest we add @RegisterForReflection, resource includes or reachability metadata, and we run the integration tests against the native executable in CI.

Throughput is lower because a native image is compiled before it sees any traffic, so there's no JIT using live profiles to inline and specialise hot code; community GraalVM also uses the Serial collector. Oracle GraalVM has profile-guided optimisation and G1 that narrow the gap, but I'd check current editions.

To decide, I'd look at the workload: native for scale-to-zero, short-lived or memory-bound services with many small replicas, the JVM for long-running services under high load. Then I'd load test both builds for at least 30 minutes, compare cost per request including CI build time, and decide per service.

About this answer

Last updated
12 November 2026
Versions it names
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 official documentation for the version you use. 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 "Your team moves a Spring Boot service to Quarkus native images to cut cloud cost....": https://scrivio-interview-library.netlify.app/java/other-java-frameworks/d3a62b8e55/