Elastic Load Balancing – ELB
Elastic Load Balancing automatically distributes traffic across multiple targets – Amazon EC2 instances, containers and IP addresses – in a single Availability Zone or multiple Availability Zones.
Amazon offers 3 types of Load Balancer:
1.Classic Load Balancer
2.Application Load Balancer
3.Network Load Balancer
Now lets see how to configure classic load balancer and how to configure
Classic load balancer:
A load balancer distributes incoming application traffic across multiple EC2 instances in multiple Availability Zones.This increases the fault tolerance of your applications. Elastic Load Balancing detects unhealthy instances and routes traffic only to healthy instances.
How to configure Classic Load Balancer:
To configure ELB and test you need minimum 2 instance . ELB can work with 1 instance also , but for high availability and load sharing test you need minimum 2 instances.Lets take 2 Linux instance in two different zone to test.In this post we will see from scratch how to configure public web site with ELB.
For our example we will take below servers
Before configure ELB lets configure httpd apache web service and run a default web page on both Linux server .
Amazon Linux – httpd web service configuration
Install “httpd” with yum command
#yum install httpd
Start httpd service
#service httpd start
On Amazon Linux Server:
After successful completion of above steps we can see apache test page
Now create your index.html in /var/www
Enter the Website content whatever you like. You can create php file also .
Now restart the httpd service
Now enter the Public IP address (or private IP address in same subnet). You can view the output content in the browser.
On webserver 2 (Cent OS):
Now lets take “centos” server . Repeat the same procedure as above on server2 .
Now both web servers are ready.
Next step configure security groups:
you have to create a security group for ELB . The traffic allowed to reach ELB .You can specify some particular IP address or from anywhere also 0.0.0.0/0.
This is very important . Now allow the security group of web server “inbound http traffic from ELB only” .So that all http traffic should come through ELB.
Configuring Load balancer:
Now all set to crate and configure ELB.
Select Load Balancers in panel and click “create Load Balancer” .
Select “Classic Load Balancer”
Enter Load Balancer Name
Select the VPC to create LB inside
Leace the check box empty to create external ELB.
Enter Listener configuration front end and back end port details . The advantage of classic load balancer is its support ant TCP traffic . So you can specify other than port 80/443 also.
Now select the security group which already created in previous stpes” sgprd-fronendwebelb”
This page is need to configure when you are using https.To update ssl certificate . In this test we are going to use http only.
Configure health Check . The ELB will keep check the health status of backend attached EC2 instance.If any of the instance failed to pass health check , ELB will mark as failed instance and will not send traffic.
You can configure your actual web page for health check with http .
You can configure with normal TCP port 80 also . So the ELB will check the port 80 only , not actual web page response . Any one health check configuration is enough.
Select the EC2 instances to add into the ELB. So that the traffic will be routed to selected servers only. if the servers in 2 different zones , Enable cross zone Load balancing .
Now add the tag Name and Value
This is final step . Now review your configuration and click create.
ELB Details . The highlighted section is DNS Name of ELB . You have to use that name to map your webiste.
Initially when the Load balancer creates the backend instance status will be “Out of Service ” . It will take some time to mark as “in Service ” if health check pass.
Status Changed to In-service now
Now both servers InService and ELB is ready to receive traffic.
While enter ELB DNS name in browser 1st time
While enter ELB DNS name in browser 2nd time
Thats all! Good luck for your configuration .