RDS
AWS RDS
Managed Relational Database Service
Amazon RDS makes it easy to set up, operate, and scale relational databases in the cloud.
Supported Engines
| Engine | Versions | Use Case |
|---|---|---|
| MySQL | 5.7, 8.0 | General purpose |
| PostgreSQL | 11-16 | Complex queries, extensions |
| MariaDB | 10.4-10.11 | MySQL alternative |
| Oracle | 19c, 21c | Enterprise applications |
| SQL Server | 2016-2022 | Windows applications |
| Aurora | MySQL/PostgreSQL | High performance |
Key Concepts
DB Instances
The basic building block - an isolated database environment in the cloud.
Instance Classes
| Class | vCPUs | Memory | Use Case |
|---|---|---|---|
| db.t3.micro | 2 | 1 GB | Development |
| db.t3.medium | 2 | 4 GB | Small workloads |
| db.r5.large | 2 | 16 GB | Production |
| db.r5.xlarge | 4 | 32 GB | High memory |
Storage Types
| Type | Description | IOPS |
|---|---|---|
| gp3 | General Purpose SSD | 3,000-16,000 |
| io1/io2 | Provisioned IOPS SSD | Up to 256,000 |
| magnetic | Legacy HDD | Variable |
Multi-AZ Deployments
High availability with automatic failover:
Benefits:
- Automatic failover
- No data loss
- Increased durability
- Maintenance without downtime
Read Replicas
Scale read-heavy workloads:
Features:
- Up to 5 read replicas per DB
- Cross-region replication
- Can be promoted to standalone DB
Parameter Groups
Customize database configuration:
aws rds create-db-parameter-group \
--db-parameter-group-name my-params \
--db-parameter-group-family mysql8.0 \
--description "Custom MySQL parameters"Common Parameters:
max_connections- Maximum concurrent connectionsinnodb_buffer_pool_size- Memory for cachingslow_query_log- Enable slow query logging
Security
Encryption at Rest
aws rds create-db-instance \
--db-instance-identifier mydb \
--storage-encrypted \
--kms-key-id alias/my-keyNetwork Security
- VPC - Run in isolated network
- Security Groups - Control access
- Subnet Groups - Define subnets
Authentication
- Password - Traditional username/password
- IAM - Database authentication with IAM
- Kerberos - Active Directory integration
# Enable IAM authentication
aws rds modify-db-instance \
--db-instance-identifier mydb \
--enable-iam-database-authenticationBackups
Automated Backups
aws rds modify-db-instance \
--db-instance-identifier mydb \
--backup-retention-period 7 \
--preferred-backup-window "03:00-04:00"Manual Snapshots
aws rds create-db-snapshot \
--db-instance-identifier mydb \
--db-snapshot-identifier mydb-snapshotPoint-in-Time Recovery
Restore to any second within retention period:
aws rds restore-db-instance-to-point-in-time \
--source-db-instance-identifier mydb \
--target-db-instance-identifier mydb-restored \
--restore-time 2024-01-15T10:30:00ZMonitoring
CloudWatch Metrics
| Metric | Description |
|---|---|
| CPUUtilization | CPU usage percentage |
| FreeableMemory | Available RAM |
| ReadIOPS | Read operations/second |
| WriteIOPS | Write operations/second |
| DatabaseConnections | Active connections |
Enhanced Monitoring
Real-time OS metrics:
aws rds modify-db-instance \
--db-instance-identifier mydb \
--monitoring-interval 60 \
--monitoring-role-arn arn:aws:iam::123456789012:role/rds-monitoring-rolePerformance Insights
Analyze database load:
aws rds modify-db-instance \
--db-instance-identifier mydb \
--enable-performance-insights \
--performance-insights-retention-period 7Best Practices
Performance
- Choose appropriate instance class
- Use provisioned IOPS for consistent performance
- Enable read replicas for read-heavy workloads
- Optimize queries and indexes
Security
- Use VPC and security groups
- Enable encryption at rest
- Use SSL/TLS for connections
- Rotate credentials regularly
Cost Optimization
- Use Reserved Instances for predictable workloads
- Right-size instances based on metrics
- Delete unused snapshots
- Use Aurora Serverless for variable workloads
Consider Aurora for production workloads - it offers better performance, availability, and management features than standard RDS.