Creating a blue/green deployment - Amazon Relational Database Service

Creating a blue/green deployment

When you create a blue/green deployment, you specify the source DB instance to copy in the deployment. The DB instance you choose is the production DB instance, and it becomes the primary DB instance in the blue environment. This DB instance is copied to the green environment, and RDS configures replication from the DB instance in the blue environment to the DB instance in the green environment.

RDS copies the blue environment's topology to a staging area, along with its configured features. When the blue DB instance has read replicas, the read replicas are copied as read replicas of the green DB instance in the deployment. If the blue DB instance is a Multi-AZ DB instance deployment, then the green DB instance is created as a Multi-AZ DB instance deployment.

Preparing for a blue/green deployment

There are certain steps you must take before you create a blue/green deployment, depending on the engine that your DB instance is running.

Preparing an RDS for MySQL DB instance for a blue/green deployment

Before you create a blue/green deployment for an RDS for MySQL DB instance, you must enable automated backups. For instructions, see Enabling automated backups.

Preparing an RDS for PostgreSQL DB instance for a blue/green deployment

Before you create a blue/green deployment for an RDS for PostgreSQL DB instance, make sure to do the following:

  • Associate the instance with a custom DB parameter group with logical replication (rds.logical_replication) turned on. Logical replication is required for replication from the blue environment to the green environment. For instructions, see Modifying parameters in a DB parameter group.

    Because blue/green deployments require at least one background worker per database, make sure to tune the following configuration settings according to your workload. For instructions to tune each setting, see Configuration Settings in the PostgreSQL documentation.

    • max_replication_slots

    • max_wal_senders

    • max_logical_replication_workers

    • max_worker_processes

    After you enable logical replication and set all configuration options, make sure to reboot the DB instance so that your changes take effect. Blue/green deployments require that the DB instance be in sync with the DB parameter group, otherwise creation fails. For more information, see Rebooting a DB instance.

  • Make sure that your DB instance is running a version of RDS for PostgreSQL that's compatible with RDS Blue/Green Deployments. For a list of compatible versions, see Supported Regions and DB engines for Amazon RDS Blue/Green Deployments.

  • Confirm that the DB instance isn't the source or target of external replication. For more information, see General limitations for blue/green deployments.

  • Make sure that all tables in the DB instance have a primary key. PostgreSQL logical replication doesn't allow UPDATE or DELETE operations on tables that don't have a primary key.

  • If you're using triggers, make sure they don't interfere with the creating, updating, and dropping of pg_catalog.pg_publication, pg_catalog.pg_subscription, and pg_catalog.pg_replication_slots objects whose names start with 'rds'.

Specifying changes when creating a blue/green deployment

You can make the following changes to the DB instance in the green environment when you create the blue/green deployment.

You can make other modifications to the DB instance in the green environment after it is deployed. 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.

Specify a higher engine version

You can specify a higher engine version if you want to test a DB engine upgrade. Upon switchover, the database is upgraded to the major or minor DB engine version that you specify.

Specify a different DB parameter group

You can test how parameter changes affect the DB instances in the green environment or specify a parameter group for a new major DB engine version in the case of an upgrade.

If you specify a different DB parameter group, the specified DB parameter group is associated with all of the DB instances in the green environment. If you don't specify a different parameter group, each DB instance in the green environment is associated with the parameter group of its corresponding blue DB instance.

Enable RDS Optimized Writes

You can use Blue/Green Deployments to upgrade to a DB instance class that supports RDS Optimized Writes. You can only enable RDS Optimized Writes on a database that was created with a supported DB instance class. Thus, this option creates a green database that uses a supported DB instance class, which enables you to turn on RDS Optimized Writes on the green DB instance.

If you're upgrading from a DB instance class that doesn't support RDS Optimized Writes to one that does, you must also upgrade the storage configuration of the green DB instance. For more information, see Upgrade the storage configuration.

You can only upgrade the DB instance class of the primary green DB instance. By default, read replicas in the green environment inherit the DB instance settings from the blue environment. After the green environment is successfully created, you must manually modify the DB instance class of the read replicas in the green environment.

Some instance class upgrades aren't supported depending on the engine version and instance class of the blue DB instance. For more information about DB instance classes, see DB instance classes.

Upgrade the storage configuration

If your blue database isn't on the latest storage configuration, RDS can migrate the green DB instance from the older storage configuration (32-bit file system) to the preferred configuration. You can use RDS Blue/Green Deployments to overcome the scaling limitations on storage and file size for older 32-bit file systems. In addition, this setting changes the storage configuration to be compatible with RDS Optimized Writes if the specified DB instance class supports Optimized Writes.

Note

Upgrading the storage configuration is an I/O-intensive operation and leads to longer creation times for blue/green deployments. The storage upgrade process is faster if the blue DB instance uses Provisioned IOPS SSD (io1) storage, and if you provisoned the green environment with an instance size of 4xlarge or larger. Storage upgrades involving General Purpose SSD (gp2) storage can deplete your I/O credit balance, resulting in longer upgrade times. For more information, see Amazon RDS DB instance storage.

During the storage upgrade process, the database engine isn't available. If the storage consumption on your blue DB instance is greater than or equal to 90% of the allocated storage size, the storage upgrade process will increase the allocated storage size by 10% for the green instance.

