VISI

Databases (Detailed)

Amazon RDS:

  • Supports: PostgreSQL, MySQL, MariaDB, Oracle, SQL Server, IBM DB2, Aurora.
  • Managed: automated provisioning, OS patching, continuous backups, monitoring dashboards.
  • Automated backups: daily full backup + transaction logs every 5 minutes → Point-in-Time Restore. Retention 1-35 days.
  • Manual snapshots: retained until you delete. Useful for stopped DB (you still pay for storage; snapshot + delete is cheaper).
  • Read Replicas: up to 15. Async replication. For read scaling only (SELECT). Can be promoted. Cross-AZ read replicas within the same region = free (no network cost). Cross-region = charges apply.
  • Multi-AZ: Sync replication to standby. Automatic failover via DNS name change. NOT for read scaling. Zero-downtime conversion from Single-AZ to Multi-AZ.
  • RDS Custom: For Oracle and SQL Server. Access to underlying OS and DB. Can SSH/SSM into the instance.
  • RDS Storage Auto Scaling: Automatically scales when free storage < 10%, low storage > 5 min, 6 hours since last modification.

Amazon Aurora:

  • MySQL/PostgreSQL compatible. 5x MySQL performance, 3x PostgreSQL.
  • **Storage:**Aurora: Storage auto-grows in 10 GB increments, up to 256 TB. 6 copies across 3 AZs (4 needed for writes, 3 for reads). Self-healing with peer-to-peer replication.
  • Compute: 1 master (writes) + up to 15 read replicas. Failover < 30 seconds. Writer Endpoint + Reader Endpoint (with connection load balancing).
  • Custom Endpoints: define subset of replicas for specific workloads (e.g., analytics queries on larger instances).
  • Aurora Serverless: auto-scales compute based on usage. Good for infrequent/intermittent workloads. Pay per second.
  • Aurora Global Database: 1 primary region, up to 10 secondary read-only regions. Replication < 1 second. Promote secondary in < 1 minute (RTO). Cross-region replica lag < 1 second.
  • Aurora Multi-Master: multiple write nodes for continuous write availability.
  • Aurora Backtrack: restore to any point in time without using backups (undo operations).
  • Aurora Database Cloning: faster than snapshot/restore. Uses copy-on-write protocol. Great for staging environments.
  • Babelfish for Aurora PostgreSQL: understands T-SQL commands (MS SQL Server), allows MS SQL apps to work on Aurora PostgreSQL with no/minimal code changes.
  • Aurora Machine Learning: integrates with SageMaker and Comprehend for ML via SQL queries.

Amazon ElastiCache:

  • Managed Redis or Memcached. In-memory, sub-millisecond latency.

  • ElastiCache: Requires application code changes to use ElastiCache.

FeatureRedisMemcached
Multi-AZ / Failover
Read Replicas❌ (sharding)
Data Persistence (AOF)
Backup & RestoreServerless only
Sorted Sets / Sets
Multi-threaded
  • Caching Patterns:

    • Lazy Loading / Cache-Aside: Read from cache first; on miss, read from DB and write to cache. Can have stale data.
    • Write Through: Write to cache whenever writing to DB. No stale data but write overhead.
    • Session Store: Store temp session data with TTL.
  • Redis use case: Gaming leaderboards (Redis Sorted Sets guarantee unique ordering in real-time).

  • Security: Redis AUTH (password/token), SSL in-flight, IAM auth for Redis.

Amazon DynamoDB:

  • Fully managed NoSQL. Serverless, multi-AZ by default. Single-digit millisecond latency.
  • Structure: Tables → Items (rows) → Attributes. Max item size: 400 KB.
  • Primary Key: Partition Key (required) + optional Sort Key.
  • Capacity Modes:
    • Provisioned: Set RCUs + WCUs in advance. Can add auto-scaling.
    • On-Demand: Scales automatically, pay per request. More expensive. Good for unpredictable workloads.
  • DAX (DynamoDB Accelerator): In-memory cache purpose-built for DynamoDB. Microsecond latency. No application code changes needed. Default 5-minute TTL.
  • DynamoDB Streams: Ordered stream of item-level changes. 24-hour retention. Trigger Lambda on changes.
  • DynamoDB Global Tables: Active-active replication across regions. Must enable Streams first. Both read AND write in any region.
  • DynamoDB TTL: Automatically delete items after an expiry timestamp. For session management, temporary data.
  • Backups: PITR (up to 35 days), on-demand backups. Recovery creates a new table.
  • Export to S3: Within PITR window. Doesn't consume RCUs. Query with Athena.
  • Standard vs Infrequent Access table class — IA for lower storage cost, slightly higher reads.

Amazon Redshift:

  • OLAP (analytics/data warehousing), not OLTP. Based on PostgreSQL.
  • Columnar storage + parallel query engine. Up to 10x better than other DWs.
  • Cluster: Leader Node (query planning, aggregation) + Compute Nodes (execute queries).
  • Redshift Spectrum: Query data in S3 directly without loading it. Uses thousands of Redshift Spectrum nodes.
  • Loading data: Use COPY command from S3, Kinesis Data Firehose, or DMS. Large batch inserts are much better.
  • Snapshots: Automated (every 8h or 5GB) and manual. Can copy to another region.
  • Multi-AZ mode: Available for some cluster types.
  • vs Athena: Redshift faster for joins/aggregations/complex queries (uses indexes). Athena better for ad-hoc queries on S3.

Other Databases:

  • Amazon Neptune — graph DB. Social networks, recommendation engines, fraud detection, knowledge graphs. Highly available across 3 AZs, up to 15 replicas. Billions of relations, millisecond queries.
  • Amazon DocumentDB — MongoDB-compatible. Auto-grows in 10 GB increments. Millions of requests/sec.
  • Amazon Keyspaces — Apache Cassandra-compatible. Serverless. Single-digit millisecond latency. CQL. Use for IoT, time-series.
  • Amazon Timestream — time-series DB. Trillions of events/day. Stores recent data in memory, historical in cost-optimized storage.
  • Amazon QLDB — Quantum Ledger DB. Immutable ledger. Cryptographically verifiable journal. Not in scope for exam but worth knowing.

Database decision tree:

  • SQL/OLTP, joins → RDS or Aurora
  • NoSQL, key-value, millisecond latency at any scale → DynamoDB
  • In-memory cache → ElastiCache (Redis for features, Memcached for simple)
  • DynamoDB cache specifically → DAX
  • Analytics / OLAP / BI → Redshift
  • Ad-hoc S3 SQL queries → Athena
  • Graph → Neptune
  • MongoDB → DocumentDB
  • Cassandra → Keyspaces
  • Time-series → Timestream
  • Search (free text, partial match) → OpenSearch

References

Quiz

A few quick questions based on this unit. Mark it complete when you are done.

Question 1 / 3

What is Amazon Keyspaces?