2
votes

When setting up an ELB, it would say the following:

You must specify subnets from at least two Availability Zones to increase the availability of your load balancer.

I currently have two VPCs:

  1. WebVPC
    1. public-subnet-us-east-1a
    2. private-subnet-us-east-1b
  2. DatabaseVPC
    1. public-subnet-us-east-1a
    2. private-subnet-us-east-1b

The ELB is only meant for the WebVPC (to serve web traffic). I currently only have one public and one private subnet per VPC, which means I can only provide the ELB with one public subnet from my WebVPC.

Does this mean it is best practice to have at least two public and at least two private subnets?

2

2 Answers

5
votes

Your architecture is not Highly Available. It is best practice to replicate services across multiple Availability Zones (AZs) in case there is a failure in one AZ (effectively, if a data center fails).

Also, it is typically best to keep all related services for an application in the same VPC unless you have a particular reason to keep them separate.

Also, security is improved by putting your application in private subnets, with only your load balancer in the public subnets.

Therefore, the recommended architecture would be:

  • One VPC
  • A public subnet in AZ-a
  • A public subnet in AZ-b
  • A load balancer connected to both public subnets
  • A private subnet in AZ-a
  • A private subnet in AZ-b
  • Your web application running simultaneously in both private subnets (assuming that it can run on multiple Amazon EC2 instances)
  • Your database running in one of the private subnets, with the ability to fail-over to the other private subnet. Amazon RDS can do this automatically with the Multi-AZ option (additional charges apply).

Highly Available architecture

To learn more about architecting highly scalable solutions, I recommend the ARC201: Scaling Up to Your First 10 Million Users session from the AWS re:Invent conference in 2016 (YouTube, SlideShare, Podcast).

1
votes

Yes. It is best practice to provide at least two Availability Zones.

If EC2 Instances were launched in Private subnet then load balancer should be launched in Public subnet which should have internet gateway attached to it.

Load Balancer can handle traffic through internet gateway and redirect to Private IPs of EC2 Instances. Only registered EC2 Instances will receive traffic from Load Balancer.

In your case:

  1. You have to launch Database in Private subnet not in Public subnet as per best practice. Both Web tier and database tier can be in same VPC. If you have different environment like Dev, Test and Prod - all should be launch in different VPC. You can use VPC Peering to connect VPCs.
  2. Instead of launching EC2 Instances in Public subnet, it is good to launch in Private subnet. Because, You will be using Load balancer to redirect network traffic to EC2 Instances.