# Safe Deployments: Blue-Green, Canary and Feature Flags Questions about reliability often end with "how would you roll out a change safely?" Here are the main techniques and when to use each. ## Rolling deployment Replace instances a few at a time. Simple and the default in Kubernetes. During the rollout, old and new versions run side by side, so they must be compatible with each other and with the database schema. ## Blue-green Run two complete environments. Blue serves traffic; deploy to green, test it, then switch the load balancer. Rollback is flipping back. Costs double capacity during the switch, and database changes still need care because both versions share data. ## Canary Send a small slice of traffic (1 in 100 requests, or internal users first) to the new version, compare error rates, latency and business metrics against the old version, then widen in steps. Automated canary analysis can halt and roll back if the new version is worse. Best for large services where problems only show up under real traffic. ## Feature flags Ship code dark and turn features on per user, per region or gradually, independently of deploys. Kill switches let you disable a broken feature in seconds. Clean up old flags, or they turn into technical debt. ## Database changes: expand and contract 1. Expand: add the new column or table, keep the old one; write to both. 2. Backfill existing data. 3. Switch reads to the new schema. 4. Contract: remove the old column after every version that used it is gone. This keeps every step backward compatible, so any deploy can be rolled back. ## Interview tip Mention observability: you can't canary without metrics that show the difference between versions. Disclosure: I'm with Linkjob AI (https://www.linkjob.ai/), real-time interview help.