Upgrade RDS PostgreSQL from 13 to 17 with minimal downtime. How?
AdvancedScenarioData and databases
Answer
Situation read → An in-place major upgrade takes the database down for the whole upgrade. RDS Blue/Green Deployments let you upgrade a copy and switch over in about a minute.
What I'd do →
- Check extensions and their versions for compatibility, and run the app's tests against PostgreSQL 17 in staging.
- Create a Blue/Green deployment; the green environment is upgraded and kept in sync with logical replication.
aws rds create-blue-green-deployment --blue-green-deployment-name pg17-upgrade \
--source arn:aws:rds:ap-south-1:111122223333:db:prod-db \
--target-engine-version 17.4 --target-db-parameter-group-name pg17-prod
- Prerequisites for logical replication:
rds.logical_replication = 1and primary keys on replicated tables, and no DDL during the sync. - Run
ANALYZEon green; planner statistics aren't carried over by a major upgrade. - Switch over in a low-traffic window; endpoints keep the same names, so apps just reconnect.
- Keep blue for a few days as a fallback.
Why → Upgrade and validation happen on a copy; the user-facing downtime is only the switchover.
Interview tip → Mention running ANALYZE after a major upgrade; skipping it causes slow queries the next morning.
More on Data and databases
A release needs to rename a column that the running app reads and writes. How do you do it with zero downtime?IntermediateHow do you prove your database backups actually work?IntermediateDesign backups for an RDS PostgreSQL database with RPO of 5 minutes and RTO of 1 hour, including a region failure.AdvancedYour migrations run in an init container and two pods ran them at the same time during a deploy, leaving the schema half-applied. How do you fix the approach?IntermediateYou need to add an index and a column to a 500-million-row table that's written to constantly. How do you avoid locking it?AdvancedUsers see stale data right after saving because reads go to a replica with lag. How do you handle it?Intermediate