When trying to create an application load balancer on aws (up until now I was using the classic ones just fine), I get the following message:
At least two subnets must be specified
Why would an ALB require me to specify two subnets ? Is there any way to create it and use it to LB between instances in a single subnet ?
To expand this just a bit: Your ELB should only be on public subnets, and only on subnets in the same availability zone(s) as your instance(s).
The load balancer must have at least one subnet at all times. You can add at most one subnet per Availability Zone.
ALB requires at least two subnets across Availability Zones, NLB requires one subnet. The subnets must be tagged appropriately for the auto discovery to work. The controller chooses one subnet from each Availability Zone.
You can create a VPC that spans multiple Availability Zones. After creating a VPC, you can add one or more subnets in each Availability Zone. Each subnet must reside exclusively within one Availability Zone and cannot span zones.
So, just to be clear here. @pasmwel basically answered with the docs links but I want to clairfy it since this seems to be getting views.
ALBs require 2 subnets since so that if 1 availability zone goes down the ALB can still operate on the others.
Which is kinda silly... since AWS could be doing it in the background.
The normal ELB and the TCP LB don't require this for no apparent reason. But if a subnet falls down they will also fail.
You might want an ALB as just somewhere to easily place a certificate, provide some security and easily integrate with R53 for a single target instance. Especially handy if you want to use Cloudformation to setup when it's maximum use of AWS.
So it does seem daft to have to configure 2 subnets. I have a vague recollection of reading somewhere that doing that and only using 1 results in lower performance but I could be dreaming that.
so that if 1 region goes down
The above is wrong and should state
so that if 1 availability zone (AZ), in the region, goes down
The answer to the question is, there is not a good reason for AWS to require two subnets. There are use cases where one only wants one subnet for production and other cases where developers only want one subnet. One might think, why bother with an ALB if there is only one subnet. The answer is ALB can monitor instance health (even though there are other ways to monitor, for example, CloudWatch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With