amazon-web-servicesamazon-ecsaws-application-load-balancerspot-instances

How to avoid ECS Spot instance termination while processing user requests?


I'm planning to run an ECS cluster with an ALB in front of spot instances.
As an example: A user's request enters a container that is running on spot, but before getting the response, the spot instance is terminated. That will return an error, right?

How can I resolve this type of issue?

Is there any way to stop sending requests before it was gone?


Solution

  • You can enable something called as ECS_ENABLE_SPOT_INSTANCE_DRAINING, it will change the instance to draining state and no new requests would come to this instance. The time frame is 2 minutes, if your requests will be longer then the user would get error.