Does it make sense to have an Amazon Elastic Load Balancer with just one EC2 instance?

Amazon Web-ServicesAmazon Ec2Amazon ElbAmazon Route53

Amazon Web-Services Problem Overview


my question is simple. Does it make sense to have an Amazon Elastic Load Balancer (ELB) with just one EC2 instance?

If I understood right, ELB will switch traffic between EC2 instances. However, I have just one EC2 instance. So, does it make sense?

On the other hand, I´m using Route 53 to route my domain requests domain.com, and www.domain.com to my ELB, and I don´t see how to redirect directly to my EC2 instance. So, do I need an ELB for routing purposes?

Amazon Web-Services Solutions


Solution 1 - Amazon Web-Services

Using an Elastic Load Balancer with a single instance can be useful. It can provide your instance with a front-end to cover for a disaster situation.

For example, if you use an auto-scaling group with min=max=1 instance, with an Elastic Load Balancer, then if your instance is terminated or otherwise fails:

  1. auto-scaling will launch a new replacement instance
  2. the new instance will appear behind the load balancer
  3. your user's traffic will flow to the new instance

This will happen automatically: no need to change DNS, no need to manually re-assign an Elastic IP address.

Later on, if you need to add more horsepower to your application, you can simply increase your min/max values in your autoscaling group without needing to change your DNS structure.

Solution 2 - Amazon Web-Services

It's much easier to configure your SSL on an ELB than an EC2, just a few clicks in the AWS console. You can even hand pick the SSL protocols and ciphers.

It's also useful that you can associate different security groups to the actual EC2 and the forefront ELB. You can leave the ELB in the DMZ and protect your EC2 from being accessible by public and potentially vulnerable to attacks.

Solution 3 - Amazon Web-Services

With NO ELB :-

  • Less Secure (DOS Attacks possible as HTTP 80 will be open to all, instead of being open only to ELB)
  • You won't have the freedom of terminating an instance to save EC2 hrs without worrying about remapping your elastic IP(not a big deal tho)
  • If you don't use ELB and your ec2 instance becomes unhealthy/terminates/goesDown
  1. Your site will remain down (It will remain up if you use ELB+Scaling Policies)
  2. You will have to remap your elastic IP
  3. You pay for the time your elastic IP is not pointing to an instance around $0.005/hr

You get 750 hours of Elastic Load Balancing plus 15 GB data processing with the free tier so why not use it along with a min=1,max=1 scaling policy

Solution 4 - Amazon Web-Services

There is no need to use a Load Balancer if you are only running an single Amazon EC2 instance.

To point your domain name to an EC2 instance:

  • In the EC2 Management Console, select Elastic IP
  • Allocate New Address
  • Associate the address with your EC2 instance
  • Copy the Elastic IP address and use it in your Route 53 sub-domain

The Elastic IP address can be re-associated with a different EC2 instance later if desired.

Later, if you wish to balance between multiple EC2 instances:

  • Create an Elastic Load Balancer
  • Add your instance(s) to the Load Balancer
  • Point your Route 53 sub-domain to the Load Balancer

Solution 5 - Amazon Web-Services

On top of the answer about making SSL support easier by putting a load balancer in front of your EC2 instance, another potential benefit is HTTP/2. An Application Load Balancer (ALB) will automatically handle HTTP/2 traffic and convert up to 128 parallel requests to individual HTTP/1.1 requests across all healthy targets.

For more information, see: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#listener-configuration

Solution 6 - Amazon Web-Services

It really depends on what are you running in the EC2 instance.

While with only one EC2 instance it's not necessary to use ELB (all your traffic will go to that instance anyways), if your EC2 service has to scale in the near future, is not a bad idea to invest some time now and get familiar with ELB.

This way, when you need to scale, it's just a matter of firing up additional instances, because you have the ELB part done.

If your EC2 service won't scale in the near future, don't worry too much!

About the second part, you definitely can route directly to your EC2 instance, you just need the EC2 instance IP. Take a look at the amazon route53 docs. Mind that if your IP is not static (you don't setup an Amazon Elastic IP), you'd need to change the IP mapping everytime the EC2 ip changes.

Solution 7 - Amazon Web-Services

You can also use an ELB in front of EC2 if for example you want it to be publically reachable, without having to use up an Elastic IP address. As said previously they work well too with ASG's

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRoberView Question on Stackoverflow
Solution 1 - Amazon Web-ServicesMatt HouserView Answer on Stackoverflow
Solution 2 - Amazon Web-ServicesHeskyView Answer on Stackoverflow
Solution 3 - Amazon Web-ServicesRyan AugustineView Answer on Stackoverflow
Solution 4 - Amazon Web-ServicesJohn RotensteinView Answer on Stackoverflow
Solution 5 - Amazon Web-ServicesMonkey34View Answer on Stackoverflow
Solution 6 - Amazon Web-ServicesruppsView Answer on Stackoverflow
Solution 7 - Amazon Web-ServicesJoeShmoeView Answer on Stackoverflow