Scrivio Interview library
ConceptFoundations7 min read · updated 12 November 2026

Explain rolling, blue-green and canary deployments for a Spring Boot service and one risk of each.

A rolling deployment replaces pods a few at a time, so two versions run together and APIs and schemas must be compatible. Blue-green runs a complete second environment and switches all traffic at once, at the cost of double capacity and with the risk of database changes that the old version cannot handle. A canary sends a small share of traffic to the new version and compares its metrics, with the risk that the share is too small to reveal a problem. All three need readiness probes and graceful shutdown, and feature flags let us separate deploying code from releasing a feature.

Why this question is asked

How we replace a running service decides whether users notice a release at all. A careless deployment drops in-flight requests, and a careless strategy can expose every user to a broken version at once. Interviewers ask this question to see whether we understand what each strategy protects against and what it costs, rather than just naming them. In this answer, we will walk through rolling, blue-green and canary deployments for a Spring Boot service on Kubernetes, name one main risk of each, look at the readiness and shutdown settings all three depend on, and finish with feature flags.

1Rolling Deployments

A rolling deployment is Kubernetes' default. With six replicas, Kubernetes starts a new pod, waits until it is ready, then stops an old one, and repeats until all six run the new version. Two settings control the pace: maxSurge, how many extra pods may exist during the update, and maxUnavailable, how many may be missing.

YAML
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 6
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 # at most 7 pods during the update
maxUnavailable: 0 # never fewer than 6 ready pods

The risk is that for several minutes both versions serve traffic side by side. A user's first request may hit version 2 and the next one version 1. So the new version must keep the old API contract, and any database schema change must work for both versions at once. Renaming a JSON field or dropping a column in the same release breaks the old pods that are still running.

2Blue-Green Deployments

In a blue-green deployment, we run the current version (blue) and a complete copy of the environment with the new version (green). We test green with internal traffic, then switch the router or load balancer so all traffic goes to green at once. If something goes wrong, we switch back to blue, which is still running and warm.

The benefits are an instant switch and an instant rollback, and there is never a period with mixed versions behind one route. The costs are two. During the release we run double the capacity. And the database is usually shared by blue and green, so a schema change that the old version cannot handle, such as dropping a column, makes the switch back to blue fail exactly when we need it. Blue-green only gives a safe rollback when database changes are backward compatible.

3Canary Deployments

A canary deployment sends a small share of traffic, for example 5 percent, to the new version while the rest stays on the old one. We compare the canary's error rate and latency with the stable version for a while, then increase the share step by step, 5, 25, 50, 100 percent, and stop and roll back if the metrics get worse. The name comes from the canaries miners once carried to detect gas before it harmed people.

The risk is statistical. If the service gets 20 requests per minute and the canary gets 5 percent, that is one request per minute: a bug that affects one percent of requests may not appear for hours. Canaries need enough traffic and enough time at each step, and the comparison must use metrics that actually show the kind of failure we fear.

The three strategies at a glance
StrategyHow traffic movesMain risk
RollingPods replaced a few at a timeOld and new versions serve together
Blue-greenAll traffic switches to a full copyDouble cost; DB changes block switching back
CanarySmall share first, then moreToo little traffic to see a problem
Each strategy trades a different kind of cost for a different kind of safety.

4What All Three Need: Readiness and Graceful Shutdown

Every strategy moves traffic between pods, so every one depends on two things. A readiness probe tells Kubernetes when a new pod can receive traffic. If it reports ready before the application context has started and caches are warm, the first requests fail. Spring Boot Actuator provides health groups for this, and on Kubernetes it enables liveness and readiness endpoints automatically.

Graceful shutdown handles the other end. When Kubernetes stops an old pod, it sends SIGTERM. Spring Boot then stops accepting new requests and lets in-flight requests finish, up to a timeout. Graceful shutdown is the default since Spring Boot 3.4; on older versions we set server.shutdown=graceful. Because the load balancer may still send a few requests in the second after SIGTERM, many teams also add a short preStop sleep.