This option is only available if your blue database is not on the latest storage configuration, or if you're changing the DB instance class within the same request. You can only upgrade the storage configuration when initially creating a blue/green deployment.

Handling lazy loading when you create a blue/green deployment

When you create a blue/green deployment, Amazon RDS creates the primary DB instance in the green environment by restoring from a DB snapshot. After it is created, the green DB instance continues to load data in the background, which is known as lazy loading. If the DB instance has read replicas, these are also created from DB snapshots and are subject to lazy loading.

If you access data that hasn't been loaded yet, the DB instance immediately downloads the requested data from Amazon S3, and then continues loading the rest of the data in the background. For more information, see Amazon EBS snapshots.

To help mitigate the effects of lazy loading on tables to which you require quick access, you can perform operations that involve full-table scans, such as SELECT *. This operation allows Amazon RDS to download all of the backed-up table data from S3.

If an application attempts to access data that isn't loaded, the application can encounter higher latency than normal while the data is loaded. This higher latency due to lazy loading could lead to poor performance for latency-sensitive workloads.

Important

If you switch over a blue/green deployment before data loading is complete, your application could experience performance issues due to high latency.

Creating a blue/green deployment

You can create a blue/green deployment using the AWS Management Console, the AWS CLI, or the RDS API.

To create a blue/green deployment
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Databases, and then choose the DB instance that you want to copy to a green environment.

  3. Choose Actions, Create Blue/Green Deployment.

    If you choose an RDS for PostgreSQL DB instance, review and acknowledge the logical replication limitations. For more information, see PostgreSQL logical replication limitations for blue/green deployments.

    The Create Blue/Green Deployment page appears.

    Create blue/green deployment
  4. Review the blue database identifiers. Make sure that they match the DB instances that you expect in the blue environment. If they don't, choose Cancel.

  5. For Blue/Green Deployment identifier, enter a name for your blue/green deployment.

  6. In the remaining sections, specify the settings for the green environment. For information about each setting, see Settings for creating blue/green deployments.

    You can make other modifications to the databases in the green environment after it is deployed.

  7. Choose Create staging environment.

To create a blue/green deployment using the AWS CLI, use the create-blue-green-deployment command. For information about each option, see Settings for creating blue/green deployments.

For Linux, macOS, or Unix:

aws rds create-blue-green-deployment \ --blue-green-deployment-name my-blue-green-deployment \ --source arn:aws:rds:us-east-2:123456789012:db:mydb1 \ --target-engine-version 8.0.31 \ --target-db-parameter-group-name mydbparametergroup

For Windows:

aws rds create-blue-green-deployment ^ --blue-green-deployment-name my-blue-green-deployment ^ --source arn:aws:rds:us-east-2:123456789012:db:mydb1 ^ --target-engine-version 8.0.31 ^ --target-db-parameter-group-name mydbparametergroup

To create a blue/green deployment by using the Amazon RDS API, use the CreateBlueGreenDeployment operation. For information about each option, see Settings for creating blue/green deployments.

Settings for creating blue/green deployments

The following table explains the settings that you can choose when you create a blue/green deployment. For more information about the AWS CLI options, see create-blue-green-deployment. For more information about the RDS API parameters, see CreateBlueGreenDeployment.

Console setting Setting description CLI option and RDS API parameter

Blue/Green Deployment identifier

A name for the blue/green deployment.

CLI option:

--blue-green-deployment-name

API parameter:

BlueGreenDeploymentName

Blue database identifier

The identifier of the instance that you want to copy to the green environment. When using the CLI or API, specify the instance Amazon Resource Name (ARN).

CLI option:

--source

API parameter:

Source

DB parameter group for green databases A parameter group to associate with the databases in the green environment.

CLI option:

--target-db-parameter-group-name

--target-db-cluster-parameter-group-name

API parameter:

TargetDBParameterGroupName

TargetDBClusterParameterGroupName

Enable Optimized Writes for green database

Enable RDS Optimized Writes on the green primary DB instance. For more information, see Enable RDS Optimized Writes.

If you're changing from a DB instance class that doesn't support Optimized Writes to one that does, you also need to perform a storage configuration upgrade. For more information, see Upgrade the storage configuration.

For the CLI and API, specifying a target DB instance class that supports RDS Optimized Writes automatically enables it on the green primary DB instance.

Engine version for green databases

Upgrade the databases in the green environment to the specified DB engine version.

If not specified, each database in the green environment is created with the same engine version as the corresponding DB instance in the blue environment.

CLI option:

--target-engine-version

RDS API parameter:

TargetEngineVersion

Green DB instance class

The compute and memory capacity of each DB instance in the green environment, for example db.m5d.xlarge.

This option is only visible when you enable RDS Optimized Writes for the green database.

CLI option:

--target-db-instance-class

RDS API parameter:

TargetDBInstanceClass

Storage configuration upgrade

Choose whether to upgrade your storage file system configuration. If you enable this setting, RDS migrates the green database from the old storage file system to the preferred configuration.

This option is only available if your blue database is not on the latest storage configuration, or if you're enabling RDS Optimized Writes within the same request. You can only upgrade the storage configuration when initially creating a blue/green deployment.

For more information, see Upgrading the storage file system for a DB instance.

CLI option:

--upgrade-target-storage-config

RDS API parameter:

UpgradeTargetStorageConfig