Trang chủ/Chương 21

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

EC2LambdaFargate
LoạiIaaS (VM)FaaS (Serverless)Serverless Containers
ScalingASG (manual setup)Tự độngTự động
Max runtimeUnlimited15 phútUnlimited
Cold startKhông100-1000ms~30s
PricingPer giờ/giâyPer request + durationPer vCPU+memory/giây
Min cost/tháng~$8 (t3.micro)$0 (1M free tier)~$10
StateStatefulStatelessStateful/Stateless
OS controlFullKhôngContainer
Use caseTraditional appsEvent-driven, ngắnContainers serverless

💡 Exam: "Serverless, <15 min" → Lambda. "Container, no server" → Fargate. "Full control" → EC2.

EC2 Instance Families Cheat Sheet

FamilyKý hiệuOptimized choVí dụ use case
T3T = BurstableWeb servers nhẹDev/test, small web
M5/M6iM = GeneralBalancedApp servers
C5/C6iC = ComputeCPU-intensiveVideo encoding, gaming
R5/R6iR = RAMMemoryIn-memory DB, analytics
I3/I4iI = I/OStorageNoSQL (Cassandra)
G4/P3G/P = GPUML/GraphicsML training, inference

Cách nhớ: Tiny → Medium → Compute → RAM → I/O → GPU

EC2 Pricing Comparison (t3.medium, us-east-1)

ModelGiá/thángTiết kiệmCommitment
On-Demand$30.370%Không
1-Year RI$18.2540%1 năm
3-Year RI$8.5472%3 năm
Spot~$9.1370%Có thể bị thu hồi

2. 💾 STORAGE

S3 Storage Classes — Quick Reference

ClassGiá/GBRetrievalMin DurationUse case
Standard$0.023InstantTruy cập thường xuyên
Intelligent-Tiering$0.023InstantKhông biết pattern
Standard-IA$0.0125Instant30 ngày1 lần/tháng
One Zone-IA$0.01Instant30 ngàyNon-critical
Glacier Instant$0.004Instant90 ngày1 lần/quý
Glacier Flexible$0.00361 phút-12 giờ90 ngày1 lần/năm
Glacier Deep Archive$0.0009912-48 giờ180 ngày7-10 năm

💡 Exam: "Infrequent + instant retrieval" → Standard-IA. "Cheapest archive" → Deep Archive.

EBS Volume Types

TypeMax IOPSMax ThroughputGiá/GBUse case
gp316,0001,000 MB/s$0.08Default choice
gp216,000250 MB/s$0.10Legacy
io2 Block Express256,0004,000 MB/s$0.125 + IOPSMission-critical DB
st1500500 MB/s$0.045Big data, throughput
sc1250250 MB/s$0.015Cold 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

EBSEFSS3Instance Store
TypeBlockFile (NFS)ObjectEphemeral block
AttachSingle EC2*Multiple EC2API/HTTPSingle EC2
AZSingle AZMulti-AZMulti-AZSingle instance
Max size64 TBUnlimitedUnlimitedVaries
Persist❌ (mất khi stop)
Giá$0.08-0.125/GB$0.30/GB$0.023/GBFree

*io2 Multi-Attach exception

💡 "Shared file across instances" → EFS. "Temporary high IOPS" → Instance Store.


3. 🗄️ DATABASE

RDS vs Aurora vs DynamoDB vs Redshift

RDSAuroraDynamoDBRedshift
TypeSQLSQL (5x faster)NoSQLData Warehouse
PerformanceStandard5x MySQLms latencyAnalytics optimized
Storage≤64 TB≤128 TB (auto)Unlimited≤8 PB
Read Replicas515Global TablesMulti-node
Failover60-120s<30sBuilt-inMulti-node
Serverless✅ On-Demand
Min cost~$30/month~$60/month~$1/month~$180/month
Use caseMigration SQLHigh-perf SQLMassive scale NoSQLAnalytics/BI

Multi-AZ vs Read Replicas (RDS)

Multi-AZRead Replicas
Mục đíchHA (failover)Read scaling
ReplicationSynchronousAsynchronous
Standby dùng đọc?❌ Không✅ Có
FailoverTự động (1-2 phút)Manual promote
Cross-Region
Chi phí2x instance1x / replica

💡 Combine cả hai: Multi-AZ (HA) + Read Replicas (scaling) = Best practice production.

Redis vs Memcached (ElastiCache)

RedisMemcached
Data typesStrings, Lists, Sets, Sorted Sets, HashesStrings 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

