Chương 21: Service Comparisons & Performance Benchmarks
Tổng Quan
Chương này tổng hợp bảng so sánh chi tiết giữa các dịch vụ AWS dễ nhầm lẫn, kèm số liệu performance và pricing thực tế giúp bạn chọn đáp án chính xác trong thi.
1. 🖥️ COMPUTE
EC2 vs Lambda vs Fargate
| EC2 | Lambda | Fargate |
|---|
| Loại | IaaS (VM) | FaaS (Serverless) | Serverless Containers |
| Scaling | ASG (manual setup) | Tự động | Tự động |
| Max runtime | Unlimited | 15 phút | Unlimited |
| Cold start | Không | 100-1000ms | ~30s |
| Pricing | Per giờ/giây | Per request + duration | Per vCPU+memory/giây |
| Min cost/tháng | ~$8 (t3.micro) | $0 (1M free tier) | ~$10 |
| State | Stateful | Stateless | Stateful/Stateless |
| OS control | Full | Không | Container |
| Use case | Traditional apps | Event-driven, ngắn | Containers serverless |
💡 Exam: "Serverless, <15 min" → Lambda. "Container, no server" → Fargate. "Full control" → EC2.
EC2 Instance Families Cheat Sheet
| Family | Ký hiệu | Optimized cho | Ví dụ use case |
|---|
| T3 | T = Burstable | Web servers nhẹ | Dev/test, small web |
| M5/M6i | M = General | Balanced | App servers |
| C5/C6i | C = Compute | CPU-intensive | Video encoding, gaming |
| R5/R6i | R = RAM | Memory | In-memory DB, analytics |
| I3/I4i | I = I/O | Storage | NoSQL (Cassandra) |
| G4/P3 | G/P = GPU | ML/Graphics | ML training, inference |
Cách nhớ: Tiny → Medium → Compute → RAM → I/O → GPU
EC2 Pricing Comparison (t3.medium, us-east-1)
| Model | Giá/tháng | Tiết kiệm | Commitment |
|---|
| On-Demand | $30.37 | 0% | Không |
| 1-Year RI | $18.25 | 40% | 1 năm |
| 3-Year RI | $8.54 | 72% | 3 năm |
| Spot | ~$9.13 | 70% | Có thể bị thu hồi |
2. 💾 STORAGE
S3 Storage Classes — Quick Reference
| Class | Giá/GB | Retrieval | Min Duration | Use case |
|---|
| Standard | $0.023 | Instant | — | Truy cập thường xuyên |
| Intelligent-Tiering | $0.023 | Instant | — | Không biết pattern |
| Standard-IA | $0.0125 | Instant | 30 ngày | 1 lần/tháng |
| One Zone-IA | $0.01 | Instant | 30 ngày | Non-critical |
| Glacier Instant | $0.004 | Instant | 90 ngày | 1 lần/quý |
| Glacier Flexible | $0.0036 | 1 phút-12 giờ | 90 ngày | 1 lần/năm |
| Glacier Deep Archive | $0.00099 | 12-48 giờ | 180 ngày | 7-10 năm |
💡 Exam: "Infrequent + instant retrieval" → Standard-IA. "Cheapest archive" → Deep Archive.
EBS Volume Types
| Type | Max IOPS | Max Throughput | Giá/GB | Use case |
|---|
| gp3 ✅ | 16,000 | 1,000 MB/s | $0.08 | Default choice |
| gp2 | 16,000 | 250 MB/s | $0.10 | Legacy |
| io2 Block Express | 256,000 | 4,000 MB/s | $0.125 + IOPS | Mission-critical DB |
| st1 | 500 | 500 MB/s | $0.045 | Big data, throughput |
| sc1 | 250 | 250 MB/s | $0.015 | Cold storage, rẻ nhất |
💡 Exam: ">16K IOPS" → io2. "General purpose" → gp3. "Throughput big data" → st1. "Cheapest" → sc1.
EBS vs EFS vs S3 vs Instance Store
| EBS | EFS | S3 | Instance Store |
|---|
| Type | Block | File (NFS) | Object | Ephemeral block |
| Attach | Single EC2* | Multiple EC2 | API/HTTP | Single EC2 |
| AZ | Single AZ | Multi-AZ | Multi-AZ | Single instance |
| Max size | 64 TB | Unlimited | Unlimited | Varies |
| Persist | ✅ | ✅ | ✅ | ❌ (mất khi stop) |
| Giá | $0.08-0.125/GB | $0.30/GB | $0.023/GB | Free |
*io2 Multi-Attach exception
💡 "Shared file across instances" → EFS. "Temporary high IOPS" → Instance Store.
3. 🗄️ DATABASE
RDS vs Aurora vs DynamoDB vs Redshift
| RDS | Aurora | DynamoDB | Redshift |
|---|
| Type | SQL | SQL (5x faster) | NoSQL | Data Warehouse |
| Performance | Standard | 5x MySQL | ms latency | Analytics optimized |
| Storage | ≤64 TB | ≤128 TB (auto) | Unlimited | ≤8 PB |
| Read Replicas | 5 | 15 | Global Tables | Multi-node |
| Failover | 60-120s | <30s | Built-in | Multi-node |
| Serverless | ❌ | ✅ | ✅ On-Demand | ✅ |
| Min cost | ~$30/month | ~$60/month | ~$1/month | ~$180/month |
| Use case | Migration SQL | High-perf SQL | Massive scale NoSQL | Analytics/BI |
Multi-AZ vs Read Replicas (RDS)
| Multi-AZ | Read Replicas |
|---|
| Mục đích | HA (failover) | Read scaling |
| Replication | Synchronous | Asynchronous |
| Standby dùng đọc? | ❌ Không | ✅ Có |
| Failover | Tự động (1-2 phút) | Manual promote |
| Cross-Region | ❌ | ✅ |
| Chi phí | 2x instance | 1x / replica |
💡 Combine cả hai: Multi-AZ (HA) + Read Replicas (scaling) = Best practice production.
Redis vs Memcached (ElastiCache)
| Redis | Memcached |
|---|
| Data types | Strings, Lists, Sets, Sorted Sets, Hashes | Strings only |
| Persistence | ✅ | ❌ |
| Multi-AZ / Replication | ✅ | ❌ |
| Backup | ✅ | ❌ |
| Pub/Sub | ✅ | ❌ |
| Multi-threading | ❌ (single) | ✅ (multi) |
| Performance | ~100K ops/sec | ~200K ops/sec |
💡 Mặc định chọn Redis trừ khi đề nói rõ "simple caching, multi-threaded".
4. 🌐 NETWORKING
ALB vs NLB vs GWLB
| ALB | NLB | GWLB |
|---|
| Layer | 7 (HTTP/HTTPS) | 4 (TCP/UDP) | 3 (IP) |
| Latency | ~50-100ms | <100μs | Low |
| Static IP | ❌ | ✅ | ✅ |
| Throughput | ~100K req/s | Millions req/s | High |
| Path routing | ✅ | ❌ | ❌ |
| Lambda target | ✅ | ❌ | ❌ |
| Use case | Microservices, HTTP | Extreme perf, TCP/UDP | 3rd-party appliances |
💡 "HTTP/path routing" → ALB. "Static IP/TCP/UDP" → NLB. "Appliance" → GWLB.
CloudFront vs Global Accelerator
| CloudFront | Global Accelerator |
|---|
| Type | CDN (caching) | Network accelerator |
| Layer | 7 (HTTP) | 4 (TCP/UDP) |
| Caching | ✅ | ❌ |
| Static IP | ❌ | ✅ (2 Anycast) |
| Best for | Static/dynamic content | Non-HTTP, gaming, VoIP |
💡 "Cache content globally" → CloudFront. "TCP/UDP + static IP globally" → Global Accelerator.
VPC Peering vs Transit Gateway vs VPN vs Direct Connect
| VPC Peering | Transit Gateway | VPN | Direct Connect |
|---|
| Transitive | ❌ | ✅ | — | — |
| Max VPCs | 1-to-1 | Thousands | — | — |
| Setup | Minutes | Minutes | Minutes | Weeks |
| Bandwidth | No limit | 50 Gbps | ≤1.25 Gbps | 1/10/100 Gbps |
| Encrypted | ❌ | Optional | ✅ | ❌ |
| Cost | Low | Medium | Low | High |
Route 53 Routing Policies — Khi nào dùng?
| Policy | Use case | Exam keyword |
|---|
| Simple | Single resource | "No special routing" |
| Weighted | A/B testing, gradual migration | "percentage traffic" |
| Latency | Route to nearest region | "lowest latency" |
| Failover | Active-passive DR | "automatic failover" |
| Geolocation | Content by location | "based on user location" |
| Multi-Value | Multiple healthy IPs | "return multiple records" |
5. 🔒 SECURITY
CloudTrail vs CloudWatch vs Config
| CloudTrail | CloudWatch | Config |
|---|
| Tracks | API calls (who did what) | Metrics & Logs | Resource config |
| Purpose | Audit, compliance | Monitoring, alarms | Compliance rules |
| Example | "Who deleted S3 bucket?" | "CPU > 80% alarm" | "All S3 encrypted?" |
💡 "Audit API" → CloudTrail. "Metrics/alarms" → CloudWatch. "Compliance check" → Config.
Secrets Manager vs Parameter Store
| Secrets Manager | Parameter Store |
|---|
| Auto-rotation | ✅ (built-in) | ❌ |
| Cost | $0.40/secret/month | Free (standard) |
| Use case | DB credentials, API keys | Config values, feature flags |
| KMS encryption | ✅ Built-in | ✅ Optional |
💡 "Auto-rotate credentials" → Secrets Manager. "Store config, free" → Parameter Store.
Security Groups vs NACLs
| Security Groups | NACLs |
|---|
| Level | Instance | Subnet |
| State | Stateful (return traffic auto) | Stateless (need explicit rules) |
| Rules | ✅ ALLOW only | ✅ ALLOW + DENY |
| Default | Deny all inbound | Allow all |
| Evaluation | All rules evaluated | Rules evaluated in order |
💡 "Block IP" → NACL (Security Group KHÔNG CÓ DENY).
6. 📊 KEY PERFORMANCE NUMBERS
Lambda Cold Start by Runtime
| Runtime | Cold Start | Warm Start |
|---|
| Go | 100-250ms | 1-5ms |
| Node.js | 150-300ms | 1-5ms |
| Python | 200-400ms | 1-5ms |
| .NET | 600-1000ms | 1-10ms |
| Java | 800-1500ms | 1-10ms |
💡 Giảm cold start: dùng Provisioned Concurrency, small packages, Go/Node.js.
Lambda Limits (Must-Know)
| Limit | Value |
|---|
| Max execution time | 15 minutes |
| Memory | 128 MB - 10,240 MB |
| Package size | 50 MB (zip), 250 MB (unzip) |
| Concurrent executions | 1,000 (default, có thể tăng) |
| /tmp storage | 512 MB - 10,240 MB |
Aurora vs RDS Performance
| Metric | RDS MySQL | Aurora MySQL |
|---|
| Read throughput | 10K QPS | 50K QPS (5x) |
| Replication lag | Seconds | <100ms (20x) |
| Failover time | 60-120s | <30s (4x) |
| Max replicas | 5 | 15 (3x) |
| Max storage | 64 TB | 128 TB |
DynamoDB Performance
| DynamoDB | DynamoDB + DAX |
|---|
| Read latency (p50) | 5-10 ms | <1 ms |
| Read latency (p99) | 20 ms | <2 ms |
| Cache hit ratio | — | 80-95% |
S3 Request Rate
| Operation | Rate/prefix |
|---|
| GET/HEAD | 5,500 req/sec |
| PUT/COPY/POST/DELETE | 3,500 req/sec |
| 10 prefixes | 55K GET + 35K PUT |
| 100 prefixes | 550K GET + 350K PUT |
Load Balancer Comparison
| ALB | NLB |
|---|
| Throughput | ~100K req/sec | Millions req/sec |
| Latency | 50-100ms | <100μs |
| Price | $0.0225/hr | $0.0225/hr |
Exam Tips 💡
- gp3 > gp2 — luôn chọn gp3 trừ khi cần gp2 specific features.
- Aurora > RDS khi đề nói "high performance" hoặc "5x faster".
- DynamoDB + DAX khi cần microsecond latency.
- NLB khi cần static IP hoặc ultra-low latency TCP/UDP.
- NACL khi cần block IP (Security Group chỉ có ALLOW).
- Secrets Manager khi cần auto-rotate credentials.
- S3 Standard-IA cho "infrequent access + instant retrieval".
- CloudFront cho caching content, Global Accelerator cho TCP/UDP.
⬅️ Chương 20: Architecture Patterns | Chương 22: Practice Exam ➡️