RDS Flashcards
RDS allows you to
create databases in the cloud that are managed by AWS
- Postgres
- MySQL
- MariaDB
- Oracle
- Microsoft SQL Server
- Aurora (AWS proprietary)
Advantages over using RDS versus deploying DB on EC2
- automated provisioning
- OS patches
- coninuous backups and restore to specific timestamp (Point in time restore)
- monitoring dashboards
- read replicas for improved read performance
- multi AZ setup for disaster recovery
- maintenance windows for upgrades
- scaling capability (vertical and horizontal)
- storage backed by EBS (GP2 or IO1)
what you can’t do with RDS as opposed to deploying DB on EC2
you can’t SSH into your instances
RDS Backups
- are automatically enabled in RDS
2. Automated backups and / or DB Snapshots
RDS Automated backups
- daily full backup for the database - during the maintenance window configured by user
- transaction logs are backed up by RDS every 5 minutes
- therefore you can restore to any point in time (from oldest backup to 5 mins ago)
- 7 days retention (can be increased to 35)
DB shapshots
- are manually triggered by user
2. retention of backup for as long as you want
if you want to speed up reads from your RDS DB instance
You can reduce the load on your primary DB instance by routing read queries from your applications to the read replica.
You can elastically scale out beyond the capacity constraints of a single DB instance for read-heavy database workloads.
RDS Read Replicas how many
up to 5 read replicas
RDS Read Replicas and AZ
can be
- within AZ
- cross AZ
- cross Region
Replication is
ASYNC, so reads are eventually consistent
Replica Lag
Each Read Replica publishes a Replica Lag metric in Amazon CloudWatch to allow you to see how far it has fallen behind the source DB Instance.
how to deal with eventual consistency
DO NOT send SELECT queries to a read slave if the data needs to be immediately available.
You should structure your application such that all real-time requests hit your master, and all other requests hit one of your read slaves.
For things where you don’t need real-time results, you can fool the user quite well using something like AJAX requests or websockets (websockets is going to make your application a lot more resource friendly as you won’t be hammering your backend servers with multiple AJAX requests).
why would you promote a replica to stand-alone DB?
You can use read replica promotion as a data recovery scheme if the primary DB instance fails.
But be aware of the ramifications and limitations of asynchronous replication.
To promote a replica for data recovery
- create a read replica and then monitor the primary DB instance for failures.
In the event of a failure, do the following:
- Promote the read replica.
- Direct database traffic to the promoted DB instance.
- Create a replacement read replica with the promoted DB instance as its source.
Replica traffic
The primary DB instance is the only copy of the database that can accept both read/write traffic; the read replica can only accept read-only traffic.
use case for RDS read replica
you have a production database taking on a normal load
you want to a reporting application to run some analytics
In order to avoid extra load on the main database, you create a read replica and run this new workload on it
Network costs
if your main database is in one AZ and your replica - in another one - there will be a network cost for ASYNC replication of the data. Because when the data is transfered between AZs - there is always a price to pay
So to reduce the costs we can place both the main DB and the replica in one AZ, then we are not charged for the transfer
RDS Mutli AZ purpose
disaster recovery in cases of
- loss of AZ
- loss of network
- instance or storage failure
increase availability
but NOT for scalability
RDS Mutli AZ one DNS name
we have a synchronous replica in another AZ. Automatic failover: App is automatically recovered from failure by redirecting traffic to the standby replica.
no manual intervention necessary
RDS Multi AZ and replicas
read replicas can be set up as Multi AZ for Disaster Recovery
2 types of RDS encryption
- at rest encryption
2. in-flight encryption