There are four sections that play a key role in creating an HAProxy configuration file. Unless all the sections are configured correctly, we may not achieve good performance. The sections are as follows:
- global
- defaults
- frontend
- backend
In this recipe, we shall discuss how the preceding four sections can be configured appropriately and understand what is needed to build a configuration file.
Getting ready...
HAProxy should preferably be installed on the application server as it is lightweight. This avoids the need to have an active-passive HAProxy server when it is hosted on an external server between the application and the database server.
We must have already installed HAProxy to successfully execute the steps in this recipe.
Please note that the default location of an HAProxy configuration file is /etc/haproxy/haproxy.cfg.
How to do it...
The following is the minimal list of settings for each section. These can be added to an HAProxy configuration...