Henrique Gontijo
Henrique Gontijo

Reputation: 1072

Implement scale in protection in AWS EC2 Spot fleet

We'd like to use Spot Fleet to manage our EC2 instances scaling that executes batch jobs. An aggressive scale in approach turns out to remove machines that are executing a job hence triggering the job recovery process that restart the jobs. The final result is the job taking more than expected time to finish. We also want an aggressive scale in policy for lowering the overall cost.

A possible solution is to have control how the instances are terminated (besides the price aspect). Even though Spot Fleet does not officially provide "scale in protection" similarly to ASG, is there any way around that?

Upvotes: 2

Views: 503

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 179314

You can programmatically request that the size of the group decrease through attrition -- decrease the group size and then when the instances terminate themselves, they won't be replaced -- by setting the excess capacity termination policy not to terminate instances that are, then, excess capacity.

you can request that the Spot fleet keep the fleet at its current size, but not replace any Spot instances that are interrupted or that you terminate manually.

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet-requests.html#modify-spot-fleet

Instances can terminate themselves internally without calling the API by telling the OS to power down the machine (e.g. sudo halt). Spot instances can't be in the Stopped state, so unlike the default behavior of on demand instances (the instance only stops), spot instances terminate on this action.

Upvotes: 2

Related Questions