Mục tiêu học tập
- Hiểu Aurora architecture đặc biệt (6 copies storage)
- Phân biệt Aurora Provisioned vs Serverless v2
- Nắm Aurora Global Database
- Biết Aurora endpoints và replication
1. Tổng quan Aurora
Amazon Aurora = relational database AWS proprietary, MySQL & PostgreSQL compatible.
Đặc điểm độc đáo
- Performance: 5x faster than MySQL, 3x faster than PostgreSQL (theo AWS)
- Storage: Auto-scaling 10 GB → 128 TB
- Replication: 6 copies of data across 3 AZs (built-in HA)
- Failover: < 30 giây (vs 1-2 phút RDS Multi-AZ)
- 15 read replicas (vs 5 cho RDS)
- Continuous backup to S3 (no perf impact)
- Database cloning (copy-on-write, instant)
Cost
- ~20% more expensive than RDS standard
- Trade-off: significantly better performance + features
2. Aurora Storage Architecture
6 copies across 3 AZs
Self-healing
- Continuous scanning, auto-repair corrupted blocks
- Tolerate loss of 2 copies (read) hoặc 3 copies (write)
- AZ failure → no data loss, no write disruption
Storage cluster volume
- Shared storage volume
- All compute instances (writer, readers) đọc cùng storage
- → Failover không cần copy data
3. Aurora Cluster Architecture
Components
- Writer (Primary) Instance: handle writes
- Reader Instances: serve reads, up to 15
- Shared Storage: replicated 6 copies
Failover
- Auto-promote reader → writer (< 30s)
- Failover priority: configurable per reader (tier 0-15, lower wins)
- DNS endpoint updates → app reconnects
4. Aurora Endpoints
4 loại endpoints
| Endpoint | Purpose |
|---|---|
| Cluster Endpoint (Writer) | Always points to primary, for write workload |
| Reader Endpoint | Load-balance reads across all reader instances |
| Custom Endpoint | Subset of instances (e.g., reporting subset) |
| Instance Endpoint | Specific instance (rarely used) |
Example
my-cluster.cluster-xxx.us-east-1.rds.amazonaws.com ← Writer
my-cluster.cluster-ro-xxx.us-east-1.rds.amazonaws.com ← Reader (LB)
my-cluster.cluster-custom-xxx.us-east-1.rds.amazonaws.com ← Custom
instance-1.xxx.us-east-1.rds.amazonaws.com ← Specific
5. Aurora Replication
Read Replicas (within Region)
- Auto-scale 0-15 replicas
- Async replication (sub-10ms lag typical)
- Same shared storage → faster than RDS read replica
- Reader endpoint load-balances
Aurora Global Database (Cross-region)
- 1 primary region + up to 5 secondary regions
- Sub-second replication lag (much better than CRR)
- Read-only replicas in secondary regions
- Disaster recovery: promote secondary → primary in < 1 minute (RTO)
- RPO < 1 second
Use case
- Multi-region applications
- DR with low RTO/RPO
- Read scaling globally
Aurora Global Database Architecture
Write Forwarding (Global Database)
- Reader instance in secondary region can forward writes to primary
- App treats secondary as local writer (with latency penalty)
- Use case: multi-region writes without app complexity
6. Aurora Serverless v2
Định nghĩa
Aurora Serverless v2 = on-demand auto-scaling Aurora, scale instantly từ 0 ACU đến 256 ACU.
Đặc điểm
- ACU (Aurora Capacity Unit): 2 GiB memory + CPU + networking
- Min: 0 ACU với auto-pause (từ 11/2024; trước đó min 0.5 ACU, không scale to zero)
- Max: configurable up to 256 ACU (nâng từ 128 cuối 2024)
- Scale in seconds (vs minutes cho Provisioned)
- Pay per ACU-hour consumed
v1 vs v2
| Aurora Serverless v1 | Aurora Serverless v2 | |
|---|---|---|
| Scale | Slow (minutes), pauses to 0 | Fast (seconds), scale to 0 với auto-pause (từ 11/2024) |
| Engine | MySQL 5.7, PostgreSQL 10 | MySQL 8, PostgreSQL 13+ |
| Read replicas | No | Yes (up to 15) |
| Multi-AZ | No | Yes |
| Status | Deprecated, removing | Current (recommended) |
Use case Serverless v2
- Unpredictable workload
- Intermittent traffic (dev/test, occasional spikes)
- Multi-tenant apps with variable load
- New app where size unknown
Use case Provisioned
- Predictable steady workload
- Cost-conscious (Reserved Instance discount)
7. Aurora Backup
Automated Backup
- Continuous backup to S3 (no impact on performance)
- Retention 1-35 days
- PITR to any second within retention
Manual Snapshots
- User-initiated, kept until deleted
- Cross-region copy
- Cross-account share
Database Cloning
- Copy-on-write clone of cluster
- Instant (no data copy initially)
- Storage diverges as clones change
- Use case: dev/test with prod data, what-if analysis
- Cost: only diverged blocks
8. Aurora Backtrack (MySQL-compatible only)
Định nghĩa
"Undo" cluster to previous point in time without restoring from backup.
Đặc điểm
- Max backtrack window: 72 hours
- Fast (no restore involved)
- In-place operation (no new cluster)
- Cost: $/hour of backtrack window enabled
Use case
- "Oops, I dropped wrong table" — backtrack 5 minutes
- A/B testing rollback
- Faster than restore from snapshot
9. Aurora Auto Scaling (Read Replicas)
Tính năng
- Auto-scale number of read replicas based on:
- Average CPU utilization
- Average connections
- Min/Max settings
Setup
Aurora Auto Scaling Policy:
Target Metric: AverageCPUUtilization
Target Value: 60%
Min Replicas: 1
Max Replicas: 8
10. Aurora Machine Learning Integration
Tính năng
- Aurora MySQL/PostgreSQL invoke SageMaker hoặc Comprehend from SQL
- Real-time inference in DB query
- Use case: fraud detection, sentiment analysis trong query
SELECT product, predict_fraud(product, user_id, amount)
FROM transactions;
11. Cost Comparison Examples
Single-AZ RDS MySQL db.r5.large (16 GB RAM)
- ~$0.24/hour = $176/month
Aurora MySQL db.r5.large (1 writer + 1 reader Multi-AZ)
- ~$0.29/hour × 2 = ~$420/month
- Storage: $0.10/GB-month (vs $0.115 for RDS gp3)
Aurora Serverless v2 (1-4 ACU average)
- ~$0.12/ACU-hour × 2 avg × 730 hrs = $175/month
- Pay only what you use
12. RDS vs Aurora Decision
Câu hỏi ôn tập
-
Aurora replicate data thành mấy copies, qua mấy AZ?
Xem đáp án
Aurora tự động replicate data thành 6 copies trên 3 AZs (2 copies/AZ). Write chỉ cần 4/6 copies acknowledge; read cần 3/6. Shared storage volume tự heal — nếu mất 2 copies vẫn có thể write, mất 3 copies vẫn có thể read. Đây là lý do Aurora có durability và availability cao hơn standard RDS Multi-AZ.
-
Aurora Global Database RTO khi failover là bao nhiêu?
Xem đáp án
< 1 phút (thường dưới 1 phút, không quá 1 phút). Aurora Global Database replication lag thường < 1 giây. Managed failover (promote secondary region thành primary): dưới 1 phút. Unplanned failover (primary region fail): khoảng 1 phút. So sánh: RDS Multi-AZ failover 60-120s, nhưng trong cùng Region.
-
Aurora Serverless v2 có scale to zero không?
Xem đáp án
Có — từ 11/2024, Aurora Serverless v2 hỗ trợ scale to 0 ACU với auto-pause (set min capacity = 0); resume tự động khi có connection (có cold start vài giây). Trước 11/2024, min là 0.5 ACU và không scale về 0 — đề thi/tài liệu cũ có thể vẫn ghi như vậy. Max hiện là 256 ACU. Aurora Serverless v1 (legacy, đã deprecated) cũng pause được về 0 nhưng scale chậm hơn nhiều.
-
Aurora Backtrack max window là bao lâu?
Xem đáp án
72 giờ (3 ngày) maximum backtrack window. Backtrack cho phép "rewind" Aurora cluster về bất kỳ thời điểm nào trong window đó — không cần restore snapshot (nhanh hơn nhiều, thường vài phút). Chỉ hỗ trợ MySQL-compatible Aurora, không phải PostgreSQL. Hữu ích khi phát hiện data corruption hoặc accidental delete trong vòng 72 giờ.
-
Khác biệt giữa Cluster Endpoint và Reader Endpoint?
Xem đáp án
Cluster Endpoint (Writer Endpoint): luôn trỏ đến primary instance — dùng cho write operations. Tự động failover sang primary mới khi có failover event. Reader Endpoint: load balance reads qua tất cả read replicas — dùng cho read-only queries. Không cần biết IP/hostname của từng replica. Aurora cũng cung cấp custom endpoints để route traffic đến subset replicas cho workloads cụ thể.
Bài tập thực hành
- Tạo Aurora MySQL cluster với 1 writer + 1 reader
- Test failover: force reboot writer, observe < 30s failover
- Tạo Aurora Serverless v2 cluster với 0.5-4 ACU, observe scaling
- Setup Aurora Global Database (1 primary region + 1 secondary)
- Test database cloning: clone production cluster, modify clone
- Backtrack cluster về 5 phút trước
Tài liệu tham khảo chính thức
- Amazon Aurora User Guide
- Aurora Global Database
- Aurora Serverless v2
- Aurora Backtrack
- Database Cloning
Tiếp theo: DynamoDB Basics