HAProxy is an open-source, free tool offering high availability and load balancing for TCP and HTTP-based traffic. It is written in C language and was first released on Dec 16, 2001.
Over the years, and because of its popularity, it is now shipped with most Linux/Unix distributions. If it is not shipped with your Linux distro, follow this guide to install it. I am using Ubuntu 22.04 (long-term service) for demonstration.
How HAProxy works?
When HAProxy receives user requests, it balances the load across backend servers using a round-robin or ‘least connection used’ algorithm. Moreover, when one of the servers is down, HAProxy forward all the requests to another active server, thus providing high availability.
Installing HAProxy in Ubuntu 22.04
Update and Upgrade the Package Repository
Run the below command to update and upgrade the package repository to install newer software versions on your system.
sudo apt update && sudo apt upgrade
You will be prompted to input a sudo password. Type the password and hit Enter from your keyboard.
Fire up the terminal and run the following single-line command.
sudo apt install haproxy
This could take 5 min to install HAProxy. Therefore, please be patient.
Execute the following on the terminal, which will return a version of HAProxy installed on your machine.
You can uninstall HAProxy from your system with the following command.
sudo apt remove haproxy
We hope you like our tutorial. Please suggest any improvement using our comment section at the end of this article. You can also follow and subscribe to us on Youtube, Linkedin, Twitter, Facebook, Pinterest, and Flickr.