Status check và CloudWatch alarm action: reboot, recover
Khi status check của EC2 instance thất bại, CloudWatch alarm có thể tự động reboot hoặc recover instance mà không cần thao tác thủ công.
Trang quản lý kho của MFTECH chạy trên một EC2 instance, quy mô chưa cần tới Auto Scaling group. Instance thỉnh thoảng gặp sự cố và việc khởi động lại thủ công ngoài giờ làm việc (ví dụ lúc 3h sáng) là không mong muốn. CloudWatch alarm có thể gọi trực tiếp bốn action của EC2: stop, terminate, reboot, recover, không cần Lambda hay script. Ngoài ra, với instance type được hỗ trợ, simplified automatic recovery được bật mặc định khi launch; CloudWatch action based recovery là cơ chế cấu hình thêm và không áp dụng cho instance thuộc Auto Scaling group.
EC2 có hai loại status check. Instance status check thất bại khi lỗi nằm bên trong instance (hệ điều hành bị treo, cạn bộ nhớ). System status check thất bại khi hạ tầng AWS mà instance chạy trên đó gặp sự cố (mất kết nối mạng, mất nguồn, lỗi phần cứng hoặc phần mềm trên host vật lý). Mỗi loại cần một action khác nhau:
Chọn một tình huống, bật hoặc tắt action, sau đó chọn Chạy alarm.
- Lỗi bên trong instance (instance status check): action reboot.
- Lỗi host (system status check): action recover, chỉ dùng với
StatusCheckFailed_System; instance có instance store chỉ được hỗ trợ ở một số instance type (M3, C3, R3, X1, X1e, X2idn, X2iedn) và dữ liệu trên instance store bị mất. - Recover giữ nguyên instance ID, public IPv4, private IP, Elastic IP, instance metadata, placement group, AZ và EBS volume; dữ liệu trong RAM bị mất.
- Alarm scale in với default termination policy: ASG chọn AZ có nhiều instance nhất, sau đó ưu tiên instance dùng cấu hình cũ (launch configuration, launch template khác, version cũ nhất của launch template hiện tại), tiếp theo là instance gần giờ tính phí tiếp theo nhất; mixed instances group còn xét purchase option và allocation strategy trước.
Status checks and CloudWatch alarm actions: reboot, recover
When an EC2 instance fails a status check, a CloudWatch alarm can reboot or recover the instance automatically, with no manual intervention.
MFTECH’s warehouse management page runs on one EC2 instance; its scale does not yet need an Auto Scaling group. The instance occasionally fails, and restarting it manually outside working hours (for example at 3:00 a.m.) is undesirable. A CloudWatch alarm can call four EC2 actions directly: stop, terminate, reboot, recover, with no Lambda or script. In addition, for supported instance types, simplified automatic recovery is enabled by default at launch; CloudWatch action based recovery is an additional mechanism you configure, and it does not apply to instances in an Auto Scaling group.
EC2 has two kinds of status checks. An instance status check fails when the problem is inside the instance (the operating system hangs, memory is exhausted). A system status check fails when the AWS infrastructure the instance runs on has a problem (loss of network connectivity, loss of power, hardware or software failure on the physical host). Each kind needs a different action:
Chọn một tình huống, bật hoặc tắt action, sau đó chọn Chạy alarm.
- Problem inside the instance (instance status check): reboot action.
- Host problem (system status check): recover action, used only with
StatusCheckFailed_System; instances with instance store are supported only on some instance types (M3, C3, R3, X1, X1e, X2idn, X2iedn), and the data on the instance store is lost. - Recover keeps the instance ID, public IPv4, private IP, Elastic IP, instance metadata, placement group, AZ and EBS volumes; data in RAM is lost.
- Scale-in alarm with the default termination policy: the ASG picks the AZ with the most instances, then prefers instances using an older configuration (launch configuration, a different launch template, the oldest version of the current launch template), then the instance closest to the next billing hour; a mixed instances group also considers purchase option and allocation strategy first.