RDS Blue-Green Deployments let you perform major version upgrades on your database with zero downtime.

Imagine you have a production PostgreSQL database running on RDS, and you need to upgrade from version 13.4 to 14.2. This isn’t a trivial patch; it involves schema changes, new features, and potentially incompatible function calls. Traditionally, this would mean taking your application offline, performing the upgrade, and then bringing it back online, resulting in downtime. RDS Blue-Green Deployments sidestep this entirely.

Here’s how it works, using a concrete example. Let’s say your current production database is named my-prod-db.

  1. Create the Blue Environment: You initiate a blue-green deployment. RDS takes a snapshot of your my-prod-db, then creates a new, separate RDS instance from that snapshot. This new instance is provisioned with the target database version (14.2 in our example). This is your "green" environment. Crucially, it’s not yet connected to your application.

    aws rds create-db-instance-read-replica \
      --db-instance-identifier my-prod-db-green \
      --source-db-instance-identifier my-prod-db \
      --db-instance-class db.r5.large \
      --engine postgres \
      --engine-version 14.2 \
      --publicly-accessible # Or configure VPC security groups appropriately
    

    (Note: While create-db-instance-read-replica is often used for replicas, it’s the underlying mechanism for creating the initial green environment in a blue-green deployment context via the console or API. The actual blue-green functionality is managed separately when you initiate the swap.)

  2. Synchronize the Green Environment: RDS immediately sets up logical replication from your "blue" (production) instance to the "green" instance. This means any writes happening on my-prod-db are being continuously applied to my-prod-db-green. Your green environment is now a near real-time replica of your production database, but on the new version.

  3. Test the Green Environment: This is where you gain confidence. You can now connect your staging or testing environment to my-prod-db-green. Because it’s on the new version, you can run your application’s integration tests, performance benchmarks, and even simulate production load. You can verify that all your queries work, that new features are accessible, and that performance is acceptable. You can also manually inspect schema differences and run custom validation scripts.

    # Example of connecting to the green instance for testing
    psql -h my-prod-db-green.abcdef123456.us-east-1.rds.amazonaws.com -U admin -d mydb
    
  4. Initiate the Switchover: Once you’re satisfied with the green environment, you tell RDS to perform the switchover. This is the critical zero-downtime step.

    • RDS briefly pauses writes to the blue instance.
    • It waits for the green instance to catch up on any final transactions.
    • It then repoints the CNAME record (which your application uses to connect to the database) from the blue instance’s endpoint to the green instance’s endpoint.
    • The green instance is promoted to be the new production ("blue") instance.
    • The original blue instance becomes the new "green" environment, now running the old version, and is available for rollback if needed.

    This switchover typically takes less than a minute. Your application, by connecting via a DNS name, automatically starts hitting the new database instance without any manual intervention or application restarts.

  5. Post-Switchover: Your application is now running on the upgraded database version. The old production instance is kept around as a staging environment for a configurable period, allowing for a quick rollback if any unforeseen issues arise.

    You can then delete the old blue instance once you’re fully confident, or keep it as a read replica if desired.

The core problem this solves is the inherent risk and operational burden of performing major database upgrades. By creating an isolated, replicated copy and then performing a near-instantaneous DNS switchover, RDS Blue-Green Deployments eliminate the need for scheduled downtime windows for such critical maintenance. It also provides a robust rollback path by keeping the old environment available.

What most people don’t realize is that the replication mechanism used during the synchronization phase is logical replication, not physical. This allows for upgrades between different major versions (e.g., PostgreSQL 13 to 14) where physical replication might struggle with internal data structure changes. The switchover itself is also a carefully orchestrated DNS update combined with a brief write pause, not a full instance migration.

The next step after a successful blue-green deployment is often managing the lifecycle of the old environment, deciding whether to delete it or reconfigure it as a read replica.

Want structured learning?

Take the full Rds course →