Aurora Replicas

Learn via video courses

Overview

Amazon Aurora is one of the relational database engines supported by Amazon RDS. Amazon Aurora is used to create Aurora DB Cluster, which comprises more than one DB instance and a cluster volume. The DB instances are subdivided into two categories, primary DB instances, and Aurora replicas. An amazon aurora DB Cluster needs at least one Primary DB instance. If there is more than one primary DB instance, then Aurora automatically creates replicas of the primary DB instance known as Aurora Replicas.

Introduction to Amazon Aurora

Before understanding Amazon Aurora, let's have a brief idea of Amazon Relation Database Service, also known as Amazon RDS.

What is Amazon RDS?

Amazon RDS is an AWS service that provides us with the comfort of working with relational databases easily on the cloud. It gives the facility to scale the relational databases easily when needed. It takes care of everyday database tasks like provisioning, patching, backup, recovery, failure detection, etc.

Amazon RDS Logo

Database Engines are software used by databases to carry out CRUD operations. Amazon RDS provides us with six different types of database engines to choose from.

  • Amazon Aurora
  • MySQL
  • PostgreSQL
  • MariaDB
  • Oracle database
  • Microsoft MySQL server

What is Amazon Aurora?

Amazon Aurora is a relational database that supports MySQL and PostgreSQL on the AWS cloud. It is five times faster than the standard MySQL database and three times faster than the PostgreSQL database. It offers security and reliability similar to other databases, with costs reduced to approximately one-tenth of the cost of the standard databases.

Amazon Aurora Logo

What is Amazon Aurora DB Cluster?

Amazon Aurora DB Cluster is a cluster/group comprising more than one database instance and a cluster volume that manages the DB instances. Aurora DB Cluster component can be spread across multiple availability zones. Because of this, the cluster volume, which is a virtual storage volume, is spread across multiple AZs. Each AZs contains a copy of the cluster volume, including the database's information.

There are primarily two kinds of databases which can be used to make the Aurora DB Cluster.

Primary DB Instance

  • Every Aurora Database cluster comprises at least one primary DB instance.
  • The primary instance supports read and write operations and a data modification feature.

Aurora Replica

  • If we have multiple primary DB instances in an Aurora Db cluster, Aurora automatically creates replicas of the prior DB instances, called Aurora Replicas.
  • Aurora replicas are replicas/copies of the primary DB instances. They support only read operations.
  • In addition to a primary DB instance, an Aurora database cluster can consist of up to 15 Aurora Replicas.
  • Aurora replicas are located in separate availability zones to ensure high availability.
  • In case the primary DB instance associated with the Aurora DB cluster fails, the entire service is handed over/managed via the Aurora replicas.

Steps to Set Up Amazon Aurora Replication

Let's look at the steps to create an Aurora DB Cluster and set up Amazon Aurora Replication.

Signing into AWS Console for Amazon RDS

  1. Sign in to the AWS Management Console and search for Amazon RDS. Click on the first option named RDS, which shows among the list of services.

Signing into AWS Console for Amazon RDS

We are redirected to another page for Amazon RDS. Here we have a list of options to navigate to.

Configuring The Amazon RDS Database

Let's create a new Database.

  1. Click on the dashboard option in the navigation panel. Scroll down the page and click on Create Database to create a new database.

Configuring The Amazon RDS Database

  1. You are redirected to another page. Here you need to fill in the details for your new database. From the list of engine options, choose Amazon Aurora, as we will create an Amazon Aurora database.

Configuring The Amazon RDS Database 2

  1. In the edition section, you are provided with two options. We will go with Amazon Aurora MySQL-Compatible Edition. You can select a version for the chosen edition.

Configuring The Amazon RDS Database 3

  1. Since we are creating this for demo purposes only, we will select the dev/test option from the Templates section. In addition, you also need to provide a name for your DB cluster. Here, we have used the name demand.

Configuring The Amazon RDS Database 4

  1. Give the administrator name and password to enjoy the admin privileges for the DB instances. Select the memory configurations for your DB instances.

Configuring The Amazon RDS Database 5

  1. Other options can be left as default. For availability, we have selected the option Don't create an Aurora Replica as we will create the replica later.

Configuring The Amazon RDS Database 6

  1. The additional Configuration section can be left as default; after filling in the details, we can click on Create Database.

Configuring The Amazon RDS Database 7

  1. The database gets created successfully, with a success message. The DB cluster status changes from Creating to Available.

Configuring The Amazon RDS Database 8

Configuring Actions to Set Up Amazon Aurora Replication Using Replicas

  1. Now, let's configure and set up a replica of the created DB instance as a reader instance. Select the DB cluster and click on the Actions button. Choose Add reader from the Actions menu.

