An engineering team is deploying an updated version of a stateless microservice to Cloud Run. The update requires modifying a Cloud SQL PostgreSQL table schema by adding a new required column and removing an obsolete column. The team plans to perform a canary deployment using Cloud Run revision traffic splitting over 24 hours. How should the cloud architect structure the deployment strategy to maintain zero downtime and ensure immediate rollback capability throughout the release?
- Apply the schema migration using an expand-and-contract pattern by first adding the new column as optional, deploying the new Cloud Run revision to handle both old and new schema structures, and deferring the removal of the obsolete column until after traffic is 100% shifted and validated.Cevap
- BExecute the database schema migration script directly on the production database immediately prior to starting the 1% traffic split to the new Cloud Run revision, enabling both revisions to interact with the new database schema.
- CMigrate the application from Cloud Run to Google Kubernetes Engine (GKE) using Istio and StatefulSets, placing database schemas onto local node persistent storage to isolate canary revision database operations from production.
- DClone the Cloud SQL instance to a new regional database target with the updated schema, split Cloud Run revision traffic to the new database, and submit regional CPU quota increase requests once canary traffic hits 50%.
Cevap
Structure the database migration using an expand-and-contract strategy: add the new column as optional first, deploy the dual-compatible application revision via Cloud Run traffic splitting, and remove the deprecated column only after full rollout verification.
Executing database schema updates via an expand-and-contract approach ensures backward compatibility throughout the traffic shifting process. During a canary deployment, both old and new application revisions query the database simultaneously; keeping schema changes non-breaking allows both revisions to operate without downtime and guarantees safe rollback capability if anomalies occur.
Adım Adım Çözüm
Anahtar Kavram
Expand-and-contract database schema migration pattern during canary deployments
Tahmini Süre:2m 0s