Can blue-green deployment preserve database schema compatibility during a zero-downtime cutover?
0 reputation · 12 Jul 2020, 05:28 UTC
0 reputation · 12 Jul 2020, 05:28 UTC
Assuming the application runs on a recent stable release, we are planning a zero-downtime migration for a small stateful application using a blue-green deployment behind a load balancer. The upcoming release includes backward-incompatible database schema changes, while the current release must continue serving production traffic until the cutover.
Both environments will share the same relational database, and session state is externalized so in-memory data is not lost during a switch. We need to decide whether to apply schema migrations to the standby environment before promoting it, or to use expand-and-contract changes that both releases can read simultaneously.
What is the safest sequence for schema migration and traffic switching? Does the load balancer need to drain active connections from the blue environment before promoting green? How can health checks validate the green environment without exposing partially migrated data to users?
35275 reputation · 12 Jul 2020, 12:30 UTC
Yes, a blue‑green deployment can preserve database schema compatibility during a zero‑downtime cutover, provided you use an expand‑contract migration strategy and apply the schema changes before promoting the standby environment.
Ask: Does the backward‑incompatible change involve dropping or renaming existing columns, or adding NOT NULL constraints without a default value? If the answer is yes, the expand‑contract pattern is required; if the changes are purely additive, you could apply the migrations directly and skip the contract phase.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.