Blue-green deployments explained
Quick answer
A blue-green deployment keeps two identical production environments, but only one of them, "live", is actually serving traffic at any time. You deploy and fully test the new version on the idle one, then switch traffic over once you're confident. If something's wrong after the switch, rollback means switching traffic back, not untangling an in-place upgrade that's already halfway applied.
The name comes from labelling the two environments blue and green, though the colours themselves don't mean anything, they're just a way to talk about "the one that's live" and "the one that isn't" without constantly renaming which is which. At any given moment, one is live and taking real traffic, the other is idle and available to deploy to.
How it works
Say blue is currently live. To release a new version, you deploy it to green, the idle environment, while blue keeps serving all production traffic completely undisturbed. With the new version running on green, you can test it properly, run whatever checks matter, smoke tests, a manual walkthrough, monitoring for errors, all without any of it being visible to a single real user, because green isn't receiving traffic yet.
Once you're satisfied green is good, you switch traffic over to it, typically by updating DNS or repointing a load balancer so incoming requests go to green instead of blue. Green becomes the new live environment. Blue is now idle, but it's still there, running the previous version, untouched.
Why the rollback story is the real advantage
The traffic switch itself is what makes this close to zero-downtime: requests start hitting the new version almost immediately rather than during a window where the old version is being torn down and the new one built up in its place. But the bigger practical advantage is what happens if something's wrong with the new release.
With an in-place upgrade, the old version is gone by the time a problem shows up, you're now debugging a partially-upgraded system under pressure, with users affected the whole time. With blue-green, the previous version is still sitting there on the environment you just switched away from, fully intact and not upgraded in any way. Rolling back means switching traffic back to it, the same mechanism as the original switch, just reversed. That's normally fast and doesn't require reconstructing anything.
The switch itself usually happens at the DNS layer or at a load balancer sitting in front of both environments. See DNS record types explained for how a DNS-based switch works, and Understanding load balancing: what it does and how it decides for how a load balancer can redirect traffic without touching DNS at all. Round robin DNS: basic load distribution without a load balancer covers a related but different pattern worth not confusing with this one, splitting traffic across multiple targets rather than switching cleanly between two.
The trade-off worth being honest about
Blue-green deployments aren't free. The most obvious cost is that you need double the infrastructure running, at least for the period around a switch: two full production environments, both provisioned, even though only one is serving traffic at any given time. For a small or infrequently-deployed service, that overhead might not be worth it. For something deployed often, where downtime and failed rollouts are genuinely costly, it usually is.
The other cost is subtler and matters more in practice: anything stateful doesn't fit this pattern cleanly. A database is the obvious example. You can't just duplicate a database the way you duplicate a stateless application server, blue and green sharing one database means a schema change on green can break blue, while two separate databases mean the two environments' data has diverged the moment you're running both. Making blue-green work for a system with a database usually means the database needs its own migration strategy, often backward-compatible schema changes rolled out ahead of the application switch, rather than assuming the blue-green pattern automatically extends to stateful components.