Introduction To AWS ELB

In this article, we are going to learn about AWS ELB (Elastic Load Balancing) service and we will be covering the below topics,
  • Introduction to AWS ELB.
  • Prerequisites of Creating Elastic Load Balancer.
  • Hosting sample app in web server.
So, let’s get started.

Introduction to AWS ELB

ELB stands for Elastic Load Balancing and what the Elastic Load Balancer does is, it divides user requests or traffic of the application among different EC2 instances in different availability zones. As one application can have multiple EC2 instances on which different web or database servers can be hosted.
The main benefit that comes out of this is the capacity to handle the failures as if one server is down then the request will go to the other server which is up automatically.

Health Monitoring

The load balancer continuously monitors the health of its registered instances and make sure that it routes traffic only to the healthy EC2 instances.
Whenever the load balancer detects that an instance is not healthy, it immediately stops sending traffic to that instance, and then resumes sending traffic to that instance only when it finds out that the instance is back to its healthy state again.

Internet or Internal facing Load Balancer

When you create a load balancer, you must choose whether to make it an internal load balancer or an Internet-facing load balancer.
The nodes of an Internet-facing load balancer have public IP addresses. The DNS name of an Internet facing load balancer is publicly resolvable to the public IP addresses of the nodes. Therefore, Internet facing load balancers can route requests from clients over the Internet.
On the other hand, 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.
Both Internet-facing and internal load balancers route requests to your instances using private IP addresses. Therefore, your instances do not need public IP addresses to receive requests from an internal or an Internet-facing load balancer.

Web and DB server Example

If your application has multiple tiers, where web servers must be connected to the Internet and database servers that are only connected to the web servers, we 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. This can be seen in the image below,
There are some prerequisites of creating load balancer and they are mentioned as below,
  • Choose any two Availability Zones you will use for your EC2 instances.
  • Launch at least one EC2 instance in each Availability Zone.
  • Then ensure that the security group for your EC2 instances allows HTTP access on port 80. Now to test the web server, copy the DNS name of the instance and verify whether browser displays the default page of the web server or not.


As we have seen the prerequisites for creating the load balancer. So now let’s quickly set up the web server.
In one of my previous article Host Your Sample App In AWS Instance Using EC2 Service, we have already seen that how we can set up an EC2 instance with CentOS 7 and how we can host a sample application.
So here also we are going to do the same thing and are going to launch 1 instance.
The difference is just that we are going to use Ubuntu OS this time to make it a bit different in terms of commands. Otherwise the entire process is same, this will not cover every small step here once again.
Few points to note here, to set up the application we have used The Card Portfolio Template and we have used Ubuntu Server 18.04 to set up our EC2 instance.
We have launched the one EC2 instance in us-west-1b availability zone.
We have added the tag card-web01 for our EC2 instance.
We have given the security group name as card-web-sg.
We have used the key pair name as card-kp, this will be used to login to the instance.
And post this set up launched the instance.
Once the instance is up and running then, first we will login to the instance and after switching to root user will run the below mentioned commands.
  1. ssh -i "Downloads/card-kp.pem"  
  2. sudo -i  
  3. apt update  
  4. apt install wget unzip apache2 -y  
  5. wget  
  6. unzip  
  7. cp -r 2109_the_card/* /var/www/html/  
  8. systemctl restart apache2  
Finally, after restarting the Apache2 service, we will copy the public IP address of this EC2 instance from AWS and paste it on browser to see that our site is up and running.
So, we are done for this part.


So, in this article we saw the introduction of AWS ELB and also understood the prerequisites for creating load balancer and finally towards the end created one instances and host a sample application. In the next article, we are going to learn about load balancers.
I hope you find this article helpful. Stay tuned for more … Cheers!!