Overview of Amazon RDS Blue/Green Deployments
By using Amazon RDS Blue/Green Deployments, you can make and test database changes before implementing them in a production environment. A blue/green deployment creates a staging environment that copies the production environment. In a blue/green deployment, the blue environment is the current production environment. The green environment is the staging environment. The staging environment stays in sync with the current production environment using logical replication.
You can make changes to the RDS DB instances in the green environment without affecting production workloads. For example, you can upgrade the major or minor DB engine version, upgrade the underlying file system configuration, or change database parameters in the staging environment. You can thoroughly test changes in the green environment. When ready, you can switch over the environments to transition the green environment to be the new production environment. The switchover typically takes under a minute with no data loss and no need for application changes.
Because the green environment is a copy of the topology of the production environment, the green environment includes the features used by the DB instance. These features include the read replicas, the storage configuration, DB snapshots, automated backups, Performance Insights, and Enhanced Monitoring. If the blue DB instance is a Multi-AZ DB instance deployment, then the green DB instance is also a Multi-AZ DB instance deployment.
Note
Currently, Blue/Green Deployments are supported only for RDS for MariaDB, RDS for MySQL, and RDS for PostgreSQL. For Amazon Aurora availability, see Overview of Amazon Aurora Blue/Green Deployments in the Amazon Aurora User Guide.
Topics
Region and version availability
Feature availability and support varies across specific versions of each database engine, and across AWS Regions. For more information, see Supported Regions and DB engines for Amazon RDS Blue/Green Deployments.
Benefits of using Amazon RDS Blue/Green Deployments
By using Amazon RDS Blue/Green Deployments, you can stay current on security patches, improve database performance, and adopt newer database features with short, predictable downtime. Blue/green deployments reduce the risks and downtime for database updates, such as major or minor engine version upgrades.
Blue/green deployments provide the following benefits:
-
Easily create a production-ready staging environment.
-
Automatically replicate database changes from the production environment to the staging environment.
-
Test database changes in a safe staging environment without affecting the production environment.
-
Stay current with database patches and system updates.
-
Implement and test newer database features.
-
Switch over your staging environment to be the new production environment without changes to your application.
-
Safely switch over through the use of built-in switchover guardrails.
-
Eliminate data loss during switchover.
-
Switch over quickly, typically under a minute depending on your workload.
Workflow of a blue/green deployment
Complete the following major steps when you use a blue/green deployment for database updates.
-
Identify a production environment that requires updates.
For example, the production environment in this image has a Multi-AZ DB instance deployment (mydb1) and a read replica (mydb2).
-
Create the blue/green deployment. For instructions, see Creating a blue/green deployment.
The following image shows an example of a blue/green deployment of the production environment from step 1. While creating the blue/green deployment, RDS copies the complete topology and configuration of the primary DB instance to create the green environment. The copied DB instance names are appended with
-green-
. The staging environment in the image contains a Multi-AZ DB instance deployment (mydb1-green-random-characters
abc123
) and a read replica (mydb2-green-abc123
).When you create the blue/green deployment, you can upgrade your DB engine version and specify a different DB parameter group for the DB instances in the green environment. RDS also configures logical replication from the primary DB instance in the blue environment to the primary DB instance in the green environment.
After you create the blue/green deployment, the DB instance in the green environment is read-only by default.
-
Make additional changes to the staging environment, if required.
For example, you might make schema changes to your database or change the DB instance class used by one or more DB instances in the green environment.
For information about modifying a DB instance, see Modifying an Amazon RDS DB instance.
-
Test your staging environment.
During testing, we recommend that you keep your databases in the green environment read only. Enable write operations on the green environment with caution because they can result in replication conflicts. They can also result in unintended data in the production databases after switchover. To enable write operations for RDS for MySQL, set the
read_only
parameter to0
, then reboot the DB instance. For RDS for PostgreSQL, set thedefault_transaction_read_only
parameter tooff
at the session level. -
When ready, switch over to transition the staging environment to be the new production environment. For instructions, see Switching a blue/green deployment.
The switchover results in downtime. The downtime is usually under one minute, but it can be longer depending on your workload.
The following image shows the DB instances after the switchover.
After the switchover, the DB instances that were in the green environment become the new production DB instances. The names and endpoints in the current production environment are assigned to the newly switched over production environment, requiring no changes to your application. As a result, your production traffic now flows to the new production environment. The DB instances in the previous blue environment are renamed by appending
-old
to the current name, wheren
is a number. For example, assume the name of the DB instance in the blue environment isn
mydb1
. After switchover, the DB instance name might bemydb1-old1
.In the example in the image, the following changes occur during switchover:
-
The green environment Multi-AZ DB instance deployment named
mydb1-green-abc123
becomes the production Multi-AZ DB instance deployment namedmydb1
. -
The green environment read replica named
mydb2-green-abc123
becomes the production read replicamydb2
. -
The blue environment Multi-AZ DB instance deployment named
mydb1
becomesmydb1-old1
. -
The blue environment read replica named
mydb2
becomesmydb2-old1
.
-
-
If you no longer need a blue/green deployment, you can delete it. For instructions, see Deleting a blue/green deployment.
After switchover, the previous production environment isn't deleted so that you can use it for regression testing, if necessary.