What is RDS?

Amazon RDS (Relational Database Service) is a platform that manages databases.

What RDS handles:

  • Instance provisioning
  • Backups
  • Patching
  • Monitoring
  • Failover

Database Engines

Database software that runs on RDS. All use SQL but built by different organizations with different designs.

EngineBuilt byLicenseCharacteristics
MySQLOracle (originally Sun)Open source (GPL)Simple, fast, web-focused
PostgreSQLOpen source communityOpen sourceFeature-rich, standards-compliant
OracleOracle CorporationCommercial (paid)Enterprise, everything built-in

Auto Increment ID syntax differences:

-- MySQL
CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY);

-- PostgreSQL
CREATE TABLE users (id SERIAL PRIMARY KEY);

-- Oracle
CREATE SEQUENCE user_seq;
CREATE TABLE users (id NUMBER PRIMARY KEY);

What is Aurora?

Aurora is an AWS-built database engine that runs on the RDS platform.

┌─────────────────────────────────────────────────────┐
│  Amazon RDS (Platform)                              │
│                                                     │
│  ┌───────────┐ ┌───────────┐ ┌───────────┐         │
│  │  MySQL    │ │ PostgreSQL│ │  Oracle   │         │  ← Standard engines
│  └───────────┘ └───────────┘ └───────────┘         │
│                                                     │
│  ┌─────────────────────────────────────────┐       │
│  │  Aurora (MySQL-compatible)              │       │  ← AWS-built engine
│  │  Aurora (PostgreSQL-compatible)         │       │
│  └─────────────────────────────────────────┘       │
│                                                     │
│  Shared: Console, APIs, Events, CloudWatch, IAM    │
└─────────────────────────────────────────────────────┘

Aurora Endpoints

Aurora clusters have 4 types of endpoints.

EndpointPurposeDNS Pattern
Cluster (Writer)Connects to primary (read/write)[cluster].cluster-[region].rds.amazonaws.com
ReaderLoad-balances across replicas[cluster].cluster-ro-[region].rds.amazonaws.com
InstanceConnects to specific instance[instance].[region].rds.amazonaws.com
CustomUser-defined instance group[custom].cluster-custom-[region].rds.amazonaws.com
                    Aurora Cluster
                    ┌─────────────────────────────────────┐
                    │                                     │
Cluster Endpoint ───┼──► Primary Instance (Writer)        │
                    │         ▲                           │
                    │         │ failover                  │
                    │         ▼                           │
Reader Endpoint ────┼──► Replica 1 ◄─┐                    │
(load-balanced)     │    Replica 2 ◄─┼─ round-robin       │
                    │    Replica 3 ◄─┘                    │
                    └─────────────────────────────────────┘

Failover and Endpoints

The cluster endpoint DNS name stays the same during failover. Only the destination changes.

Before Failover:
cluster-endpoint.cluster-xxx.rds.amazonaws.com → Instance A (Primary)

After Failover:
cluster-endpoint.cluster-xxx.rds.amazonaws.com → Instance B (new Primary)

Applications can keep using the same connection string.

Note: Watch for DNS caching in your application. Aurora’s DNS TTL is 5 seconds, but your app’s resolver might cache longer.

Single-AZ vs Multi-AZ

Single-AZMulti-AZ
Instance locationAll in one AZSpread across 2+ AZs
AZ failureDatabase downFailover to another AZ
Failover timeN/A~30 seconds
CostLowerHigher
Single-AZ:
┌─────────────────────────────────┐
│  Availability Zone A            │
│  ┌─────────┐  ┌─────────┐       │
│  │ Primary │  │ Replica │       │
│  └─────────┘  └─────────┘       │
└─────────────────────────────────┘
     ↑ If AZ-A fails, everything fails

Multi-AZ:
┌─────────────────┐  ┌─────────────────┐
│  AZ-A           │  │  AZ-B           │
│  ┌─────────┐    │  │  ┌─────────┐    │
│  │ Primary │    │  │  │ Replica │    │
│  └─────────┘    │  │  └─────────┘    │
└─────────────────┘  └─────────────────┘
     ↑ If AZ-A fails, replica in AZ-B becomes primary

