- Newest
- Most votes
- Most comments
Do you need the target group (TG) associated with the ASG (for example, are you using ELB healthchecks on the ASG?)
If not, you might be able to just not mention the TG on the ASG so that ASG doesn't deregister the instances; and instead only specify the TG on the CodeDeploy Deployment Group. I haven't tested the new CodeDeploy termination hook on ASG yet, but if that workflow doesn't deregister the instance, you could have that as a step in your CodeDeploy scripts. The only major concern I can think of with this option is if you're trying to deregister many instances at once, you might face ELB API throttling on the Deregister calls.
you can adjust your approach to handle scale-in events more effectively. ** 1.Detect Scale-In Events:** Implement a mechanism to detect when an instance is scheduled for termination due to a scale-in event triggered by the EC2 Auto Scaling group.
2.Pre-Drain Notification: Before the ELB starts draining connections from the instance, send a notification to the instance indicating that it will be deregistered from the ELB soon. This notification should give the instance enough time to gracefully handle existing WebSocket connections and inform clients to reconnect to other instances.
3.Handle Graceful Connection Closure: Upon receiving the pre-drain notification, your application running on the instance should start gracefully closing WebSocket connections. This involves informing connected clients to reconnect to other instances.
4.Update CodeDeploy Hooks: Adjust your BeforeBlockTraffic and BlockTraffic CodeDeploy hooks to account for the pre-drain notification. These hooks should wait for a shorter duration since the instance has already started gracefully closing connections.
**
5.Testing and Validation:** Thoroughly test your solution to ensure that WebSocket connections are gracefully handled during both deployment and scale-in events. Validate that clients can seamlessly reconnect to other instances without service interruption.
I appreciate your effort in answering the question, but without technical details the answer does not look complete.
- How can I detect an automatic scale-in event? Is there any mechanism to provide a hook for notifications that will be fired when the instance is chosen, not after as Autoscaling Group Lifecycle is finished draining the connections?
- How one can set up ELB to notify the instance about the upcoming connection draining? I don't see any related functionality in ELB documentation.
- That is what we already doing.
- That is what we already doing and it does not work for Autoscaling Group events as connection draining happens before the BeforeBlockTraffic, as I stated in the original question.
Relevant content
- Accepted Answerasked a year ago
- Accepted Answer
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
Thank you! I have removed link between ASG and ELB and now deregistration is part of CodeDeploy workflow