Blue-green deployment
Blue-green деплой
With blue-green deployment, you prepare and test a new version of an application in a separate environment while the current version serves users. You then switch live traffic to the new version and keep the previous one available for rollback.
The idea: deploy first, route traffic second
Blue and green are two environments capable of serving production traffic. One is live; the other is where you prepare the next release. Because deploying the new build doesn't send customers to it, you can check that it runs and works before making it live. Blue and green are labels, not permanent roles: after a successful switch, the old live environment can be reused for the next release.
A checkout rollout
Suppose the public checkout endpoint routes to a pool called checkout-blue. You deploy a new build to checkout-green, warm it up, and run a test checkout through a private route using a test account and a payment sandbox. A readiness probe can tell you the service is ready to receive traffic, but it doesn't prove that a checkout succeeds.
Once green is ready to handle the expected production load, you update the load balancer so new requests go there. Customers keep using the same URL. You let in-flight requests finish on blue rather than shutting it down immediately. Long-lived connections need their own plan: changing where new requests go doesn't move an open WebSocket to another server.
After the switch, you watch error rates, latency, and checkout completion. If an agreed rollback threshold is crossed, you point the route back to blue. Keep blue healthy and able to take the load for the agreed rollback window; a route change won't help if the old pool has already been shut down.
What the switch doesn't undo
A fast traffic rollback is not a data rollback. Both versions might use the same database, and green may already have written rows or sent events. If a migration drops a column that blue expects, switching back can make things worse. Use a backward-compatible migration: add the new schema first, keep reads and writes compatible during the transition, and remove obsolete fields after the rollback window closes.
Also check what runs without HTTP traffic. A scheduled job can run in both environments even if only one receives web requests. Decide which environment owns the job, or design it to tolerate duplicate execution.
When to choose it
Blue-green deployment is useful when you can afford overlapping capacity and want to test the complete new deployment before exposing it to users. The two environments can be separate server pools or two sets of workloads in one Kubernetes cluster. A rolling update replaces instances in batches, whereas blue-green prepares a complete new target before cutover. A canary release exposes a small share of live traffic first; a plain blue-green cutover sends all new traffic to the new version, so a defect missed during testing can affect many users at once.
In an interview
Walk through what you would check before cutover, what would trigger rollback, and what might prevent it. “Switch the load balancer back” is a good start, but a complete answer accounts for capacity, in-flight requests, and changes to shared state.