ALBNLBGWLB
Layer7 (HTTP/HTTPS)4 (TCP/UDP)3 (IP)
Latency~50-100ms<100μsLow
Static IP
Throughput~100K req/sMillions req/sHigh
Path routing
Lambda target
Use caseMicroservices, HTTPExtreme perf, TCP/UDP3rd-party appliances

💡 "HTTP/path routing" → ALB. "Static IP/TCP/UDP" → NLB. "Appliance" → GWLB.

CloudFront vs Global Accelerator

CloudFrontGlobal Accelerator
TypeCDN (caching)Network accelerator
Layer7 (HTTP)4 (TCP/UDP)
Caching
Static IP✅ (2 Anycast)
Best forStatic/dynamic contentNon-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 PeeringTransit GatewayVPNDirect Connect
Transitive
Max VPCs1-to-1Thousands
SetupMinutesMinutesMinutesWeeks
BandwidthNo limit50 Gbps≤1.25 Gbps1/10/100 Gbps
EncryptedOptional
CostLowMediumLowHigh

Route 53 Routing Policies — Khi nào dùng?

PolicyUse caseExam keyword
SimpleSingle resource"No special routing"
WeightedA/B testing, gradual migration"percentage traffic"
LatencyRoute to nearest region"lowest latency"
FailoverActive-passive DR"automatic failover"
GeolocationContent by location"based on user location"
Multi-ValueMultiple healthy IPs"return multiple records"

5. 🔒 SECURITY

CloudTrail vs CloudWatch vs Config

CloudTrailCloudWatchConfig
TracksAPI calls (who did what)Metrics & LogsResource config
PurposeAudit, complianceMonitoring, alarmsCompliance 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 ManagerParameter Store
Auto-rotation✅ (built-in)
Cost$0.40/secret/monthFree (standard)
Use caseDB credentials, API keysConfig values, feature flags
KMS encryption✅ Built-in✅ Optional

💡 "Auto-rotate credentials" → Secrets Manager. "Store config, free" → Parameter Store.

Security Groups vs NACLs

Security GroupsNACLs
LevelInstanceSubnet
StateStateful (return traffic auto)Stateless (need explicit rules)
Rules✅ ALLOW only✅ ALLOW + DENY
DefaultDeny all inboundAllow all
EvaluationAll rules evaluatedRules evaluated in order

💡 "Block IP" → NACL (Security Group KHÔNG CÓ DENY).


6. 📊 KEY PERFORMANCE NUMBERS

Lambda Cold Start by Runtime

RuntimeCold StartWarm Start
Go100-250ms1-5ms
Node.js150-300ms1-5ms
Python200-400ms1-5ms
.NET600-1000ms1-10ms
Java800-1500ms1-10ms

💡 Giảm cold start: dùng Provisioned Concurrency, small packages, Go/Node.js.

Lambda Limits (Must-Know)

LimitValue
Max execution time15 minutes
Memory128 MB - 10,240 MB
Package size50 MB (zip), 250 MB (unzip)
Concurrent executions1,000 (default, có thể tăng)
/tmp storage512 MB - 10,240 MB

Aurora vs RDS Performance

MetricRDS MySQLAurora MySQL
Read throughput10K QPS50K QPS (5x)
Replication lagSeconds<100ms (20x)
Failover time60-120s<30s (4x)
Max replicas515 (3x)
Max storage64 TB128 TB

DynamoDB Performance

DynamoDBDynamoDB + DAX
Read latency (p50)5-10 ms<1 ms
Read latency (p99)20 ms<2 ms
Cache hit ratio80-95%

S3 Request Rate

OperationRate/prefix
GET/HEAD5,500 req/sec
PUT/COPY/POST/DELETE3,500 req/sec
10 prefixes55K GET + 35K PUT
100 prefixes550K GET + 350K PUT

Load Balancer Comparison

ALBNLB
Throughput~100K req/secMillions req/sec
Latency50-100ms<100μs
Price$0.0225/hr$0.0225/hr

Exam Tips 💡

  1. gp3 > gp2 — luôn chọn gp3 trừ khi cần gp2 specific features.
  2. Aurora > RDS khi đề nói "high performance" hoặc "5x faster".
  3. DynamoDB + DAX khi cần microsecond latency.
  4. NLB khi cần static IP hoặc ultra-low latency TCP/UDP.
  5. NACL khi cần block IP (Security Group chỉ có ALLOW).
  6. Secrets Manager khi cần auto-rotate credentials.
  7. S3 Standard-IA cho "infrequent access + instant retrieval".
  8. CloudFront cho caching content, Global Accelerator cho TCP/UDP.

⬅️ Chương 20: Architecture Patterns | Chương 22: Practice Exam ➡️