mastercooler6
mastercooler6

Reputation: 467

How does Elastic Beanstalk support multiple EC2 instances for a web server?

Maybe I am not understanding what exactly Elastic Beanstalk should be used for, so my question is this:

How does Elastic Beanstalk have the ability to support multiple EC2 instances in the same Elastic Beanstalk Environment if the instances act as a backend web server?

For example, if I have a server that has the end point www.example.com/api/endpoint, does Elastic Beanstalk allow me to have more than 1 instance (for high availability) with that same endpoint? Is that possible? If not, how do you make use of the extra EC2 instances if they all have different domains?

How do I send requests to the Elastic Beanstalk environment (from a front end web app) that all instances can understand?

Upvotes: 1

Views: 1360

Answers (1)

Jeremy Thompson
Jeremy Thompson

Reputation: 65554

You're going to need to watch some video's.

ElasticBeanStalk is for lazy developers who don't want to learn Cloud Technology ;) I know because I was one once!

ElasticBeanStalk creates a VPC that has Subnets by default 1 per Availability Zone (AZ), and the number of AZs depends on the regions number of AZs. The VPC it creates will have a Internet Gateway attached via the Route Tables making it Public.

In the Subnet(s) ElasticBeanStalk will spin up a EC2/VM to host your website.

ElasticBeanStalk will make a Network Security Group (NSG) opening port 80 &/or 443 and because the VPC is public plus the NSG is open the EC2 will be accessible to the WWW.

If you've chosen an Auto Scale Group (ASG) the ASG will spin up/down EC2s depending typically on CPU but you can use CloudWatch metrics.

With an ASG the ElasticBeanStalk will spin up a Elastic Load Balancer (ELB) and that will coordinate the traffic coming into the Internet Gateway to the VMs. The ELB is registered with the ASG and that's how it knows the ASG spun up or down EC2 instances. This is how the ELB can deliver the traffic using either Level4 (a range of IP addresses) or Layer7 (a range of IP Addresses plus HTTP Request, Header & etc info) to the EC2s currently running in a "Target Group".

if I have a server that has the end point www.example.com/api/endpoint, does Elastic Beanstalk allow me to have more than 1 instance (for high availability

Yes! And its actually quite tricky to demonstrate because you hit the same URL and need to get the ID of the different instances in the ASG.

The best resource is Ryan Kroonenberg's A Cloud Guru "Solution Architect Associate" video on VPCs, Chapter 9. https://acloudguru.com/course/aws-certified-solutions-architect-associate-saa-c02-4KYV (you can find an yrs old torrent with it)

This diagram isn't 100% accurate, the ASGs stretch across AZs:

enter image description here

Upvotes: 3

Related Questions