EBS Volume

EBS (Elastic Block Storage) is a storage service running on dedicated storage servers in AWS data centers.

┌─────────────────────────────────────────────────────────────────┐
│  AWS Data Center (one AZ)                                       │
│                                                                 │
│  Compute Servers              Storage Servers (EBS Service)     │
│  ┌──────────────┐             ┌──────────────────────────┐     │
│  │ EC2          │             │ EBS Storage Pool         │     │
│  │ Instance     │◄──network──►│                          │     │
│  │              │             │  ┌────────┐ ┌────────┐   │     │
│  └──────────────┘             │  │Your Vol│ │Other's │   │     │
│                               │  │100GB   │ │Vol     │   │     │
│                               │  └────────┘ └────────┘   │     │
│                               └──────────────────────────┘     │
└─────────────────────────────────────────────────────────────────┘

Key points:

  • EBS volume is outside the EC2 instance (network-attached)
  • Volume persists even if instance stops/terminates
  • Can only attach to instances in the same AZ

Standard RDS Storage Architecture

Standard RDS (MySQL, PostgreSQL, etc.) uses EBS volumes for storage.

Standard RDS:
┌──────────┐     ┌──────────┐
│ Instance │────►│ EBS Vol  │  ← Each instance has its own EBS
└──────────┘     └──────────┘

Aurora:
┌──────────┐     ┌─────────────────────────────┐
│ Instance │────►│ Shared Storage Layer        │
└──────────┘     │ (6 copies across 3 AZs)     │
┌──────────┐────►│                             │
│ Instance │     └─────────────────────────────┘
└──────────┘

Aurora’s storage is separate from compute - that’s why failover is faster (~30 sec vs ~60-120 sec for standard RDS).

Cross-Region Replication

Two ways to replicate Aurora across regions:

Cross-Region Read ReplicaAurora Global Database
Replication methodDatabase-level (logical)Storage-level (physical)
Typical lagSeconds to minutes<1 second
What’s replicatedTransaction logs (binlog/WAL)Storage blocks
Cross-region failoverManual promotion onlyManaged planned failover available

Cross-Region Read Replica

Primary DB engine sends transaction logs to replica. Replica DB engine parses and writes to its own storage.

us-east-1                              us-west-2
┌─────────────────────┐                ┌─────────────────────┐
│  Primary Cluster    │                │  Replica Cluster    │
│  ┌───────────┐      │   binlog/WAL   │  ┌───────────┐      │
│  │ DB Engine │──────┼───────────────►│  │ DB Engine │      │
│  └─────┬─────┘      │  (over internet)  └─────┬─────┘      │
│        │ read       │                │        │ write      │
│        ▼            │                │        ▼            │
│  ┌───────────┐      │                │  ┌───────────┐      │
│  │ Storage   │      │                │  │ Storage   │      │
│  │ (region A)│      │                │  │ (region B)│      │
│  └───────────┘      │                └───────────┘        │
└─────────────────────┘                └─────────────────────┘
      ↑                                       ↑
      └── Separate storage, not shared ───────┘

Promote replica to primary (manual):

aws rds promote-read-replica-db-cluster \
  --db-cluster-identifier my-replica-cluster \
  --region us-west-2

Aurora Global Database

Storage replicates directly to storage - DB engine not involved in replication.

us-east-1                              us-west-2
┌─────────────────────┐                ┌─────────────────────┐
│  ┌───────────┐      │                │  ┌───────────┐      │
│  │ DB Engine │      │                │  │ DB Engine │      │
│  └─────┬─────┘      │                │  └─────┬─────┘      │
└────────┼────────────┘                └────────┼────────────┘
         │                                      │
         ▼            storage-level             ▼
┌─────────────────────────────────────────────────────────────┐
│              Global Storage Layer                           │
│  ┌───────────┐    block replication    ┌───────────┐       │
│  │ Storage A │ ──────────────────────► │ Storage B │       │
│  └───────────┘       (<1 sec)          └───────────┘       │
└─────────────────────────────────────────────────────────────┘

Convert existing cluster to Global Database:

