Fast, smart and useful! These are HAproxy properties. The software that we are going to talk about in this article. We want to see what HAproxy is. The important role of HAproxy in the Internet world
HAproxy is one of those softwares that may be less known, but it plays a very important role in the Internet world. No exaggeration! For example, high-traffic sites like GitHub, Twitter and Instagram, without this software – or at least similar software – might not even exist!!
In the following, we will talk about the capabilities of this software, algorithms and how to install it. First, let’s get to know a little more about this software.
What is HAproxy?
Table of Contents
HAproxy stands for High Availability Proxy. This software plays the role of Load Balancing and Reverse Proxy in HTTP and TCP protocols for sites and applications. In addition, the language with which the program was made is C!
Let us explain the use of HAproxy with an example:
Suppose you intend to extend the technical examination of your car and you go to one of the specified centers for this purpose. You will see an endless line and unfortunately you will lose many hours waiting. It gets worse when there is only one line to check cars and all those queues are supposed to enter the same line!
But if the center you visited is large and has several examination lines, the work will definitely go faster. In such a case, someone stands near the center and directs the cars to quieter lanes. If the line becomes long, the rest of the cars are sent to other lines. This process will continue constantly in order to share the burden and speed things up.
HAproxy does the same for site and application servers; In this way, the incoming traffic, instead of connecting directly to the server, reaches HAproxy and is then sent by this software to a server that is quieter.
With this traffic division, the performance of sites and applications will improve and users will have a better experience.
Of course, HAproxy has many features.
What features does HAproxy have?
Along with speed, usability and intelligence, the most important feature of HAproxy is its open source. In addition, this software is available in many different Linux distributions.
Of course, there is also a corporate version of this software that provides a more professional service along with full support.
So let’s go to the features:
Transparent Proxy
Transparent proxy, which is also called Inline Proxy, Intercepting Proxy and Forced Proxy, allows the user to connect directly to the server. Let’s say it this way: there is a proxy, but it doesn’t seem like it!! From those short sentences.
Content Inspections
This feature makes it possible for users to block unwanted protocols.
CLI for Server Management
If you want to make changes to the server environment, the CLI will help you. Changes such as turning off and turning on the server are done through this feature.
** The meaning of turning off and turning on the server is the same as activating and deactivating the server inside haproxy.
Support for different protocols
HAproxy is compatible with various protocols such as HTTP, HTTP/2, gPRC and FastCGI.
HTTP Authenticator
The authentication process in the HTTP protocol is very simple and basic. HAproxy does this. In this way, the server asks the user for Username and Password to allow him to enter.
Multithreading
Multithreading is a model of program execution that allows multiple threads to be created in one process. With the help of HAproxy, this model can be used.
In this model, threads use process resources independently but simultaneously.
Load Balancing layer 4 and layer 7
The most important feature of HAproxy is Load Balancing. It is this feature that divides incoming traffic between different servers and ultimately improves the performance of the site or application.
HAproxy also scales well; That means it can even be prepared to connect to thousands of back-end servers.
But let’s talk a little more about Load Balancing.
What is Load Balancing and how many types are there?
Load Balancing icon, do you remember the example of technical examination? In that example, sending cars to different lanes is exactly the process of load balancing. So that one line is not too busy and the other line is empty, the input load is divided between them.
As we said, HAProxy is first a special software for Load Balancing, and in the later stages it has other features (the ones we discussed); That is, it is HAproxy that is responsible for performing the Load Balancing process to divide incoming traffic to the site or application.
In total, we have 2 types of load balancing: layer 4 and layer 7. In the following, we will talk about these two types and, of course, the mode where load balancing is not used.
No load balancing
In this case, the user connects directly to the web server without any intermediary.
Load balancing layer 4
The easiest way to divide the traffic between several servers is to use a layer 4 load balancer.
In this case, the user’s request reaches the load balancer, and the software (for example, HAproxy) sends the request to a group of backend servers. Any server that is more open will send the request response directly to the user. (The answer is the same page that the user intends to visit.)
Load balancing layer 7
This type of Load Balancing is more complicated than layer 4.
For example, requests for blog visits go to the blog backend and other requests go to the web backend! Meanwhile, both sets of servers are finally connected to a common database.
Well, we talked about Load Balancing and now we want to talk about HAproxy security.
Is HAproxy highly secure?
Since this software is open source, its security is provided by users! But don’t think that HAproxy is insecure. Incidentally, in recent years, very rare cases of vulnerability have been observed in this software.
Also, HAproxy has the ability to severely limit and control the level of attack that occurs when detecting a security flaw.
Another feature of this software in terms of security is monitoring the behavior of users to identify suspicious cases. If there is an unusual movement on the part of the user, the necessary actions will be taken quickly and the user will be denied access to the site or application.
Even HAproxy provides the possibility of Rate Limiting and the use of Black List and White List for its users.
But one question: How does the Load Balancer decide which server to send the request to? This selection is based on the algorithms of this software.
What algorithms does HAproxy work on?
HAproxy uses different algorithms for load balancing. There is even a parameter that determines the frequency of use of each server. There are many algorithms in this software, but we will review only 3 algorithms in this article.
roundrobin
HAproxy’s default algorithm is roundrobin. A simple algorithm that takes turns into choosing servers!
leastconn
In this algorithm, the server that has the least connection is selected. In other words, the server whose head is quieter than the rest of its colleagues is receptive to user requests. Applications and sites where the user connection is longer use this algorithm more.
Source
In the Source algorithm, the server is selected based on the requester’s IP hash. In this way, it is guaranteed that a user always connects to a specific server.
We talked about almost all aspects of HAproxy; But this software has two other features in the field of Load Balancing.
What is meant by Sticky Sessions and Health Check?
As you can see by now, HAproxy is a great software for both large and small sites and applications. Well, now we want to talk about two other attractive features of this software related to Load Balancing.
Sticky Sessions
The mechanism of some sites and applications is such that each user only has to stay connected to one server and it is not possible to change the server. This is possible with the help of Sticky Sessions feature.
Health Check
HAproxy checks all servers to see if they are capable of processing requests! If a server is not able to respond for any reason, it will be automatically disabled and traffic will not go to it.
Also, if all servers are unavailable, the entire site or application will be blocked until at least one backend server returns to the activity cycle.
Last word: HAproxy is more powerful next to NginX!
Well, we found out that HAproxy is a software whose task is to improve the final performance of the site and application. Nginx web server will perform better when used with HAproxy because of its features. Also, HAproxy is more efficient than ever with this web server.
If you have any questions or comments in this regard, we are waiting for you in the comments section.
CATEGORY:Blog