Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Making Spring AOT processing the default for all services would cut startup time, but it fixes the bean set at build time and some teams rely on runtime profiles to change beans per environment. As the senior technical leader, how do you decide and manage the change?

I would decide on data: measured startup and memory gains on representative services, translated into what they mean for autoscaling speed and cost. I would be honest that AOT changes the build-once, configure-anywhere model for bean selection, since conditional bean registration is decided at build time while property values still work at run time. Then I would set a migration standard that moves environment-specific bean choices into runtime logic or configuration values, phase the change from opt-in to default for new services to existing services as they become compatible, and keep an exception path where the gain does not justify the work.

Why this question is asked

Platform-wide defaults are where a senior technical leader's decisions have the most leverage and the most risk. A change that saves a second of startup per pod across thousands of pods can be worth a lot, but if it silently changes how some services behave in production, the trust cost is far higher. Interviewers ask this question to see whether we can weigh a measurable benefit against a real change in the programming model, and manage the human side of moving many teams. In this answer, we will quantify the benefit, explain the model change honestly, define the migration standard, plan the phases and design the exception path.

1Stating the Benefit With Data

A default affects everyone, so the case must be made with numbers from our own services, not from blog posts. We pick representative services, such as a small API, a large monolith-like service and an event consumer, and measure startup time, time to ready and memory with and without AOT, ideally also combined with class data sharing or the JDK AOT cache, since the benefits add up.

Then we translate the numbers into what the business cares about. Faster startup shortens scale-out, which lets us lower the warm buffer kept for spikes, and it shortens deployments and recovery after node failures. If a service runs 200 pods with a 25 percent buffer for scale-out lag, and faster startup lets us cut the buffer to 15 percent, that is 20 pods saved for that service alone. Presenting the benefit this way makes it comparable with the migration effort.

Example measurements (illustrative)
ServiceStartup beforeWith AOT + AOT cacheEffect
orders-api4.2 s1.9 sfaster scale-out, buffer 25% -> 15%
catalog (large)11.5 s5.8 srolling deploys 40% shorter
event-consumer3.1 s2.6 ssmall gain, low priority
The gain differs a lot between services, which is why the plan allows exceptions.

2Being Honest About the Model Change

Spring applications are commonly built once and configured per environment. AOT keeps half of that promise. Property values, such as URLs, credentials and timeouts, are still bound at run time from the environment. But which beans exist is decided at build time: @Profile on beans, @ConditionalOnProperty and similar conditions are evaluated during the AOT step and the result is baked into generated code. A team that uses a runtime profile to swap a bean will see the build-time choice in every environment, without an error.

Saying this clearly up front matters. If we sell AOT as a free speed-up and teams discover the change in an incident, the whole programme loses credibility. If we explain it, show the affected patterns and provide tools, most teams accept it as a reasonable trade.

3Defining the Migration Standard

The standard tells teams what good looks like. Environment-specific behaviour is expressed as configuration values read at run time, not as different beans. Where a service really needs different implementations per environment, one bean selects the implementation from a property at startup, or the service builds separate artifacts explicitly. Feature toggles are always runtime checks inside beans, never conditional registration.

We support the standard with tooling: a build check that lists @Profile and @ConditionalOnProperty on application beans, a test template that starts the AOT-processed application with each environment's configuration and compares the bean set with a normal start, and examples of before and after for the common patterns. This turns a vague rule into a short checklist each team can complete.

Java
// Before: bean chosen by runtime profile (frozen under AOT)
@Bean @Profile("dev") CacheManager localCache() { return new ConcurrentMapCacheManager(); }
@Bean @Profile("!dev") CacheManager redisCache(RedisConnectionFactory f) { return RedisCacheManager.create(f); }
// After: one bean, choice made from a property at run time
@Bean
CacheManager cacheManager(CacheProps props, ObjectProvider<RedisConnectionFactory> redis) {
return switch (props.mode()) { // cache.mode=local or redis, set per environment
case LOCAL -> new ConcurrentMapCacheManager();
case REDIS -> RedisCacheManager.create(redis.getObject());
};
}

