DEV Community

deborah-Cat
deborah-Cat

Posted on

Need help ! Issue with Auto Scaling for Application Load Balancer with 2 different instances for target groups

What is your question/issue (provide as much detail as possible)?

Hi All, I currently have an Application Load Balancer that has two rules :

If the request is coming from a specific path Example: /test/, use a target group that points to an instance ( Let's say instance b ). For any other request use this target group ( another instance a ) In the autoscaling settings I have added these two target groups so that if autoscaling occurs and terminates the instances, they will be re-registered. This works correctly, however, I noticed that when termination happens the target group registers instance a where only instance b needs to be registered.

I do have 2 ASGs, one for the instance a and one for another instance b. However, I mostly use the main site Load balancer as the rules are located there ( if the path of /test/* it uses the instance b ( target group ). The reason this was set like this is that the instance b is accessed by the main site domain. ( For example www.example.com/test ) The desired count is set to 1.
Since I'm using the ALB of the main site only when the ASG terminates the instance, a new target is registered for the main site in the target group of the instance b. My issue is that this target group should only register one instance and not 2 ( instance a ( main site ) and instance b )

Would really appreciate some guidance, haven't received much from Re:post :(

What technologies are you using?

AWS, AutoScaling, EC2, ElasticBeanstalk

What were you expecting to happen?

When Autoscaling terminates the instance, the target group that has instance b registers, initiates another instance and places the same instance b and not another instance a.

What is actually happening?

When Autoscaling terminates the instance, the target group is adding another instance a and therefore the site breaks as the incorrect server is being shown.

What have you already tried/thought about?

Maybe having one autoscaling group for two different instances, however didn't manage. But there is still the issue of cannot control which instance is added to the target group when its terminated.

Top comments (1)

Collapse
 
helpbot profile image
Experimental Help Bot

It sounds like the issue you are experiencing is related to the way that your Application Load Balancer (ALB) and Auto Scaling groups (ASGs) are configured. From what you have described, it seems that you have set up your ALB to use two different target groups, one for requests with a specific path (e.g. /test/) and one for all other requests. You have also configured your ASGs to re-register instances with the ALB when they are terminated. However, when an instance is terminated, the ALB is registering the instance in the wrong target group, causing your website to break.

To resolve this issue, you may want to consider modifying your ALB rules to specify which target group to use based on the instance that is registered with the target group, rather than based on the path of the incoming request. This way, you can ensure that the correct instance is registered with the correct target group, and your website will not break when instances are terminated and re-registered with the ALB.

Alternatively, you could consider using a single target group for both instances, and using a different listener rule for each instance. This way, you can use the instance ID or other identifying information to determine which listener rule to use for each incoming request, and you can ensure that the correct instance is used to handle the request.

Overall, the key to resolving this issue is to carefully consider the configuration of your ALB and ASGs, and to ensure that they are set up in a way that will allow you to correctly register and use the appropriate instances to handle incoming requests.


I'm an experimental help bot that leverages ChatGPT. As such, the answers I provide may be incorrect, incomplete, or even nonsensical. I am not associated with OpenAI.

Please reply to my comment(s) with your own corrections and feedback.