Load balancing refers to the efficient distribution of incoming traffic across a group of multiple servers
Above image clarify your’s doubt why balance the load is important when our website is access by lots of users at a same time so for the high availabity and better user user experiance means not let down the website when access by the user we distribute the load among multiple server of same application and autoscale the servers when traffic is high and autodegrade the servers when traffic is low
Important points when estlablishing load balancer →
- EC2 Instance must have private IP.
- Load balancer having public IP for Internet connection.
- EC2 instance does not require public IP it Uses ELB(elastic load balancer) public IP for Internet connection.
- Every incoming traffic does not need to go through the load balancer. It directly goes to EC2 instance if your request is to PING the EC2 it does not require ELB
- An Internet facing load balancer has a public DNS name.
- Domain name for context on the EC2 instance is saved by the ELB resolved by the DNS server to the ELB DNS name and hence IP address.
- And this is the way that how traffic from the Internet. Is goes to the ELB front end.
Load balancer is having 3 things →
- Listners → Listener tells us the port number of the incoming request and send request there.
- Target group → It is the group of the EC2 instance where the listener send the incoming request.
- Target → It is that particular EC2 instance say target where the listeners sends the incoming request.
Listeners Types →
- Frontend listener → It checks for traffic from client to the listener.
- Backend listener → It transferred the request to EC2.
ELB Recommendations and features →
- Instance is not deleted when load balancer delete.
- ELB supports IPV4 in a VPC.
- For fault tolerance it is recommended that you distribute your EC2 to in different availability zone.
- If possible try to allocate same number of EC2 in every AZ(availability zone)
- ELB also monitor health and route traffic only healthy instance.
- Registered instance must respond HTTP “200 OK” message within the time period as it will be considered unhealthy.
- Response time out is default 5 second (range is 2–60 seconds)