Compute
D2 · Resilient
D3 · Performance
~1 phút đọcAuto Scaling Group & Elastic Load Balancing
ASG giúp co giãn compute tự động; ELB phân phối traffic. Biết chọn loại ELB và policy scaling theo use case là must.
asg
elb
alb
nlb
scaling
Sơ đồ tổng quan
Đang tải sơ đồ…
ASG core
- Thành phần: Launch Template, Min/Desired/Max, Health Check (EC2/ELB), Scaling Policies.
- Policies: Target Tracking (đơn giản, AWS giữ metric ≈ target), Step, Simple, Scheduled, Predictive.
- Lifecycle hooks để chèn logic trước `InService` hoặc trước `Terminating`.
- Warm Pool để giảm thời gian scale-out (instance pre-initialized).
- Mixed Instances Policy: combine On-Demand + Spot, nhiều loại instance để rẻ & linh hoạt.
ELB: chọn đúng loại
- ALB (Layer 7, HTTP/HTTPS/gRPC): path/host/header routing, WebSocket, HTTP/2, Lambda target, OIDC auth.
- NLB (Layer 4, TCP/UDP/TLS): cực nhanh, hỗ trợ static IP & EIP, giữ IP nguồn, hàng triệu request/s.
- GWLB: triển khai virtual appliance (firewall, IDS/IPS) dạng bump-in-the-wire.
- CLB: legacy, không nên dùng cho workload mới.
Info
Cần static IP hoặc whitelist IP firewall → NLB (hỗ trợ EIP). Routing theo URL path → ALB.
Sticky sessions
- ALB: duration-based cookie (AWSALB) hoặc application-based cookie.
- NLB: source IP affinity (ở connection level).
- Tránh sticky nếu có thể — stateless + external session store (ElastiCache/DynamoDB) tốt hơn.
Nội dung liên quan
Quiz liên quan
Flashcards liên quan