liveBook · Manning

Blue-green deployment

As explained in Grokking Software Architecture

Blue-green deployment is a release pattern that maintains separate current and replacement environments and switches traffic between them after verification.

Blue-green deployment is a release pattern with two matching environments: Blue serves current production traffic, while Green runs the replacement version in isolation. After verifying Green, you switch traffic to it rather than patching live servers. Think of it as preparing a spare stage before moving the audience. section 9.8.2 section 13.3.2

A typical switch follows these steps:

  • Build and deploy the new version to Green while Blue continues serving users. section 13.3.2 section 13.5.1
  • Verify Green with health checks and, as appropriate, integration tests, load tests, and security scans. section 13.3.2 section 13.5.1
  • Update the API gateway or load balancer to route production traffic from Blue to Green. section 13.3.2
  • If the new version fails, route traffic back to the untouched Blue environment. Destroy old infrastructure only when it is no longer needed for rollback. section 9.8.2 section 13.3.2
Figure 13.2 Blue-Green Deployment: The ultimate safety switch. By maintaining an isolated, duplicate environment (Green), you can deploy and verify new code out of sight. When ready, a fraction-of-a-second configuration change at the routing layer instantly swings 100% of live traffic over, providing a zero-downtime cutover with an instant rollback path if things go wrong.

Follow the traffic switch between the isolated Green environment and the live Blue environment. section 13.3.2

An order service gets a new version

Customers place orders on Blue while the new Order Service is tested on Green. After the switch, a billing processor develops a memory leak. Routing back to Blue can restore the previous service quickly—but orders written to a separate Green database may be missing from Blue unless the data is synchronized. section 13.3.2

The safety switch has a price. Running two fully provisioned environments during cutover costs more infrastructure than a rolling update. Blue-green also avoids mixing versions within the active service fleet, but a fast routing rollback does not automatically undo or synchronize database writes. Plan database alignment before relying on the switch. section 13.3.2 section 13.3.5

Choose blue-green when fast rollback and avoiding downtime matter enough to justify two production fleets. If infrastructure cost is the main constraint, consider rolling updates; if limiting exposure to a small share of real traffic matters most, consider a canary deployment. section 13.3.5

How Grokking Software Architecture covers it

How deep it goes
Walks through deployment, verification, cutover, rollback, cost, and database divergence without providing a detailed implementation.
Examples
Uses an Order Service cutover with a billing memory leak and potentially missing orders to illustrate rollback and data divergence.
What you can do after
Evaluate deployment strategies by rollback speed, infrastructure cost, version mixing, and data-divergence risk.
How it connects
Connects immutable infrastructure, load balancing, continuous delivery, rolling updates, canary deployment, and database synchronization.

Also explained in

Compare how 6 books explain blue-green deployment →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.