RDS, Aurora & ElastiCache Flashcards
What relational databases does AWS support in the cloud?
Postgres, MySQL, MariaDB, Oracle, Microsoft SQL Server, Aurora
What does RDS stand for?
Relational Database Service
What is the advantage of using RDS versus deploying DB on EC2?
- Automated provisioning, OS patching
- Continuous backups and restore to specific timestamp (Point in Time Restore)
- Monitoring dashboards
- Read replicas for improved read performance
- Multi AZ setup for Disaster Recovery (DR)
- Maintenance windows for upgrades
- Scaling capability (vertical and horizontal)
- Storage backed by EBS (gp2 or io1)
What is the disadvantage of using RDS versus deploying DB on EC2?
Cannot SSH into your RDS instances.
What is Storage Auto Scaling?
RDS detects you are running out of free database storage and scales automatically according to your pre-determined Maximum Storage Threshold.
What are the conditions for Storage Auto Scaling to occur?
Storage will automatically scale if:
- Free storage is less than 10% of allocated storage
- Low-storage lasts at least 5 minutes
- 6 hours have passed since last modification
When is Storage Auto Scaling useful?
For applications with unpredictable workloads
What is an RDS Read Replica?
An instance replication of the main RDS DB instance that only allows reads.
What are some advantages of using Read Replicas?
- Allows the ability to scale the read capacity of the RDS DB instance
- Can scale the read capacity within AZ, Cross AZ or Cross Region
- Read replicas can be promoted to their own DB
What are some disadvantages of using Read Replicas?
- Replication is async, and so reads are eventually consistent
- Main application must update the connection string to leverage read replicas
What is a use case for read replicas?
Run reporting on an application to run some analytics without affecting production database load
- Create a Read Replica to run the new workload
State the main network cost considerations for RDS Read Replicas
(Typically there is a network cost when data goes from one AZ to another)
- If a Read Replica is within the same region as the main DB instance, there is no fee
- If the Read Replica is in a different region, you must pay for the cross-region async replication
Describe RDS Multi AZ - Disaster Recovery
- Sync replications
- One DNS name - automatic app failover to standby db instance
- Standby db instance cannot by read/written to, just there for failover
- Increase availability
- No manual intervention in apps
- Not used for scaling
When does Multi AZ (Disaster Recovery) occur?
RDS will failover in the case of loss of AZ, loss of network, instance or storage failure
Is there a possibility to have Read Replicas as Multi AZ for Disaster Recovery?
Yes, yes there is
Describe the transition of RDS from single to multi AZ
- Zero downtime operation (no need to stop DB)
- Click ‘modify’ for the database
How does RDS achieve zero downtime for transition from single-AZ to multi-AZ?
- RDS takes a snapshot of the DB automatically which will then be restored to the standby DB.
- Synchronization is established between the two databases to allow standby DB to catchup.
What is Multi-AZ deployment?
Specifies if the DB instance should have a standby deployed in another availability zone.
What Structured Languages does Aurora support?
Postgres and MySQL
What are the advantages of using Aurora?
- Shared Storage Volume automatically grows in increments of 10GB up to 128TB
- Can have 15 read replicas, with a faster replication process (sub 10ms replica lag)
- Failover in Aurora is instantaneous (High Availability native)
What is a possible downside of using Aurora?
- Proprietary technology from AWS (not open sourced)
- Costs more than RDS (20% more), but is more efficient
How does Aurora offer high availability and read scaling?
- 6 copies of data across 3 AZ
- 4 out of 6 needed for writes
- 3 out of 6 needed for reads
- Self healing with peer-to-peer replication
- Storage is striped across 100s of volumes
Describe the Aurora instance structure and failover contigency
- One Aurora Instance takes writes (master)
- Automated failover for master in less than 30 seconds
- Master + up to 15 read replicas serve reads
- Support for Cross Region Replication
Describe the Aurora instance structure and failover contigency
- One Aurora Instance takes writes (master)
- Automated failover for master in less than 30 seconds
- Master + up to 15 auto-scaling read replicas serve reads
- Support for Cross Region Replication
Describe the Aurora instance structure and failover contigency
- One Aurora Instance takes writes (master)
- Automated failover for master in less than 30 seconds
- Master + up to 15 read replicas serve reads
- Support for Cross Region Replication
Describe the Aurora DB Cluster structure
- A single Writer Endpoint which points to the master instance
- A single Reader Endpoint at which Connection Load Balancing occurs
- All read replicas point towards the Reader Endpoint so that the application does not have to manage changing connections due to auto-scaling
List the key features of auroras
- Automatic failover
- Backup and recovery
- Isolation and security
- Industry compliance
- Push button scaling
- Automated patching with zero downtime
- Advanced monitoring
- Routing maintenance
- Backtrack: restore data at any point of time without using backups
What types of encryption does RDS and Aurora offer?
At-rest and in-flight encryption
Describe At-rest encryption
- Database master and replicas encryption using AWS KMS (must be defined at launch time)
- If mater not encrypted, the replicas cannot be encrypted
- To encrypt an un-encrypted database, go through a DB snapshot and restore as encrypted
Describe In-Flight encryption
TLS-ready by default, use the AWS TLS root certificates client-side
How is connection and access to RDS and Aurora managed by AWS?
- IAM authentication: IAM roles to connect to your database (instead of username/pw)
- Security groups: Control network access to your db
Where is SSH access to RDS available?
Only if using RDS Custom
How would you retain and analyse your DB queries for RDS?
Audit Logs can be enabled and sent to CloudWatch Logs
What is a difficulty with using AWS ElastiCache?
Involves heavy application code changes for use (query cache before/after querying db)
What are two ElastiCache architectures?
- DB cache: standard hit/miss strategy to keep most current data available in the in-memory cache (requires invalidation strategy for out of date data)
- User Session Store: User logs in to application, causing session data to be written to cache; user hits another instance of application which retrieves the session data from the cache
Describe Redis
- Multi AZ with Auto-Failover
- Read replicas to scale reads and have high availability
- Data Durability using AOF (append only file - log of all write commands that can be re-run to restore state) persistence
- Backup and restore features
Describe Memcached
- Multi-node for partitioning of data (sharding)
- No high availability (no replication)
- Non persistent
- No backup and restore
- Multithreaded architecture
Describe the high-level difference of Redis vs Memcached
Redis is high availability with data persistence; memcached is not high availability with no backup but is distributed.
What is a risk of caching data?
Data may be out of date, eventually consistentWhat is a pattern for effective cahhing
What is a risk of caching data?
Data may be out of date, eventually consistent
What is a pattern where caching would be effective?
Slow changing data, few keys are frequently needed
What is an anti-pattern where caching would be ineffective?
Data changing rapidly, all large key space frequently needed
What are some examples of data structured well for caching?
Key value caching, or caching or aggregations results
Describe Lazy Loading, giving its other names
Cache-Aside/Lazy Population: Hit and miss caching
What are the pros of Lazy Loading?
- Only requested data is cached (so cache not filled with unused data)
- Node failures are not fatal, just increase latency to warm the cache
What are the cons of Lazy Loading?
- Cache miss penalty of 3 round trips causing a significant delay for the request
- Stale data: data can be updated in the database and outdated in the cache
Describe Write Through
Add or Update cache when database is updated
What are the pros of Write Through?
- Data in cache is never stale
- Reads are quick
- Write penalty instead of read penalty (2 calls per write) (this penalty is more expected from a user)
What are the cons of Write Through?
- Missing data until it is added/updated in the DB (can be mitigated by implementing lazy loading as well)
- Cache churn: a lot of the data will never be read (may be a problem if your cache is very small)
Describe three methods of Cache eviction
- Explicit deletion of an item from the cache
- Item is evicted because memory is full and it’s not recently used (LRU - least recently used)
- You set an item time-to-live (TTL)
When should you consider updating your cache size?
Too many evictions due to full cache memory
Describe ElastiCache Replication: Cluster Mode Disabled
- One primary node, up to 5 replicas
- Async replication
- Primary node is read/write, replicas are read-only
- One shard, all nodes have all data (guard against data loss if node failure)
- Multi-AZ enabled by default for failover
Describe ElastiCache Replication: Cluster Mode Enabled
- Data is partitioned across shards (helpful to scale writes)
- Each shard has a primary and up to 5 replicas
- Multi-AZ enabled by default for failover
- Up to 500 nodes per cluster (e.g. 500 shards with a single master, 250 shards with 1 master and 1 replica, 83 shards with one master and 5 replicas etc.)