# EC2竞价实例终止通知：您的竞价实例'i-1234567890abcdef0'已终止，因为竞价价格超过了您愿意支付的最高价格。

- **ID:** `cloud/aws-ec2-spot-instance-termination`
- **领域:** cloud
- **类别:** runtime_error
- **错误码:** `SpotInstanceTermination`
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

竞价实例的出价低于当前竞价市场价格，导致AWS回收该实例。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| EC2 Spot Instances (all regions) | active | — | — |
| AWS CLI 2.13.0 | active | — | — |

## 解决方案

1. ```
   Use a Spot Fleet or EC2 Fleet with multiple instance types and bid prices. Example: `aws ec2 request-spot-fleet --spot-fleet-request-config file://config.json` where config.json includes diverse instance types (e.g., m5.large, c5.large) and a max bid equal to the On-Demand price. This increases chances of capacity availability.
   ```
2. ```
   Implement graceful shutdown handling. Use the EC2 metadata endpoint to check for termination notices (http://169.254.169.254/latest/meta-data/spot/termination-time) and save state before termination. Example script: `curl http://169.254.169.254/latest/meta-data/spot/termination-time 2>/dev/null && echo "Termination imminent"`
   ```

## 无效尝试

- **Increase the bid price to the On-Demand price** — Setting bid to On-Demand price defeats the purpose of Spot Instances and may still not guarantee persistence during high demand. AWS may still terminate if capacity is reclaimed. (60% 失败率)
- **Use a different instance type without changing bid** — Different instance types have different Spot markets; the same bid may still be too low for the new type. (70% 失败率)
