System Design (50 Qs)•Part 3: Distributed Transactions, Consensus & Reliability (26 - 36)
Zero-Downtime Database Migrations (Expand and Contract Pattern).
In Simple Words: How to rename columns or alter schemas on live production databases with billions of rows without table locks or service downtime.
- Expand: Add new nullable column
new_column. - Dual-Write: Deploy application code that reads from
old_columnand writes to bothold_columnandnew_column. - Backfill: Asynchronously copy legacy data from
old_columntonew_columnin small batches. - Switch Read: Switch application reads to
new_column. - Contract: Stop writing to
old_columnand drop it during a low-traffic window.