Video in progress
How do you choose a deploy strategy for Spring services: rolling update, blue/green or canary?
A rolling update is simple and cheap, but two versions run at the same time; blue/green gives a fast rollback, but needs double the resources and a compatible schema; canary verifies risk on a small slice of traffic with measurements, but needs good metrics and automated analysis.
📖 Answer
All three share one condition: the database schema must work with two versions at the same time. Without that, none of them is safe.
Rolling update is the Kubernetes default. Pods are replaced one by one.
- You need: a correct readiness probe (a pod gets no traffic until it is ready), graceful shutdown,
maxUnavailable/maxSurge. - Rollback: another rolling update, so minutes.
- Fits: most internal services.
Blue/green: the new version is brought up fully, verified, and then traffic is switched over at once.
- Rollback is easy: you turn the traffic back, and it takes seconds.
- Cost: double the resources during the switch; the JVM pods are "cold", so with an abrupt switch p99 spikes in the first minutes while the JIT warms up (warm-up requests in advance help).
- Fits: systems with few releases where each one is risky.
Canary: the new version first gets 1–5% of the traffic, the metrics are compared, and then it is increased step by step.
- You need: traffic splitting by percentage (service mesh, Argo Rollouts, Flagger), metrics split by version (error rate, p99, business indicators), and an automatic "stop and roll back" rule.
- The trap: on a low-traffic service 5% is not statistically meaningful, and some bugs only show up for certain customers.
- Fits: high-traffic, user-facing services (payments, checkout).
My general policy:
- Default is rolling, with correct probes and graceful shutdown on every service.
- Services on the critical path: canary with automated analysis.
- Risky changes (a new payment flow): not a deploy but release management: the code ships behind a switched-off feature flag, and the flag is turned on step by step. Separating deploy from release is often cheaper than blue/green and gives finer control.
And whatever the strategy, the way back has to be tested in advance: trying it for the first time during an incident is very expensive.
Sign up to mark studied questions and save your progress.