RDS + Aurora + Elasticache Flashcards
RDS
Relational Database Service
Managed DB Service that uses SQL as a query language
RDS Storage AUto Scaling
Detects when you run out of free database storage, scales automatically
You have to set Maximum Storage Threshold
Useful for applications with unpredictable workloads.
RDS Read Replicas
Application performs reads and writes to Database instance, which sends read data to application.
Up to 15 read replicas
within AZ, cross AZ or cross Region.
Replication is asynchronous so reads are eventually consistent.
Replicas can be promoted to their own DB
Application must update the connection string to leverage read replicas.
Use Case: you have production database taking on normal load, but you want to run a reporting application. you create read replica to run the new workload there.
RDS Read Replicas- Network Cost
RDS read replicas within same region, you don’t pay that replication fee.
RDS
Multi AZ
For disaster recovery
Does not require you to change the SQL connection string
Sync Replication
One DNS name- automatic app failover to standby
Increases availability
Failover in case of loss of AZ, loss of network, instance or storage failure.
Not used for scaling.
Read replicas can be setup as Multi AZ for disaster recovery.
RDS from single-az to multi-az
zero downtime operation ( no need to stop DB)
just click on “modify” for the database and enable multi-AZ.
Amazon Aurora
Aurora is a proprietary technology from AWS (not opened source)
POstgres and MySql are both supported Aurora DB ( that means your drivers will work as if Aurora was a Postgres or MySql Database)
Aurora is “AWS cloud optimized” and claims 5x performance improvement over MySql on RDS, over 3x performance of Postgres on RDS
Aurora storage automatically grows in increments of 10GB up to 128 TB
Aurora can have up to 15 read replicas and the replication process is faster than MySQL
Failover in Aurora in instantaneous.
Auora costs more than RDS (20% more) but is more efficient.
Aurora High Availability and Read Scaling
6 copies of your data across 3 AZs
Shared Storage Volume: replication + self healing + auto expanding
It’s like multi-AZ for RDS. one instance takes writes (master)
automated failover for master in less than 30 seconds
Master + up to 15 aurora read replicas serve reads
Supports cross region replication
Aurora DB Cluster
Client talks to writer endpoint and redirected to right instance.
Then there is multiple read replicas. there is autoscaling. storage volume auto expands.
reader endpoint helps with connection load balancing and connects with all the multiple read replicas.
Load balancing happens at connection level not statement level.
Writer Endpoint
Cluster endpoint (or writer endpoint) for a DB cluster connects to the current primary DB instance for that DB cluster. Cluster endpoint is the only one that can perform write operations such as DDL statements as well as read operations.
Reader Endpoint
A reader endpoint for an Aurora DB cluster provides connection-balancing support for read-only connections to the DB cluster. Use the reader endpoint for read operations, such as queries. By processing those statements on the read-only Aurora Replicas, this endpoint reduces the overhead on the primary instance.
Custom Endpoints
A custom endpoint for an Aurora cluster represents a set of DB instances that you choose. When you connect to the endpoint, Aurora performs connection balancing and chooses one of the instances in the group to handle the connection. You define which instances this endpoint refers to, and you decide what purpose the endpoint serves.
use case: aurora instances with higher computing power, so you would want to query them for higher workloads.
Aurora Serverless
Automated Database instantiation and auto-scaling based on actual usage
good for infrequent, intermittent or unpredictable workloads.
no capacity planning needed
pay per second, can be more cost- effective
Global Aurora
Aurora Cross region read replicas
aurora global database (recommended): 1 primary region for (Read/write). up to 5 secondary (read only) regions, replication lag is less than 1 second. up to 16 read replicas per secondary region.
Typical cross-region replication takes less than 1 second.
You would like to ensure you have a replica of your database available in another AWS Region if a disaster happens to your main AWS Region. Which database do you recommend to implement this easily? use Aurora Global Database
Aurora Machine Learning
Enable you to add Machine learning based predictions to your applications via SQL
Supported services: sage maker and Amazon Comprehend.
Use cases: fraud detection, ads targeting, sentiment analysis, product recommendations.
RDS Backups
Automated Backups:
- Daily full backup of the database (during the backup window)
- Transaction logs are backed up by RDS every 5 minutes. ability to restore to any point in time from oldest backup to 5 minutes ago
- 1 to 35 days of retention, set 0 to disable automated backups.
Manual DB Snapshots:
- Manually triggered by the user.
- retention of backup for as long as you want.
Trick: in a stopped RDS database, you will still pay for storage. if you plan on stopping it for a long time, you should snapshot and restore instead.
Aurora Backups
Automated backups:
- 1 to 35 days (cannot be disabled)
- Point-in-time recovery in that timeframe.
Manual DB Snapshots
1. manually triggered by the user.
2. retention of backup for as long as you want. good for long-term backups for disaster recovery and audit purposes.
RDS and Aurora Restore Options
- Restoring a RDS/Aurora backup or a snpashot creates a new database.
- restoring Mysql rds database from S3.
- restoring my SQL aurora cluster from S3.
Aurora Database Cloning
create a new aurora DB cluster from an existing one.
use case: Your development team would like to perform a suite of read and write tests against your production Aurora database because they need access to production data as soon as possible.
RDS & Aurora Security
- At rest encryption: database master & replicas encryption using AWS KMS- must be defined at launch time.
If master is not encrypted the read replicas cannot be encrypted.
to encrypt an un-encrypted database, go through a DB snapshot and restore as encrypted.
- IN-Flight encrpytion: TLS-ready by default, use the AWS TLS root certificate client-side.
- IAM Authentication: IAM roles to connect to your database (instead of username/pw)
4.Security Groups: control network access to yoru RDS/ Aurora DB.
- No SSH available except on RDS Custom
5.Audit Logs can be enabled and sent to CloudWatch Logs for longer retention.
RDS Proxy
Allows apps to pool and share DB connections established with the database. *instead of every application connecting to DB instance, it connects to DB proxy and pools the connections together into less connections into RDS instance.
Makes a lot of sense if you have a lot of connections into your database instance.
Improves database efficiency by reducing the stress on database resources (e.g CPU, RAM) and minimizes connections.
serverless, autoscaling, highly available (multi-AZ)
Reduced RDS and Aurora failover time by 66%.
No code changes required for most apps. instead of connecting to RDS instance or Aurora Database, you connect to proxy and are done.
Enforce IAM authentication for DB, and securely store credentials in AWS Secrets Manager.
RDS Proxy is never publicly accessible (must be accessed from VPC)
Elasticache
The Same way RDS is to get managed relational dabases, elasticache is to get managed Redis or Memcached.
Caches are in-memory databases with really high performance, low latency.
helps reduce load off of databases for read intensive workloads.
helps make your application stateless, by putting state of application into Elasticache.
AWS takes care of OS maintenance/patching, optimizations, set up, configuration, monitoring, failure recovery and backups.
Using ElastiCache involved heavy application code changes.
ElastiCache Solution Architecture
Application queries ElastiCache to see if the query has already been made. if it has been made and is stored in ElastiCache it’s called a cache hit and get answers right from ElastiCache and saves trip to RDS to do the query.
If it is not stored in cache (cache miss) reads from DB and then for other applications or instances when query is made, we can write the data back into the cache, so next query results in cache hit.