What is Load Balancing
Date : 20.02.2020 Author : Kron Product Team
How to use Load Balancer and in which cases it is used
1.What is Load Balancing?
Load balancing is an important component of highly available (high availability) infrastructures that are widely used to improve the performance and reliability of websites, applications, databases, and other services by deploying workload to multiple servers.
With this process, users of the system are efficiently deployed between servers that can be called a server group or server pool, either equally or within the specified rules. Systems that perform these load balancing operations between both application and database servers are called "load balancer".
On a system where load balancing is not used, users connect directly to a single web server on which the domain name is running on, whether they want to access a web service, such as "domainame.com". As a result, users will not be able to access the website in the event of a problem that may occur on this server. In addition, if many users try to access the site simultaneously, there may be a slowdown in load times and eventually access interruptions because overload cannot be met over a single server.
This "single point of failure" state can be eliminated with at least one additional server and load balancer to add to the system architecture. Typically, servers running behind load balancer will have the same content, so users encounter the same output no matter which server they provide.
2. Which Traffic Types Can Be Balanced with Load Balancing?
Balancing rules can be created for load balancers in 4 basic traffic types.
HTTP: Requests that come in standard HTTP balancing are routed based on standard HTTP techniques. Load balancer sets x-forwarded-for, X-Forwarded-Proto, and X-Forwarded-Port titles to inform the back-end system about the original request.
HTTPS: The same process is operated with HTTP balancing processes. The only difference is the encryption processes in HTTPS operations. These encryption processes can be performed in two different ways. In the first method, encryption is maintained up to back-end with SSL migration. In the second method, the encryption and decryption load is taken over each server and loaded into load balancer. In this structure, both less load strain on servers and costs can be reduced. This process, in which SSL is built on a load balancer, is called SSL Offload.
TCP: TCP traffic may be balanced for applications that are not http or HTTPS. For example, traffic to a set of databases can be balanced by spreading to all servers.
UDP: Recently, some load balancers have added load balancing support for basic internet protocols that use UDP, such as DNS and syslogd.
These balancing rules ensure that after the protocol and port on the load balancer are defined, they match the protocol and connection that the load balancer will use to route traffic in back-end.
3. How Does Load Balancing Work?
How do Load balancers select the back-end server to route traffic to?
Load balancers use a 2-factor combination to forward requests. First, they make sure that the servers they can choose can respond to the requests in accordance with the requests. It then uses pre-configured rules to choose between servers that can respond (healthy pool).
4. Compliance Checks (Health Checks)
Load balancing systems must transmit load balancers traffic only to back-end servers that are considered healthy. If a server fails in eligibility check and therefore fails to respond to requests, it is automatically removed from the pool and traffic will not be transmitted to this server until it responds to compliance control again.
5. Load Balancing Algorithms
The load balancing algorithms used are algorithms that determine which backend server traffic is transmitted to. Here's how we can sort the most commonly used algorithms:
Round Robin: Round robin are algorithms where servers are selected sequentially and traffic is shared with this sort. In this algorithm, the load balancer selects the first server in the list for the first request and proceed with the next server in list for the for the next request. By the end of the list, the selection continues to scroll down, starting again from the top.
In the Least Connection: Least connection algorithm, the load balancer selects the server with the least connection. This algorithm is recommended when traffic results in longer sessions.
Source (IP Hash): In the Source algorithm, the load balancer uses the client's IP address to determine which server will receive the request. This method ensures that a specific user is constantly connecting to the same server.
Random assignment: Random assignment, which is least organized from all load balancing methods, does exactly what it says: Random assigns each workload to a server (server pool) on a group of servers. The theory behind the random assignment sounds more complicated than it sounds. In probability theory, the Great Numbers Act says that as a sample size grows, the middle result in a sample set will eventually match the average result. When applied here, random assignment of a workload to a server in the pool means that each server in the pool will handle approximately equal workloads, even if workloads are not initially equal.
6. Why should Load Balancing must be used?
- Load balancing can maximize accessibility and server continuity. This ensures that the server system is always ready and running for users.
- The user experience also shows improvements as there will be no delays and access disruptions even in periodic traffic increases.
- The risk of "single point of failure" is eliminated because users will be redirected to the most appropriate application/database resources and application/database optimization will be provided.