What is a Load Balancer ?

 What is a Load Balancer ?

     Load balancing aims to optimize resource use, maximize throughput, minimize response time, and avoid overload of any single resource.
       Load balancing improves the distribution of workloads across multiple computing
resources, such as computers, a computer cluster, network links, central processing units, or disk drives
     Types of Load Balancer
* Layer 4
* Layer 7

 

Best DevOps Training Institute in Gurgaon...

Layer 4 Load Balancing

Layer 4 load balancing (which is also called as transport layer load balancing) is widely acknowledged for its simple way to load balance the network traffic through multiple servers. This type is based on IP range/domain and port i.e. if a user request comes in for domain.com/blog, the traffic will be sent to the backend that manages all the user requests for domain.com on port 80. 

 Layer 4 Load Balancing

Also known as application layer load balancing is a more refined and sophisticated way of network traffic load balancing than Layer 4.

This mode is based on the content of the user’s request in which load balancer sends user requests to the web servers according to the content of a request.

This is the very advantageous way because users can run multiple web servers on the same

domain and port.


 HAPROXY

     It is free, open source software that provides a high availability load balancer and proxy server for TCP and HTTP-based applications that spreads requests across multiple servers.

     License: GNU General Public License Version 2

     Stable release: 1.8.0 / November 26, 2017

     Original author(s): Willy Tarreau

     Written in: C

     Operating system: Linux, FreeBSD, OpenBSD, Solaris (8/9/10), AIX (5.1 – 5.3

 How to Use HAProxy and share the load with round-robin policy

     Install and start HAProxy on Ubuntu

$apt update

$ apt install haproxy

$ haproxy –v

$ systemctl start haproxy

     Configuration file can be found at

/etc/haproxy/haproxy.cfg

     Let's define a frontend first, We will have it listen on the HAProxy IP address at port 80, Open /etc/haproxy/haproxy.cfg configuration file and add the following lines to the bottom.

frontend webserver

bind *:80

default_backend appservers

     appservers backend shares the traffic equally among two web servers by using the roundrobin algorithm.

backend appservers

balance roundrobin

server appserver1 http://apache1-ip check server appserver2 http://apache2-ip check

 

     Restart HAproxy service

$ systemctl restart haproxy

     Browse the ip of the HAProxy server and reload the browser.

Get More Information About Devops Training and Certification Course Visit Here.

Thank You For Reading

Written By Amal Satheesh

Comments