aws rds create-global-cluster \
  --global-cluster-identifier my-global-db \
  --source-db-cluster-identifier arn:aws:rds:us-east-1:123456789:cluster:my-existing-cluster

Add secondary region:

aws rds create-db-cluster \
  --db-cluster-identifier my-secondary-cluster \
  --global-cluster-identifier my-global-db \
  --engine aurora-mysql \
  --region us-west-2

Global Database Failover Options

TypeUse CaseData LossWhat Happens
Managed planned failoverDR drill, migrationNone (waits for sync)Roles swap, both stay connected
Detach and promoteEmergency (region down)PossibleSecondary becomes standalone, original abandoned

Important: Cross-region failover is always manually triggered - Aurora does NOT automatically failover across regions even with Global Database.

Detach secondary for emergency failover:

aws rds remove-from-global-cluster \
  --global-cluster-identifier my-global-db \
  --db-cluster-identifier arn:aws:rds:us-west-2:123456789:cluster:my-secondary \
  --region us-west-2

Initial Sync: Creation Differences

Cross-Region ReplicaGlobal Database Secondary
MethodSnapshot copy → restore → catch upStorage-level replication
SpeedSlower (full snapshot copy)Faster (incremental blocks)
DB engine involvedYesNo

Cross-Region Read Replica creation:

1. Take snapshot of primary
              ↓
2. Copy snapshot to target region (hours for large DBs)
              ↓
3. Restore snapshot as new cluster
              ↓
4. Start logical replication to catch up

us-east-1                              us-west-2
┌─────────────┐    snapshot copy       ┌─────────────┐
│  Primary    │ ─────────────────────► │  (restore)  │
│  100GB      │    (slow, full copy)   │  100GB      │
└─────────────┘                        └─────────────┘

Global Database secondary creation:

1. Add secondary region to Global Database
              ↓
2. Storage layer replicates blocks to new region
              ↓
3. Secondary reads from replicating storage

us-east-1                              us-west-2
┌─────────────┐                        ┌─────────────┐
│  Primary    │                        │  Secondary  │
└──────┬──────┘                        └──────┬──────┘
       │                                      │
       ▼         storage-level sync           ▼
┌─────────────────────────────────────────────────────┐
│  Storage A  ──────────────────────►  Storage B     │
│             (incremental, faster)                  │
└─────────────────────────────────────────────────────┘

Linux Filesystem Basics

Directory Path

/var/lib/mysql/data is a directory path (folder location in the filesystem).

Device Files

In Linux, disks appear as files under /dev/:

/dev/xvda  - first disk (usually OS disk)
/dev/xvdf  - another disk (could be EBS volume)

Mounting

Mounting = connecting a disk to a folder location. = Attach a remote file system to a local directory path, so it appears as local files.

Before mounting:
┌─────────────────┐     ┌─────────────────┐
│ Filesystem      │     │ EBS Volume      │
│                 │     │ /dev/xvdf       │
│ /var/lib/mysql/ │     │ (disconnected)  │
│ (empty folder)  │     │ [your data]     │
└─────────────────┘     └─────────────────┘

After mounting:
┌─────────────────┐     ┌─────────────────┐
│ Filesystem      │     │ EBS Volume      │
│                 │     │ /dev/xvdf       │
│ /var/lib/mysql/ │────►│ [your data]     │
│ (shows EBS data)│     │                 │
└─────────────────┘     └─────────────────┘

Mount command:

mount /dev/xvdf /var/lib/mysql

This says: “Make the contents of disk /dev/xvdf accessible at folder /var/lib/mysql

How Database Sees Storage

MySQL writes to:     /var/lib/mysql/data/mydb.ibd
                            ↓
OS knows:            /var/lib/mysql is mounted from /dev/xvdf
                            ↓
OS sends to:         /dev/xvdf (EBS device)
                            ↓
EBS driver:          Sends over network to EBS service

MySQL just sees a folder. It doesn’t know that folder is actually a network-attached EBS volume.

Notes

  • Aurora events can be detected via EventBridge (aws.rds source)
  • RDS-EVENT-0031 = running instance failed
  • RDS-EVENT-0013/0014 = failover started/completed
  • CloudWatch Alarms can detect “no data” for silent failures that don’t emit events