Skip to main content

ELASTIC LOADBALENCER IN AWS



Elastic Load Balancing distributes incoming application traffic across multiple EC2 instances, in multiple Availability Zones.Here before creating a loadbalencer assume that we have 2 subnets sub1 and sub2 in 2 availability zones.Also we have 2 ec2 instances vm1 and vm2 under these subnets.






 To check loadbalencing  I have httpd installed on both instances.The index.html page contains Information as follows:



Now lets begin creating loadbalencer.Here we are creating an application load balancer to distribute traffic among webservers across vm1 and vm2
From ec2-dashboard > select Load balencers >Create Load balancer >Application Load balancer  




In Configure loadbalencer give
>Name: give name for the load balancer we want
>Scheme: Scheme can be internet facing or internal.Here we are creating an internet     facing load balancer.
An Internet-facing load balancer routes requests from clients over the Internet to targets. An internal load balancer routes requests to targets using private IP addresses.
If your application has multiple tiers, for example web servers that must be connected to the Internet and database servers that are only connected to the web servers, you can design an architecture that uses both internal and Internet-facing load balancers. Create an Internet-facing load balancer and register the web servers with it. Create an internal load balancer and register the database servers with it. The web servers receive requests from the Internet-facing load balancer and send requests for the database servers to the internal load balancer. The database servers receive requests from the internal load balancer.

>Ip address type: Here give ip4 scince we are using that
>Listeners: For Listeners, the default is a listener that accepts HTTP traffic on port 80. You can keep the default listener settings, modify the protocol, or modify the port. Choose Add to add another listener (for example, an HTTPS listener).Here iam going with http only.
>Availability zones: The instances should be multiple availability zones.Select our vpc and add instances.
For Availability Zones, select at least two Availability Zones from your VPC. If there is one subnet for an Availability Zone, it is selected. If there is more than one subnet for an Availability Zone, select one of the subnets. Note that you can select only one subnet per Availability Zone.

Now click Next









In configure security settings we have nothing to do since we are using only http.Click Next
In configure security group add security groups we want and click Next.


 Next step is configure Routing.Here we will give following details
>Target group:Since we don’t have any existing target group,we will create one.Give name of new target group and select protocol and port.Here we are selecting HTTP with port 80.Also type target type.Here we are giving instance.

>Health checks: Here we want to specify through which port and through which protocol we want to check health status.We ae giving HTTP and port 80.In advanced health check we can also set timeouts for health checks.In path give the path where we want traffic to loadbalence.Here we are giving index.html.





Click Next and add the instances to registered targets.






 We can see that our load balancer is created.Try to acess the loadbalencer using DNS.We can see the traffic is distributing among multiple instances.