Chương 20: Architecture Patterns
Tổng Quan
10 architecture patterns phổ biến nhất trong kỳ thi SAA-C03. Mỗi pattern có sơ đồ kiến trúc, giải thích components, và exam keywords để nhận diện nhanh.
1. 🌐 Classic 3-Tier Web Application
Sơ Đồ
Internet Users
│
▼
Amazon Route 53
│
▼
Amazon CloudFront
(CDN Cache)
│
┌──────────────┴──────────────┐
│ VPC (10.0.0.0/16) │
│ │
│ ┌──────────────────┐ │
│ │ Application LB │ │
│ └────────┬─────────┘ │
│ │ │
│ ┌────────┴────────┐ │
│ ▼ ▼ │
│ AZ-A AZ-B │
│ ┌──────┐ ┌──────┐ │
│ │ EC2 │ │ EC2 │ ← Web │
│ │(ASG) │ │(ASG) │ Tier │
│ └──┬───┘ └──┬───┘ │
│ │ │ │
│ ┌──▼───┐ ┌──▼───┐ │
│ │ EC2 │ │ EC2 │ ← App │
│ │(ASG) │ │(ASG) │ Tier │
│ └──┬───┘ └──┬───┘ │
│ └────┬─────┘ │
│ │ │
│ ElastiCache (Redis) │
│ │ │
│ ┌───────┴──────────┐ │
│ │ RDS Primary ◄──► Standby│ ← DB Tier
│ │ (AZ-A) (AZ-B) │ Multi-AZ
│ └──────────────────┘ │
└──────────────────────────────┘
Components & Vai trò
| Layer | Component | HA | Mục đích |
|---|---|---|---|
| Edge | CloudFront | Global | CDN, cache static content |
| DNS | Route 53 | Multi-region | DNS, health checks |
| LB | ALB | Multi-AZ | Distribute traffic, SSL |
| Web | EC2 ASG | Multi-AZ | Web servers, auto scale |
| App | EC2 ASG | Multi-AZ | Business logic, auto scale |
| Cache | ElastiCache | Multi-AZ | Session, query cache |
| DB | RDS Multi-AZ | Auto failover | Persistent data |
🎯 Exam Keywords
"web application" + "high availability" + "auto scaling" → Pattern này
2. ⚡ Serverless Web Application
Sơ Đồ
Users → Route 53 → CloudFront
│
┌──────────────┴──────────────┐
▼ ▼
S3 Bucket API Gateway
(Static Site) (REST API)
HTML/CSS/JS │
┌────────┴────────┐
▼ ▼
Lambda (Auth) Lambda (Logic)
│ │
▼ ▼
Cognito DynamoDB
(User Auth) (NoSQL Database)
│
▼
Lambda (Stream)
│
▼
SES (Email)
So sánh Chi phí
| Traditional (EC2) | Serverless | |
|---|---|---|
| Compute | 2 × t3.medium = $60/tháng | Lambda (1M req) = $0.20 |
| Database | RDS t3.small = $30/tháng | DynamoDB On-Demand = $1.25 |
| LB | ALB = $22/tháng | API Gateway = $3.50 |
| Hosting | EC2 serving | S3 = $1 |
| Tổng | ~$112/tháng (luôn chạy) | ~$6/tháng (pay per use) |
🎯 Exam Keywords
"serverless" + "no operational overhead" + "pay per use" → Pattern này
3. 🐳 Microservices với Containers
Sơ Đồ
Application Load Balancer
│
┌───────────────┼───────────────┐
▼ ▼ ▼
/api/users/* /api/orders/* /api/payment/*
Target Group 1 Target Group 2 Target Group 3
│ │ │
▼ ▼ ▼
ECS Service 1 ECS Service 2 ECS Service 3
(User) (Order) (Payment)
│ │ │
Fargate Tasks Fargate Tasks Fargate Tasks
│ │ │
▼ ▼ ▼
RDS DynamoDB SQS
(Users) (Orders) → Payment Queue
Communication Patterns
| Pattern | Cơ chế | Use case |
|---|---|---|
| Synchronous | Service A → ALB → Service B | Direct call, cần response ngay |
| Async (Queue) | Service A → SQS → Service B | Decoupled, retry tự động |
| Event (Pub/Sub) | Service A → SNS → Multiple Services | Fan-out, nhiều consumers |
ECS vs EKS
| Chọn ECS nếu | Chọn EKS nếu |
|---|---|
| AWS-native, đơn giản | Đã dùng Kubernetes |
| Tightly AWS integrated | Multi-cloud strategy |
| Không có K8s expertise | Complex orchestration |
🎯 Exam Keywords
"microservices" + "containers" + "independent scaling" → Pattern này
4. 🗄️ High Availability Database
RDS Multi-AZ
Application → RDS Endpoint (DNS auto-switch)
│
┌───────┴───────┐
▼ ▼
┌──────────┐ ┌──────────┐
│ Primary │◄─►│ Standby │ Synchronous
│ (AZ-A) │ │ (AZ-B) │ Replication
│ Active │ │ Passive │
└──────────┘ └──────────┘
Failover: 60-120 giây → DNS tự chuyển → App tự reconnect
Aurora Global Database
┌─── Primary Region (us-east-1) ──────────────┐
│ Writer ◄─► Read Replica × 2 │
│ Shared Storage (6 copies / 3 AZs) │
└──────────────────┬───────────────────────────┘
│ < 1 giây replication
┌──────────────────▼───────────────────────────┐
│ Secondary Region (eu-west-1) — Read Only │
│ Read Replicas × 3 │
│ Promote to Primary < 1 phút (DR) │
└──────────────────────────────────────────────┘
DynamoDB Global Tables
┌─ us-east-1 ─┐ ┌─ eu-west-1 ─┐
│ DynamoDB │◄────►│ DynamoDB │ Bi-directional
│ (R/W) │ │ (R/W) │ Active-Active
└──────┬──────┘ └──────┬──────┘
│ │
└────────┬────────────┘
▼
┌─ ap-southeast-1 ─┐
│ DynamoDB │
│ (R/W) │
└───────────────────┘
✅ < 1 giây replication ✅ Write anywhere ✅ Last-writer-wins
🎯 Exam Keywords
"automatic failover" → RDS Multi-AZ "cross-region DR, < 1 phút" → Aurora Global "multi-region active-active" → DynamoDB Global Tables
5. 🌉 Hybrid Cloud
┌─ On-Premises ───────────────────────────────────┐
│ Corporate Network ← → Customer Gateway │
└──────────┬──────────────────────┬────────────────┘
│ (Primary) │ (Backup)
│ Direct Connect │ VPN over Internet
│ 1/10 Gbps dedicated │ IPSec tunnel
│ │
┌──────────▼──────────────────────▼────────────────┐
│ AWS Cloud │
│ Virtual Private Gateway → Transit Gateway │
│ │ │
│ ┌──────────────────────┼──────────┐ │
│ ▼ ▼ ▼ │ │
│ VPC Prod VPC Dev VPC Test │ │
│ │ │
│ Storage Gateway → S3 → Glacier │ │
└───────────────────────────────────────────────────┘
| Direct Connect | VPN | Client VPN | |
|---|---|---|---|
| Bandwidth | 1/10/100 Gbps | ≤ 1.25 Gbps | ≤ 1 Gbps |
| Latency | Low, consistent | Variable | Variable |
| Setup | Weeks | Minutes | Minutes |
| Cost | $$$ | $ | $ |
| Use case | Production | Backup/DR | Remote workers |
🎯 Exam Keywords
"dedicated connection" → Direct Connect "encrypted, quick setup" → VPN "hybrid storage" → Storage Gateway
6. 🌍 Multi-Region DR
Active-Passive
┌─ PRIMARY (us-east-1) — ACTIVE ─┐
│ Route 53 → ALB → EC2 ASG │
│ ↓ │
│ RDS Primary │
└────────────────┬─────────────────┘
│ Cross-Region Replication
┌────────────────▼─────────────────┐
│ SECONDARY (eu-west-1) — PASSIVE │
│ Route 53 (Failover) │
│ ALB (Standby) │
│ EC2 ASG (Min=0) │
│ RDS Read Replica (→ promote) │
│ RTO: 5-15 min | RPO: 5 min │
└──────────────────────────────────┘
Active-Active
Route 53 (Latency/Geo Routing)
│ │
┌────────▼──────┐ ┌──────▼────────┐
│ us-east-1 │ │ eu-west-1 │
│ ⭐ ACTIVE │ │ ⭐ ACTIVE │
│ CloudFront │ │ CloudFront │
│ ALB → EC2 │ │ ALB → EC2 │
│ DynamoDB ◄──┼─┼──► DynamoDB │ Global Tables
│ S3 ◄─────────┼─┼────► S3 │ CRR
└───────────────┘ └───────────────┘
🎯 Exam Keywords
"survive region failure" → Multi-Region "failover routing" → Active-Passive "latency-based routing" → Active-Active
7. 🔄 Event-Driven Architecture
SQS Pattern (Async Processing)
API Gateway → Lambda (Producer) → SQS Queue → Lambda (Consumer) → DynamoDB
│
DLQ (Failed)
✅ Decoupled ✅ Auto retry ✅ Independent scaling
SNS Fan-Out Pattern
Event Source (S3, API)
│
SNS Topic
┌────┼────┐
▼ ▼ ▼
SQS 1 SQS 2 Lambda
↓ ↓ ↓
Service Service Email
A B (SES)
Use case: Order → update inventory + create shipment + send email
EventBridge Complex Routing
Events (AWS, SaaS, Custom)
│
EventBridge Bus
│
Event Rules
┌────────┼────────┐
▼ ▼ ▼
Lambda SNS Step Functions
(handler) (alert) (workflow)
🎯 Exam Keywords
"decouple" + "message queue" → SQS "fan-out" + "pub/sub" → SNS "event routing" + "rules" → EventBridge "workflow orchestration" → Step Functions
8. 📊 Data Analytics Pipeline
┌─ Data Sources ──────────────────────────────────────────┐
│ IoT │ Web │ Mobile │ APIs │ RDS │ DynamoDB │ On-Prem │
└──────┴─────┴────────┴──────┴─────┴──────────┴───┬──────┘
│
┌─────────────────────┤
▼ ▼
Kinesis Data Streams DataSync / DMS
(Real-time) (Batch)
│ │
┌───────────────┼──────────┐ │
▼ ▼ ▼ ▼
Lambda Firehose Analytics │
(Process) (Deliver) (SQL) │
│ │ │
▼ ▼ │
DynamoDB ┌──────┴──────┐ │
(Hot Data) ▼ ▼ │
S3 (Data Lake) OpenSearch │
│ │
▼ │
AWS Glue (ETL + Catalog) │
│ │
┌────────┼────────┐ │
▼ ▼ ▼ │
Athena Redshift EMR │
(Query S3) (Data WH) (Hadoop) │
│ │ │ │
└────────┼────────┘ │
▼ │
QuickSight (BI Dashboards) │
Chọn Analytics Service
| Nhu cầu | Service |
|---|---|
| Query S3 trực tiếp (serverless) | Athena |
| Data warehouse, complex queries | Redshift |
| Big data processing (Hadoop/Spark) | EMR |
| ETL + Data Catalog | AWS Glue |
| BI dashboards | QuickSight |
| Real-time streaming | Kinesis Data Streams |
| Deliver streaming data to S3 | Kinesis Data Firehose |
🎯 Exam Keywords
"query S3 with SQL" → Athena "data warehouse" → Redshift "ETL" → Glue "real-time streaming" → Kinesis Streams
9. 🔥 Disaster Recovery — 4 Strategies
Chi phí: $ ─────────────────────────────────── $$$$
RTO/RPO: Giờ ──────────────────────────────── Real-time
Backup & Pilot Warm Multi-Site
Restore Light Standby Active-Active
| Strategy | RTO | RPO | Mô tả |
|---|---|---|---|
| Backup & Restore | Giờ-Ngày | Giờ | Backup → S3, restore khi cần |
| Pilot Light | 10s phút | Phút | Core DB always running, scale up khi DR |
| Warm Standby | Phút | Giây | Scaled-down version always running |
| Multi-Site | Real-time | Near-zero | Full production ở cả 2 regions |
🎯 Exam Keywords
"lowest cost DR" → Backup & Restore "near-zero downtime" → Multi-Site "RPO minutes" → Pilot Light "RTO minutes" → Warm Standby
10. 🚀 Multi-Layer Caching
User Request
│
┌────▼─────────────────────┐
│ Layer 1: CloudFront │ ← Static content, TTL: hours-days
│ (600+ edge locations) │ Cache hit ratio: 80-90%
└────┬─────────────────────┘
│ Cache Miss
┌────▼─────────────────────┐
│ Layer 2: API Gateway │ ← API responses, TTL: seconds-minutes
│ (Per-stage cache) │ Cache hit ratio: 50-70%
└────┬─────────────────────┘
│ Cache Miss
┌────▼─────────────────────┐
│ Layer 3: ElastiCache │ ← DB queries, sessions, TTL: minutes
│ (Redis Multi-AZ) │ Cache hit ratio: 70-90%
└────┬─────────────────────┘
│ Cache Miss
┌────▼─────────────────────┐
│ Layer 4: DAX │ ← DynamoDB cache, TTL: seconds
│ (Microsecond latency) │ Cache hit ratio: 80-95%
└────┬─────────────────────┘
│ Cache Miss
┌────▼─────────────────────┐
│ Database (Source of Truth)│ ← RDS / DynamoDB / Aurora
└──────────────────────────┘
Caching Strategies
| Strategy | Flow | Ưu điểm | Nhược điểm |
|---|---|---|---|
| Cache-Aside | App → Cache (miss?) → DB → Write cache | Chỉ cache data cần | Stale data có thể |
| Write-Through | App → Cache → DB | Cache luôn fresh | Write latency cao |
| Write-Behind | App → Cache → (async) DB | Write nhanh | Risk mất data |
🎯 Exam Keywords
"reduce database load" → ElastiCache "cache DynamoDB" → DAX (microsecond) "cache static content globally" → CloudFront "cache API responses" → API Gateway caching
Exam Tips 💡
- Khi thấy "high availability web app" → nghĩ ngay Pattern 1 (3-Tier + Multi-AZ + ASG).
- "Serverless, no operational overhead" → Pattern 2 (Lambda + API GW + DynamoDB).
- "Decouple" → Pattern 7 (SQS/SNS/EventBridge).
- "Disaster recovery" → xác định RTO/RPO → chọn Pattern 9 tương ứng.
- "Reduce latency" → Pattern 10 (Multi-layer caching).
- "Migrate to cloud" → Pattern 5 (Hybrid) trước, rồi qua Cloud-native.
⬅️ Chương 19: Decision Trees & Keywords | Chương 21: Service Comparisons & Benchmarks ➡️