YAML
# application.yml
server:
shutdown: graceful # default since Spring Boot 3.4
spring:
lifecycle:
timeout-per-shutdown-phase: 20s # in-flight requests get up to 20 s
management:
endpoint.health.probes.enabled: true # automatic on Kubernetes
# Deployment pod spec
readinessProbe:
httpGet: { path: /actuator/health/readiness, port: 8080 }
lifecycle:
preStop:
exec: { command: ["sleep", "5"] } # let endpoints update before shutdown starts
terminationGracePeriodSeconds: 30 # longer than sleep + shutdown timeout

Notice that terminationGracePeriodSeconds must be longer than the preStop sleep plus the shutdown timeout, otherwise Kubernetes kills the JVM while requests are still finishing. The preStop sleep needs a sleep binary in the image; newer Kubernetes versions also offer a built-in sleep action, so check your version.

5Feature Flags: Deploying Is Not Releasing

Deploying means putting new code on the servers. Releasing means letting users use a new behaviour. Feature flags separate the two: the new checkout flow is deployed turned off, and we turn it on for internal users, then for 10 percent of customers, then for everyone, without another deployment. If it misbehaves, we turn the flag off in seconds, which is faster and safer than rolling back a whole version that may contain other fixes.

Flags work with all three strategies. They have a cost too: each flag is a branch in the code, so we remove flags once a feature is fully released.

6Follow-up questions

Which strategy would you pick for a typical Spring Boot service?

Rolling deployments as the default, because they are built into Kubernetes and cost nothing extra, combined with backward-compatible changes and good probes. For high-risk or high-traffic services, I would add a canary with automated metric analysis, and keep blue-green for cases that need an instant switch, such as a cutover between infrastructure stacks.

What happens if the readiness probe checks the database?

Then a short database outage makes every pod report not ready at the same moment, and Kubernetes removes all of them from the service, turning a partial problem into a total outage. Readiness should reflect whether this pod can serve traffic, and shared dependencies are usually better left to timeouts and circuit breakers. Spring Boot keeps external checks out of the readiness group by default for this reason.

How do canaries and feature flags differ?

A canary exposes a new version of the whole service to a share of traffic, so it catches problems in any part of the release. A flag exposes one feature inside an already-deployed version. They complement each other: the canary protects the deployment, and the flag protects the release of a specific behaviour.

7Conclusion

In this answer, we saw that rolling deployments replace pods gradually and require compatible APIs and schemas, blue-green deployments switch all traffic to a full second environment at the cost of double capacity and backward-compatible database changes, and canary deployments test a small share of traffic but can miss problems when that share is too small. All three rely on readiness probes and graceful shutdown in Spring Boot, and feature flags let us release features separately from deploying code.

What to say in the interviewAbout 90 seconds aloud

Open with

With a rolling deployment, Kubernetes replaces pods a few at a time, controlled by maxSurge and maxUnavailable. It is cheap and the default, but for a few minutes old and new versions serve traffic together, so the API and the database schema must work for both, for example no dropping a column in the same release.

Then, if they want more

Blue-green means running a full second environment with the new version and switching all traffic at once. The switch and the rollback are instant, but it doubles capacity during the release, and since the database is usually shared, a schema change the old version cannot read makes switching back impossible.

A canary sends a small share, say 5 percent, to the new version, compares error rate and latency against the stable version, and increases the share step by step. Its risk is that with low traffic, 5 percent may be too few requests to see a problem, so it needs enough volume and time at each step.

All three depend on a readiness probe that only reports ready when the app can serve, and on graceful shutdown, which is the default since Spring Boot 3.4, with a shutdown timeout, a short preStop sleep and a termination grace period longer than both.

On top of that I like feature flags, because they separate deploying code from releasing a feature, so we can turn a behaviour off in seconds without a rollback.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 3.4
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 "Explain rolling, blue-green and canary deployments for a Spring Boot service and one...": https://scrivio-interview-library.netlify.app/spring-boot/production-operations/b6299d3a52/