Stateful infrastructure comprises resources that store or manage data, including databases, queues, caches, and stream-processing tools. Changes require extra care because replacing or updating a resource can corrupt or lose application data. section 9.3.1 section 9.4
Use a blue-green change process when updating a stateful resource in place is unsafe or unsupported:
- Duplicate the infrastructure configuration and create a green resource. section 9.3.1
- Migrate and reconcile data from blue to green, then test the new resource before switching applications. section 9.3.1 section 9.3.2
- Switch application traffic or endpoints to green and remove blue only after applications no longer depend on it. section 9.3.1 section 9.3.3
- Make migration automation idempotent so repeated runs produce the same state without duplicating data. section 9.3.2
Incremental database cutover
A canary-style rollout can first write to both databases, then write exclusively to green, and finally read from green. Regression testing at each stage enables rollback to blue, although dual writes may require data-reconciliation automation. section 9.3.3
Figure 9.10 If you can’t update the database in place, you must deploy a new green database, migrate and reconcile the data, and change the database endpoint from blue to green.
Follow the deployment sequence for creating green, migrating and reconciling data, and changing the database endpoint. section 9.3.1
