Quick revision
The short answer
I would treat it as a cost comparison with a second benefit attached: we compare what idle always-on capacity costs each year with the engineering and support cost of making startup fast, and we remember that fast startup also gives quicker reaction to load and faster deploys. The techniques form a ladder, from CDS and the JDK AOT cache, which are cheap, to Spring AOT and native images, which cost more to build and support. We apply them first to services with spiky load or many instances, and we revisit the decision as Project Leyden brings startup improvements into the JDK itself.
What to remember
In this answer, we saw that the choice between faster startup and more always-on instances is a comparison of idle capacity cost against engineering and support cost, with faster scaling, deploys and recovery as extra benefits. The techniques form a ladder from cheap CDS and the JDK AOT cache, through Spring AOT, to native images with their higher build and support cost. We apply the cheap layer everywhere through the platform, the expensive one only to spiky, many-instance or scale-to-zero services, and we revisit the balance as Project Leyden improves the JDK.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would treat it as a cost comparison with a second benefit attached: we compare what idle always-on capacity costs each year with the engineering and support cost of making startup fast, and we remember that fast startup also gives quicker reaction to load and faster deploys. The techniques form a ladder, from CDS and the JDK AOT cache, which are cheap, to Spring AOT and native images, which cost more to build and support. We apply them first to services with spiky load or many instances, and we revisit the decision as Project Leyden brings startup improvements into the JDK itself.
Why this question is asked
Every organisation running Java on autoscaled infrastructure meets this trade-off. Slow-starting services force us to keep spare instances running so that a traffic spike does not overwhelm us while new ones start. That spare capacity is money spent every hour. The alternative is engineering work to make services start fast, which also costs money and adds complexity. Interviewers ask this at the principal or director level because it tests whether we can reason with numbers instead of enthusiasm, and whether we can plan over several years while the JDK itself keeps changing. In this answer, we will work through the cost comparison with example numbers, look at the benefits that do not show up on the cloud bill, compare the techniques and what each one costs to support, decide where to apply them first, and set a review point for future JDK improvements.
1What Startup Time Really Costs
When a service needs 40 seconds to start, autoscaling cannot follow a sudden spike, so we keep headroom: extra instances that sit mostly idle so the service survives the first minute of a spike. Scale-to-zero, where a service runs no instances at all when nobody uses it, is not possible at all if the first request would wait 40 seconds.
Let us put numbers on it. Suppose we run 120 services, each keeps 2 extra instances purely as startup headroom, and an instance costs about 70 dollars a month. That is 240 instances, or 16,800 dollars a month, around 200,000 dollars a year, for capacity that exists only because startup is slow. On the other side, enabling the JDK AOT cache in the shared build might take two engineers a month, while moving one service to a native image might take two to four engineer-weeks plus ongoing care. These are the two columns we compare.
Notice that the numbers are only an example; the method is what matters. We gather the real headroom per service from the autoscaling configuration and minimum replica counts, price it from the cloud bill, and estimate how much headroom we could remove if startup fell from 40 seconds to 10 or to 1. Usually the saving is not linear: going from 40 to 10 seconds lets us drop most of the headroom, while going from 10 to 1 adds mainly scale-to-zero for rarely used services.
2Benefits That Are Not on the Cloud Bill
Cost is only part of the case. Fast startup shortens deployments: a rolling update of 30 instances that each need 45 seconds to become ready takes many minutes, and a rollback takes just as long when it matters most. It makes scaling react within seconds, so latency during traffic spikes improves even where we keep headroom. It makes recovery from node failures faster, and it makes local development and integration tests quicker, which developers feel every day.
So when we present the decision, we show the cost saving and also these effects, ideally with measured values: the deployment duration, the 95th percentile latency during the last big spike, and the time to recover after a node loss. A senior leader's job is to make the whole value visible, not only the line that is easiest to compute.
3The Ladder of Techniques and Their Support Cost
The techniques are not equal, and each step up the ladder costs more to build and to support. Class Data Sharing and its successor, the JDK AOT cache, save the work the JVM does to load classes, and from Java 25 also early profiling data, into a file created by a training run during the image build. They need no code changes and are supported by recent Spring Boot versions. Spring AOT processing generates the bean definitions at build time; it is required for native images and can also run on the JVM. Native images with GraalVM give the fastest startup but bring long builds, reachability metadata for reflection-heavy libraries, a fixed set of beans decided at build time, and a separate toolchain to keep current.
| Technique | Startup effect | Build and support cost |
|---|---|---|
| CDS / JDK AOT cache | roughly 30 to 50% faster JVM start | training run in the image build; same JDK required |
| Spring AOT on the JVM | modest gain in context refresh | build plugin step; conditions fixed at build time |
| GraalVM native image | well under 1 second | long builds, library metadata, separate toolchain |
| More always-on instances | none; hides the problem | cloud bill every month |
The support cost is easy to underestimate. Native images change how we debug and profile, and when a library upgrade breaks native compatibility, the team owning that service must fix it. A platform team usually needs to own the toolchain, a set of known-good library versions and documentation, which is a standing cost in people, not a one-off project.
4Where to Invest First
We do not need one answer for the whole company. The value of fast startup is highest where instances come and go: services with spiky load, such as those that see traffic jumps when a campaign starts, services with many instances, where a small saving per instance is multiplied, and services that could scale to zero, such as internal tools used a few hours a day. A steady service with three instances running all day gains little.
- Does load change sharply or often?spikes, campaigns, daily peaksYesStartup matters: continueNoKeep always-on instances; apply the cheap cache only
- Many instances or scale-to-zero?the saving multipliesYesConsider a native imageNoCDS or the AOT cache is enough
- Libraries native-ready?check metadata and a test buildYesPilot a native imageNoStay on the JVM with the AOT cache
3 steps in order. Play them, or step through them one at a time.
Most services stop at the cheap cache; a few justify native images.
So the plan is a broad, cheap layer and a narrow, expensive one. CDS or the AOT cache goes into the shared build for everyone, because its cost is paid once by the platform team. Native images are piloted on two or three services that meet the conditions above, and we measure the actual saving before expanding.
5Revisiting the Decision as the JDK Improves
This decision has a short shelf life. Project Leyden is steadily moving startup improvements into the standard JDK: the AOT cache arrived in Java 24, method profiling was added in Java 25, and further steps such as storing compiled code are planned; check the current JDK release notes. Each step makes the cheap rung of the ladder more effective, which may remove the reason to keep some services on native images, with their higher support cost.
So I would set a review point, for example with each new LTS release or once a year, where we measure startup on a few reference services with the latest JDK and the latest Spring Boot, and compare again with the cost of headroom and of maintaining native builds. A strategy that was right when JVM startup took 40 seconds may be wrong when it takes 8.
6Follow-up questions
How would you convince finance that the engineering spend is worth it?
With the same numbers they use. I would show the monthly cost of instances kept only as startup headroom, taken from the bill and the autoscaling settings, next to the estimated engineering cost in person-weeks, and the expected payback period. Then I would add the operational effects that reduce risk, such as faster rollbacks, as supporting evidence rather than as the main argument.
Why not move everything to native images and be done with it?
Because the cost is not only the migration but the permanent support burden: long builds, library compatibility work at every upgrade, a different debugging experience and a separate toolchain. For a steady service the saving does not cover that cost. Native images pay off where startup changes the outcome, and that is a minority of services in most fleets.
What if teams resist because of build time?
That is a fair concern, so the platform should absorb it. The cache training run adds a minute or two to the image build, and native builds can run only on the main branch or in a nightly job while pull requests use the normal JVM build. Showing teams the measured startup and deploy times for their service makes the benefit concrete.
7Conclusion
In this answer, we saw that the choice between faster startup and more always-on instances is a comparison of idle capacity cost against engineering and support cost, with faster scaling, deploys and recovery as extra benefits. The techniques form a ladder from cheap CDS and the JDK AOT cache, through Spring AOT, to native images with their higher build and support cost. We apply the cheap layer everywhere through the platform, the expensive one only to spiky, many-instance or scale-to-zero services, and we revisit the balance as Project Leyden improves the JDK.
Open with
I would frame it as a cost comparison with some extra benefits on top. First I would measure how many instances we run purely as startup headroom, from minimum replica counts and autoscaling settings, and price that from the cloud bill.
Then, if they want more
In a fleet of a hundred or so services that is often a six-figure yearly sum. Against it I would put the engineering cost of each technique, not only the migration but the ongoing support. CDS and the JDK AOT cache are cheap: a training run in the shared image build, no code change, and Spring Boot supports them.
Spring AOT and GraalVM native images give much faster startup but cost build time, library compatibility work and a toolchain someone has to own. I would also count the benefits that are not on the bill, like faster rolling deploys and rollbacks, quicker reaction to spikes and faster recovery after node loss. Then I would invest in layers.
The cache goes everywhere through the platform. Native images are piloted only on services with spiky load, many instances or a real scale-to-zero case, and we measure the saving before expanding.
Finally, I would review the decision with each LTS release, because Project Leyden keeps improving startup in the JDK itself, and that may make the expensive options unnecessary for some services.
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.
- Official documentation
- Spring Boot reference
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 "Over the next years, startup time will affect your cloud costs through autoscaling and...": https://scrivio-interview-library.netlify.app/spring-boot/boot-startup/f62a08b8f8/