By continuing to navigate on this website, you accept the use of cookies to serve you more relevant services & content.
For more information and to change the setting of cookies on your computer, please read our Cookie Policy.

Configuring and Testing Load Balancer in AWS EC2

When You have an application that is serving Huge Customer Base, so will be your Traffic. Sometimes The Application stops responding. We can use load Balancer in cases like this which distribute the Traffic it receives between the multiple VPS running the same application.

Deploying and Configuring EC2-Instances:

Load Balancers are region specific, so you have to deploy all the applications in the same region. When running a Load Balancer configuration you set Load balancer for instances and not their IP Addresses, So you don't need to assign them with Elastic IPS and you can stop add and remove instances anytime from Load Balancers.  So Deploy Instances accordingly and Configure your application. 

To Demonstrate Load Balancing I will create  3 VPS setup and install Nginx using 

apt-get install nginx

now VPS port 80 will display Nginx welcome page. 

Configuring Load Balancer:

In EC2 Services sidebar, Click Load Balancing --> Load Balancer.  Then click on the Create Load Balancer.

 Select a Name, the port to be exposed(80/443) and the Port the incoming traffic is to be redirected. Then Select Instances which host the same application and tag them if needed.

Create a Load Balancer with the above bare configuration and customize as per your requirements, wait for health to turn Green. You can find Load Balancer URL in Load balancer Properties. 

Opening Load Balancer URL in the browser will display Nginx welcome page. (served by 1 of 3 vps endpoints).

Testing the Setup:

To test the setup install apache-utils which also has Apache Benchmark package that we will use for Load Testing

sudo apt-get install apache-utils
ab -n < number-of requests> http(s)://<loadbalancer-url>/

Now you can ssh into individual instances and check the Nginx log count.

wc - l /var/log/nginx/access.log

All three servers will have entries suggesting Load Balancer setup is successful.

Know more about our Aws Consulting Services here

    Posted On
  • 13 September 2014
  • By
  • Micropyramid

Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Paginating S3 objects using boto3

When using Boto you can only List 1000 objects per request. So to obtain all the objects in the bucket. You can use s3's paginator.

Continue Reading...
CORS with Amazon S3 and CloudFront

We struggle to load fonts from CloudFront because of CORS.

CORS - Cross Origin Resource Sharing is a security measure to block macious scripts or ...

Continue Reading...
How to process message queuing system by amazon SQS

Amazon Simple Queue Service (Amazon SQS) is a distributed messaging queue oriented service.
Queued items in SQS are called messages which are variable in size ...

Continue Reading...
open source packages

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties