Going into the exam
is going to be extremely important
to understand the difference between RDS Read Replicas
and Multi AZ and understand exactly the use cases for those.
So this lecture is really dedicated
to understanding Read Replicas and Multi AZ.
So let's get started with the Read Replicas.
Read Replicas as the name indicates
help you to scale your reads.
So let's have an example.
Here, we have our application
and we have an RDS database instance
and our application performs reads and writes
to our database instance,
but say we want to scale the reads
because that's, main database instance can not scale enough.
It receives too many requests.
Well, we can create up to five Read Replicas
and they can be within the same availability zone,
cross availability zone, or cross region.
So three different options
and they're very important to remember.
So say we have another RDS instance Read Replica
and another one and what will happen
is that they will be an asynchronous replication
between the main RDS database instance
and the two Read Replicas.
Asynchronous, that means that the reads
are eventually consistent.
What that means is that,
for example, if your application reads from the Read Replica
before they had the chance to replicate the data
then you may get all data.
And this is why it's called
eventually consistent asynchronous replication.
And these replicas, they can be awesome
for reading for scaling reads
but they can also be promoted to their own database.
So you can take one of these replicas
and say, okay I want it to be its own database now
and take rights.
And so you promote it to its own database.
It's completely out of the replication mechanism after that
but it's lives and has its own life cycle afterwards.
So in case you wanna use Read Replicas,
the main application in orange in the top of the screen
must update the connection string
to leverage the list of all the Read Replicas
you have in your RDS cluster.
Okay, very nice.
So let's talk about a classic use case
for you to Read Replica.
So in this example, we have a production database
and it is taking on normal load.
So here we go.
Our production database is having read and writes
to our main RDS database instance.
And the new team comes in and say,
we want to run some reporting
and some analytics on top of your data.
And so if you plug in that reporting application
onto the main RDS database instance
then it's going to overload it
and possibly slow down the production application
and you don't want that.
So instead what you do as a solutions architect
is you create a Read Replica to run the new workload there.
So you create a Read Replica.
There is some asynchronous, a replication
that happens between your main RDS DB database instance
and your Read Replica
and then your reporting application can just do reads
from your Read Replica and run the analytics there.
The production application is completely unaffected
in this case and that's perfect.
So remember, if you have a Read Replica
you need to ensure
that it is only for SELECT type of statements
and SELECT is a SQL keyword.
SELECT means read.
And so you can not use keywords
such as INSERT, UPDATE or DELETE,
which change database itself.
Okay, Read Replicas is only for reads.
So, let's talk about the networking cost
associated with RDS Read Replica.
So in AWS, you should know that's normally there is a cost
when the data goes from one availability zone to another
but there are exceptions
and these exceptions are usually for managed services.
So for RDS Read Replica, this is a managed service.
If your Read Replica is within the same region, okay?
Different AZ, but same region, you're not paying that fee.
So what this means that if you have a RDS DB instance
in us-east-1a and then a Read Replica in us-east-1b,
and there is asynchronous replication
because this is a Read Replica,
even though the traffic goes from one AZ to a different AZ
that replication traffic is going to be free
because RDS is a managed service
and they give you that traffic for free.
But if you are using a cross region replica,
so you are in one region, us-east-1
and you go to another region, eu-west-1, for example
then your RDS DB instance and your Read Replica
will have replication that will go across regions
and this will incur a replication fee for your network.
Finally, let's talk about RDS Multi AZ
and Multi AZ is mainly used for Disaster Recovery.
So we have our application
and it performs the reads and writes
to our Master database instance
which is in availability zone A
and what we thinks you have is a synchronous replication
to a standby instance in AZ B,
and they will replicate every single change
in the Master synchronously.
So that means that when your application writes
to the Master, that change needs to also be replicated
to the standby to be accepted.
And so what we get out of it is one DNS name.
So your application talks to one DNS name
and in case there is a problem with the Master,
there will be an automatic failover to the standby database.
Thanks to that one DNS name.
So thanks to this, we increase the availability.
This is why it's called Multi AZ and they will be failover
in case we lose an entire AZ or we lose the network
or there is an instance or storage failure
for the Master database.
In which case, obviously the standby database
will become the new Master.
He don't need to do any manual intervention in your apps
as long as it tries to keep on connecting
to your database automatically at some point,
it will fail over to the standby
that will be promoted as the Master, and you'll be good
and it's not used for scaling.
So as you can see here,
the standby database is just for standby.
No one can read to it.
No one can write to it, it's just here as a failover
in case anything goes on with your Master database.
So, quick question is, is there a possibility
to have the Read Replicas being set up as Multi AZ
for Disaster Recovery?
And the answer is yes, you can set up your Read Replica
as a Multi AZ if you want it to.
And that is a common exam question, okay?
So that's it for the difference between Read Replicates
and Multi AZ, but you need to absolutely understand this
going into the exam
because a lot of questions will go and be about it.
So a question that can come up in the exam
is around how do we make an RDS database
go from Single AZ to Multi AZ?
So what you should know
is that it is a zero downtime operation.
That means you do not need to stop the database
to go from Single AZ to Multi AZ.
The only thing you need to do
is to click on modify for the database
and enable Multi AZ.
That means that your RDS database instance
is going to go to have a Master,
to have a standby DB with synchronous replication
without you doing anything except modifying that setting
and the database will not stop.
Now, this is what the exam will ask you
but I wanna show you what will happen behind the scenes
for it to work.
So, the following will happen internally.
There will be a snapshot taken by RDS automatically
of your main database
and that this snapshot will be restored
into a new standby database, okay?
And then once the standby database is restored,
there will be synchronization established
between the two database
and so therefore the standby database
will catch up to the main RDS database and there you go,
you will be in a Multi AZ setup.
So that's it for this lecture.
I hope you liked it,
and I will see you in the next lecture.