0

We have an application hosted on AWS elastic beanstalk, We are able to redirect from example.com to https://www.example.com successfully.

If my application has more load then auto scaling groups adds one more EC2 instance in back end to handle the load.

Let's say InstanceA is running and load got increased and InstanceB got added, When load gets normal auto scaling groups terminates one of the instance, currently in my application it is deleting old existing InstanceA, All our redirection rules are written on InstanceA so my application redirection fails when instance scales up.

Please help, Is there any option to hold my existing instance? or do we need to write same redirection rule for each instance which gets spin up?

ELB looks like below - enter image description here

RakeshKalwa
  • 411
  • 1
  • 3
  • 15
  • Are you modifying InstanceA after it's created? Why does InstanceA have the redirection rules only, and not InstanceB? – Matt Houser Jan 06 '18 at 17:01
  • Can you share more details of your infrastructure? For example, are you using Load Balancer? – Ele Jan 06 '18 at 21:25

2 Answers2

0

Even if you could control which instance is deleted when your ASG (Auto Scaling group) shrinks, it's not a good solution: your "InstanceA" may be deleted for other reasons (such as a failure with it's EBS volume, etc.)

You should not have the case where only "InstanceA" holds the redirection rules. The redirection rules should be on all instances.

Your problem is also not limited to when "InstanceA" gets deleted. When "InstanceB" is launched, users could be sent there first (thus satisfying your load balancing), and those redirection rules will need to be there.

You should never manually edit a single EC2 instance behind an ASG. All EC2 instances should be treated as temporary and deletable.

Your redirection rules should be applied to each EC2 instance as your application version is being deployed.

Matt Houser
  • 28,384
  • 5
  • 53
  • 70
  • Our Infrastructure - AWS ElasticBeanstalk with ELB and ASG rules associated with. – RakeshKalwa Jan 07 '18 at 15:53
  • Our Infrastructure - AWS ElasticBeanstalk with ELB and ASG rules associated with. Currently we are writing redirection rules manually in /etc/httpd/conf/httpd.conf file, Can you please guide me how to write same rules in ELB? Currently we are using linux machine with PHP application. – RakeshKalwa Jan 07 '18 at 16:00
  • Look at using `.ebextensions` files to customize the environment: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html – Matt Houser Jan 07 '18 at 17:37
  • Very specifically: https://stackoverflow.com/questions/14693852/how-to-force-https-on-elastic-beanstalk – Matt Houser Jan 07 '18 at 17:38
0

For scenarios like EC2 workers consuming SQS messages, EC2 workers for doing a lot of processing data, Etc., you go well with AutoScaling and nothing else.

Now, for your scenario definitely you need a Load Balancer along with AutoScaling and make any redirection against Load Balancer’s dns.

So, I recommend you to configure a Load Balancer in your Beanstalk’s environment to accomplish your scenario.

Hope it helps!

Ele
  • 31,191
  • 6
  • 31
  • 67