What is a Load Balancer?. Introduction | by Anshuman Pattnaik | MediumSitemapOpen in appSign up<br>Sign in
Medium Logo
Get app<br>Write
Search
Sign up<br>Sign in
What is a Load Balancer?
Anshuman Pattnaik
5 min read·<br>Sep 27, 2022
Listen
Share
Press enter or click to view image in full size
Introduction<br>Load balancing is a technique to distribute tasks and resources across multiple servers and is generally used to improve the performance of the web application, databases and other services. The load balancer keeps track of the health status of each resource while broadcasting requests to each server. If a server cannot respond or raises an error rate, then Load Balancer stops sending traffic to that server.<br>A load balancer acts as a reverse proxy and sits between client and server, receives incoming traffic and distributes the traffic across clusters of servers using various industry standard load balancing algorithms. Load balancing is an efficient technique to reduce the load of an individual server, improve the application availability, and mitigate the application server from becoming a single point of failure.<br>Press enter or click to view image in full size
Load Balancer ArchitectureLoad balancers are typically grouped into two types: Layer 4 and 7 . Layer 4 load balancer uses only a TCP connection from a client to the server, while Layer 7 load balancer uses two TCP connections from the client to the server. Layer 7 load balances are based on the data’s content, and Layer 4 load balances are based on its inbuilt software algorithm. Layer 7 is an excellent choice for microservices. However, Layer 4 does not apply to microservices.<br>Load balancers traffic<br>There are four main types of traffic the administrators create as forwarding rules.<br>HTTP<br>HTTPS<br>TCP<br>UDP<br>1. HTTP<br>The Load Balancer sets the X-Forwarded-For , X-Forwarded-Proto, and X-Forwarded-Port headers to provide the backends information regarding the initial request.<br>2. HTTPS<br>Standard HTTPS balances load using encryption, and it is handled in two techniques with SSL passthrough or an SSL termination .<br>2.1 SSL passthrough<br>SSL passthrough is the act of handing data via a load balancer to a server without decrypting. The data is passed along to a web server as a simple HTTP, and the decryption or SSL termination occurs at the load balancer.<br>2.2 SSL termination<br>SSL termination happens at the load balancer because the decryption process is a very CPU-intensive task. If the load balancer takes the load for decryption, the server spends time processing power on application tasks that helps improve the application performance.<br>3. TCP<br>A TCP load balancer uses a transmission control protocol which operates at layer 4, and it’s used to route the traffic to a database cluster distributed across all of the servers.<br>4. UDP<br>A UDP load balancer operates at layer 4 in the OSI model and recently added support to core internet protocols such as DNS and syslogd.<br>Backend Server Health Checks<br>Healthy backend servers consistently receive incoming traffic from the load balancers. The Load balancer regularly connects with the backend server and checks the health status. If a server fails on a health check and cannot respond to the load balancer, it automatically stops forwarding the traffic to the corresponding server.<br>Load Balancing Algorithms<br>A Load balancer uses load balancing algorithms to distribute network traffic between servers. There are two types of load balancing algorithms:<br>Dynamic load balancing algorithms<br>Static load balancing algorithms<br>Dynamic load balancing algorithms<br>Get Anshuman Pattnaik’s stories in your inbox
Join Medium for free to get updates from this writer.
Subscribe
Subscribe
Remember me for faster sign in
Dynamic load balancing algorithms use each server’s current state and distribute the traffic accordingly. It is divided into four different types.<br>Least connection<br>Weighted least connection<br>Weighted response time<br>Resource-based<br>1. Least connection<br>Load balancers check which server has the fewest connections open and send traffic to those servers, which means all the connections require equal processing power.<br>2. Weighted least connection<br>It gives the privilege to the administrator to assign different weights to each server by the assumption that some servers can handle more connections.<br>3. Weighted response time<br>The average response time of each server and the number of open connections specify where to send traffic. The algorithm sends traffic to the server with the fastest response time, ensuring quicker service to the end users.<br>4. Resource-based<br>Specialized software called agent runs on each server that measures the server’s available CPU and memory. The load balancers query the agent to check what resources are available on each server while distributing the traffic to that server.<br>Static load balancing algorithms<br>Static load balancing algorithms send an equal amount of traffic to each server; either it can be random or in a specified...