Configuring Actions to Set Up Amazon Aurora Replication Using Replicas

  1. Select the source for the Aurora Replica and provide a name to identify the DB instance.

Configuring Actions to Set Up Amazon Aurora Replication Using Replicas 2

  1. Leave all the other fields as default and click on Add reader. It will create a replica of the DB instance as a reader in a different region.

Configuring Actions to Set Up Amazon Aurora Replication Using Replicas 3

  1. It will take some time to create the reader DB instance. After some time, the instance shows the Available status.

Configuring Actions to Set Up Amazon Aurora Replication Using Replicas 4

We have successfully set up the Amazon Aurora database and created a replica of the instance.

Replication with Aurora MySQL

We can replicate AWS Aurora database instances using Aurora MySQL apart from Aurora Replicas in AWS.

  • To replicate, we can create multiple Aurora MySQL database clusters in various AWS regions.
    • Aurora global database helps replicate data across different AWS regions.
    • MySQL binary log can also be used to create read replicas of Aurora Cluster.
  • We can also create two Aurora MySQL clusters in the same AWS regions by using binlog replication, also known as MySQL binary log.
  • We can use the MySQL DB instance as a source to create an Aurora read replica with Aurora MySQL. This process is often used to migrate to Aurora MySQL from MySQL DB instance.

Replication with Aurora PostgreSQL

We can also replicate AWS Aurora database instances using Aurora PostgreSQL apart from using Aurora Replicas in AWS.

  • Using an Aurora global database, we can run an Aurora primary DB cluster in one Region and up to five read-only secondary DB clusters in various Regions, as Aurora PostgreSQL does not support Cross-Region Aurora Replicas.
  • With the help of PostgreSQL's logical replication feature, two Aurora PostgreSQL DB clusters can be created in the same AWS region.
  • We can use the PostgreSQL DB instance as a source to create an Aurora read replica with the Aurora PostgreSQL DB cluster. This process is often used to migrate to Aurora PostgreSQL from the PostgreSQL DB instance.

Auto Scaling with Aurora Replicas

AWS provides us with the facility of auto-scaling the DB cluster with Aurora Replicas. Aurora Auto Scaling adjusted the number of replicas of the Aurora DB cluster in real time using master replication. It manages the sudden spike in connectivity or workload in the Aurora DB cluster.

When the workload reduces, Aurora Auto Scaling deletes the replica instances that are not required so newly provisioned DB instances won't experience any change. Similarly, When the workload or connectivity increases, it will automatically create the Aurora Replica. It can create up to 15 Aurora Replicas automatically.

We need to define and apply a scaling policy to apply the auto-scaling in the DB cluster. Let's create the auto-scaling policy for the previously created Aurora DB cluster.

Follow these steps:

  • Select the cluster and Click on Actions. Scroll down the Actions menu and click on Add replica auto scaling.

Auto Scaling with Aurora Replicas

  • Provide a policy name for the Auto Scaling policy.

Auto Scaling with Aurora Replicas 1

  • Set the target value and configure the minimum and the maximum number of Aurora Replicas. We can create a maximum of up to 15 Aurora Replicas. Click on Add policy to create the auto-scaling policy.

Auto Scaling with Aurora Replicas 2

We successfully create a policy for Aurora Auto Scaling. It supports Both Aurora MySQL and Aurora PostgreSQL.

Limitation of Using Aurora Replicas to Set Up Amazon Aurora Replication

There are some limitations to using Aurora Replicas in AWS for setting up Amazon Aurora Replication.

  • You need to be well acquainted and technically sound with the AWS environment and AWS Aurora for using Aurora Replicas in AWS.
  • Aurora replicas consume high bandwidth, which may lead to the slowing down of our applications.
  • You can create an encrypted Aurora replica for an encrypted AWS Aurora database cluster, but it is impossible to create an Aurora replica in encrypted form for an unencrypted AWS Aurora database cluster.
  • Similar to the above, creating an encrypted Aurora replica in AWS for an encrypted AWS Aurora database cluster is impossible.
  • In addition, Aurora replica is the only comfortable way to replicate instances in AWS to ensure the high availability of your data.

Conclusion

  • Amazon RDS supports using the relational database on top of AWS Cloud.
  • Amazon RDS provides six different database engines to choose from. Database engines are software used by AWS databases for performing CRUD operations.
  • Aurora DB cluster is created with the help of Amazon Aurora, one of the database engines Amazon RDS supports. The Aurora DB cluster comprises at least one primary database instance and other replicas of the primary DB instances. These replicas are Aurora replicas, and we can perform only read operations on this.
  • Apart from using Aurora Replicas, there are other ways of replication with Aurora MySQL and Aurora PostgreSQL.
  • Aurora replica cannot be created in encrypted form if the Aurora DB cluster is unencrypted and vice versa.