Quick revision
The short answer
I would take work out of application startup at platform level: database migrations run as a separate job or init step before the rollout, cache warming becomes optional or runs in the background with readiness control, and remote registration is replaced by the platform's own service discovery. Then I would set startup time budgets, measure them for every service, and document which kinds of work are allowed in runners.
What to remember
In this answer, we saw why startup work in runners makes rollouts slow and fragile: work that should happen once per release runs once per pod, and it couples startup to other systems. At platform level we move migrations to a Job before the rollout, make warming optional and background with readiness control, replace remote registration with Kubernetes service discovery, and then set startup budgets, measure them and write down which work runners may do.
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 take work out of application startup at platform level: database migrations run as a separate job or init step before the rollout, cache warming becomes optional or runs in the background with readiness control, and remote registration is replaced by the platform's own service discovery. Then I would set startup time budgets, measure them for every service, and document which kinds of work are allowed in runners.
Why this question is asked
When one service does heavy work at startup, it is a local problem. When most services run migrations, warm caches and register themselves in runners, every rollout becomes slow and every incident during startup becomes harder to recover from. Interviewers ask this of senior engineers because the fix is a set of platform rules and tools rather than one code change. In this answer, we will see why startup work makes rollouts fragile, then move each kind of work to a better place, and finish with budgets, measurement and a written policy.
1Why Startup Work Makes Rollouts Fragile
A rolling update replaces pods one or a few at a time and waits for each new pod to become ready. If each pod spends 90 seconds on startup work, a 20 pod service takes half an hour to roll out. Worse, every pod repeats the same work: twenty pods each try to run the same migration, each warm a full cache, and each call a registry.
Startup work also couples a service's availability to other systems. If the registry is slow, pods do not start. If the migration takes a lock, the other nineteen pods wait on it. If a runner fails halfway, the pod restarts and does it again. The work that should happen once per release is happening once per pod, at the most delicate moment.
2Moving Migrations Before the Rollout
Database migrations, with Flyway or Liquibase, change a shared database, so they should run once per release, not once per pod. The platform can run them as a separate step: a Kubernetes Job that runs the same image with a migrate command before the Deployment is updated, or a pipeline stage that runs them and gates the rollout on success.
This needs one discipline: migrations must be backward compatible with the previous release, because old pods keep running while the new schema is in place. Adding a column is fine; renaming one is done in steps across releases, the expand and contract pattern. That rule is worth writing down, because it is what makes running migrations separately safe.
3Making Warming Optional or Background
Cache warming should never block readiness for minutes. The platform starter can provide a standard warm-up helper that runs loaders in the background after startup and keeps the pod out of traffic until they finish, through a health indicator in the readiness group, with a time limit after which the pod becomes ready anyway with a cold cache. Each service then only writes the loader, and the timing behaviour is the same everywhere.
Warming should also be optional, switched by a property, so it can be turned off during an incident when fast restarts matter more than warm caches. And teams should be encouraged to measure whether warming is needed at all; many caches fill quickly from normal traffic.
4Replacing Remote Registration With Platform Discovery
Runners that register the service with Eureka, Consul or a custom registry duplicate what Kubernetes already does. A Kubernetes Service and its endpoints are updated automatically when pods become ready or stop, so clients find healthy instances without any registration code. Removing registration from runners removes a startup dependency and a failure mode: a slow registry no longer blocks pods from starting.
Where a registry must stay, for example for systems outside the cluster, the platform should register on behalf of services, from readiness, not from application code in every service.
| Work | Today | Platform target |
|---|---|---|
| Database migrations | Runner in every pod | Job or pipeline step before rollout |
| Cache warming | Blocking runner | Background helper, readiness indicator, optional |
| Remote registration | Runner calls registry | Kubernetes Service discovery |
| Config checks | Ad hoc | Validated @ConfigurationProperties at startup |
| Small seed or checks | Runner | Runner, within the time budget |
5Budgets, Measurement and a Written Policy
Rules only work when they are measured. The platform can set a startup budget, for example time to ready under 20 seconds for a typical service, and report each service's time to ready from the ApplicationReadyEvent timestamp or the startup actuator endpoint into a dashboard. Services over budget get a ticket, not a block, and the trend shows whether the estate is improving.
Finally, the platform guide states which work is allowed in runners: short, idempotent tasks of a few seconds that the service cannot serve without. Migrations, remote registration and long warm-up are not allowed there, and the guide links to the platform's replacements. A short architecture check in CI can flag runner beans for review, so new ones are discussed when they are added rather than discovered in an incident.
- Measure time to ready for all servicesdashboard, baseline
- Move migrations to a Jobbackward compatible schema
- Offer background warm-up helperreadiness indicator, time limit
- Remove registration runnersuse Kubernetes Services
- Set budget and runner policyreview new runners in CI
5 steps in order. Play them, or step through them one at a time.
6Follow-up questions
What if the migration Job fails?
The pipeline stops before updating the Deployment, so old pods keep serving with the old schema. Because migrations are applied in transactions where the database allows it, or written to be rerunnable, the team fixes the migration and runs the pipeline again.
Do init containers work for migrations instead of a Job?
They run per pod, so with 20 replicas they would still try 20 times, relying on Flyway's lock to serialise them. They are better than runners, because they finish before the app starts, but a single Job before the rollout is cleaner.
How do you get teams to adopt these changes?
Make the platform path easier than the old one: a starter with the warm-up helper, a pipeline template with the migration step, and generated pull requests that remove registration code. Then show the rollout time drop on the dashboard.
7Conclusion
In this answer, we saw why startup work in runners makes rollouts slow and fragile: work that should happen once per release runs once per pod, and it couples startup to other systems. At platform level we move migrations to a Job before the rollout, make warming optional and background with readiness control, replace remote registration with Kubernetes service discovery, and then set startup budgets, measure them and write down which work runners may do.
Open with
The underlying problem is that work which should happen once per release is happening once per pod at startup, and it ties every pod's start to other systems.
Then, if they want more
So I would move each kind of work to its proper place. Database migrations would run as a Kubernetes Job or pipeline step before the rollout, with Flyway disabled in the service itself, and with the rule that migrations stay backward compatible, so old and new pods can run against the new schema.
Cache warming would become optional and run in the background, using a helper in the platform starter that keeps readiness down through a health indicator until the cache is warm, with a time limit. Remote registration in runners would go away, because Kubernetes Services already discover ready pods, and that removes a startup dependency.
Then I would set a startup budget, say time to ready under twenty seconds, measure every service from the ready event or the startup endpoint on a dashboard, and ticket the ones over budget. Finally I would write down which work is allowed in runners, short idempotent tasks the service truly needs, and flag new runners in CI for review.
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.
- 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 "Many services run database migrations, cache warming and remote registration in runners...": https://scrivio-interview-library.netlify.app/spring-boot/boot-startup/01dcbd0616/