The after version works the same with and without AOT, so a team can migrate before the default changes and nothing breaks if AOT is later switched off.

4Phasing the Change

We phase it in three steps. Opt-in: the golden path build template gains a single switch that runs the AOT step and adds -Dspring.aot.enabled=true at run time, with startup measured automatically; early adopters are services that gain most and have no environment-specific beans. Default for new services: once the early adopters have run for a few weeks without incidents, new services get AOT from their first commit, which costs nothing because they are written to the standard from the start. Existing services: they switch as the build check shows them compatible, starting with those with the largest gain, and each team schedules it like any dependency upgrade.

At every phase we publish the results: how many services, startup saved, incidents caused. That keeps the decision reviewable and lets us slow down if problems appear.

Step throughPhases and exits
  1. Measure on representative servicesstartup, memory, scale-out effect
  2. Opt-in in golden pathearly adopters, automatic measurement
  3. Incidents or surprises?
    YesFix standard and tooling firstNoDefault for new services
  4. Existing service compatible?
    YesSwitch on, largest gain firstNoMigrate or request exception
  5. Review results each quarterkeep, adjust or stop

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

5Keeping an Exception Path

Some services will not be worth it: a batch job that starts once a day, a service whose startup is dominated by loading a large dataset, or a legacy service that would need weeks of rework to remove profile-based beans. For them, an exception with a short reason and a review date is cheaper than forcing the change. The exception is visible in the same report as the gains, so it stays an informed choice rather than a forgotten gap. Making it easy to say no where the numbers are poor is also what makes teams trust the default where the numbers are good.

6Follow-up questions

Why not keep AOT opt-in forever?

Because opt-in features are adopted mostly by teams that already care, and the platform-wide benefit, such as smaller scale-out buffers, comes from broad adoption. Making it the default for new services costs nothing and slowly moves the whole estate.

What if an incident is caused by the frozen bean set after the default changes?

We treat it as a gap in the standard or tooling, not as one team's mistake: roll back by turning off spring.aot.enabled at run time, which needs no rebuild, then improve the build check or bean-comparison test so the pattern is caught next time.

How do you get buy-in from teams that rely on profiles heavily?

By showing them their own measured gain, giving them the exact code changes for their patterns and letting them choose the timing. Teams resist changes imposed without context much more than changes that come with data and help.

7Conclusion

In this answer, we saw how a senior leader would decide on making Spring AOT the default. We measured the startup gain on representative services and translated it into autoscaling and cost, stated clearly that conditional bean registration moves to build time while property values stay dynamic, set a migration standard with tooling, phased the change from opt-in to new services to existing services, and kept an exception path for services where the gain does not justify the work.

What to say in the interviewAbout 90 seconds aloud

Open with

I'd start by measuring on our own representative services: startup and memory with and without AOT, ideally combined with CDS or the JDK AOT cache, and I'd translate the result into business terms, like how much smaller our scale-out buffers or rolling deploy times could be.

Then, if they want more

Then I'd be very clear about the trade. AOT keeps runtime configuration of property values, but it moves bean selection to build time, so @Profile and @ConditionalOnProperty are decided once in the build. Teams that swap beans per environment with runtime profiles would get the build-time choice everywhere, silently.

So I'd publish a migration standard: environment differences are configuration values, feature toggles are runtime checks inside beans, and real structural differences mean an explicit choice in one bean or separate artifacts. I'd back it with a build check for profile-based beans and a test that compares the bean set with and without AOT.

The rollout is phased: opt-in first for services with the biggest gain, then default for new services once early adopters have run cleanly, then existing services as they become compatible, largest gain first. Rollback is easy because the runtime flag can be turned off without a rebuild.

And I'd keep an exception path with a reason and review date for services where the gain is too small.

About this answer

Last updated
12 November 2026
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 "Making Spring AOT processing the default for all services would cut startup time, but it...": https://scrivio-interview-library.netlify.app/spring-boot/native-and-aot/7bee4d4e29/