Post

17. RDS

17. RDS

RDS (Relational Database Service)


Prerequisites


1. RDS

"aws-rds0"

Amazon RDS is a managed relational database service that allows you to run databases without managing infrastructure.

AWS automatically handles:

  • OS patching
  • Backup
  • Failover
  • Monitoring

1-1. Supported Engines

  • MySQL
  • PostgreSQL
  • MariaDB
  • Oracle
  • SQL Server
  • Amazon Aurora

1-2. Architecture (with EC2)

1
2
3
4
User
β†’ ALB
β†’ EC2 (Application Server)
β†’ RDS (Database)

πŸ‘‰ Users do NOT access RDS directly πŸ‘‰ Only EC2 communicates with RDS

1-3. Network Placement

1
2
3
4
5
6
Public Subnet:
- ALB

Private Subnet:
- EC2
- RDS

πŸ‘‰ RDS must be placed in a Private Subnet

1-4. Performance Factors

  • Instance size (CPU / RAM)
  • Storage IOPS
  • Number of connections
  • Query complexity

2. How to work RDS

ComponentRole
RDSManaged database
EndpointDatabase access point
Security GroupAccess control
Multi-AZHigh availability
Read ReplicaRead scaling

2-1. Connectivity Flow

Application β†’ Database
1
EC2 β†’ RDS Endpoint

Example:

1
mydb.abc123.ap-southeast-2.rds.amazonaws.com:3306
Protocol
  • MySQL β†’ TCP 3306
  • PostgreSQL β†’ TCP 5432

2-2. Routing (VPC Internal)

1
10.0.0.0/16 β†’ local

πŸ‘‰ Communication stays inside VPC

2-3. Security

RDS Security Group
1
2
3
Inbound:
Port: 3306
Source: EC2 Security Group
1
2
Outbound:
Allow all (default)
1
2
EC2 β†’ RDS βœ…
Internet β†’ RDS ❌

2-4. Multi-AZ

Single AZ
1
EC2 β†’ RDS (Primary)
Multi-AZ
1
2
3
Primary DB (AZ1)
↓ replication
Standby DB (AZ2)
Failover
1
2
Primary failure
β†’ Automatic switch to standby

3. How to create RDS

3-1. Search RDS

"aws-rds0"

3-2. Click Navigation pane β†’ β€œDashboard”

"aws-rds1"

3-3. Click Button β†’ β€œCreate”

"aws-rds2"

3-4. Create database

"aws-rds3" "aws-rds4"

3-5. Connect EC2

"aws-rds5" "aws-rds6"

3-6. Check Connection steps on EC2

"aws-rds7"

3-7. Connect RDS’s SQL on EC2

"aws-rds8"

3-8. Command SQL on EC2

"aws-rds9"

This post is licensed under CC BY 4.0 by the author.