I'm configuring internet facing load balancing on my AWS deployment and there's one issue I can't seem to get. I understand that ELB uses DNS records to load balance between the IPs of the instances, but do I have to assign elastic (public) IP addresses to my web servers? If I want to load balance between 10 internet facing web servers, do I really need 10 elastic IPs? Or is there a way to use ELB with one elastic IP and one DNS record?
Thanks!
You need to attach only public subnets to your ELB, making sure that the availability zones those subnets are aligned with the availability zones of the private subnets that your instances are in.
The load balancer has one IP address per enabled Availability Zone. These are the addresses of the load balancer nodes.
The short answer: Yes, ELB's IP addresses (both the ones that are publicly distributed to clients of your service, and the internal IPs from which ELB sends traffic to your instances) dynamically change.
The nodes of an internal load balancer have only private IP addresses. The DNS name of an internal load balancer is publicly resolvable to the private IP addresses of the nodes. Therefore, internal load balancers can only route requests from clients with access to the VPC for the load balancer.
Your instances do not need their own elastic IPs; they don't need any kind of public IP, and, typically, they should not even be in a public subnet. Only the ELB itself needs to be in a public subnet.
The ELB does not use your elastic IPs, even if they are present. An ELB deployment provides you with a hostname that is used to route inbound requests, using either a CNAME or a Route 53 Alias DNS record.
Note also, your web server machines in private subnets, you'll need a properly-configured NAT instance and routing tables in order for those machines to make outbound requests (e.g. to other web services, downloading updates, etc). This provisioning also has an advantage of providing all your web servers with one (or one per availability zone) source IP address for their originated traffic, which can be useful if someone you are making API requests to wants to whitelist your IP address.
See also:
Why do we need private subnets in VPC?
AWS public subnet autoscaling group with outbound NAT (this applies to servers behind ELB whether or not you're using auto-scaling).
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