HAProxy Load Balancer Implementation
9.1 Why a Load Balancer Was Required
Although the deployment successfully consisted of three independent ERPNext application servers, users still had to access each server individually by using its IP address. This approach was not suitable for a production environment because users would need to know which server was currently active.
To solve this problem, a dedicated HAProxy load balancer was introduced. HAProxy provides a single entry point for all client requests and distributes traffic across multiple ERPNext application servers. It also performs health checks to ensure requests are only forwarded to healthy backend servers.
The introduction of HAProxy improves availability, scalability, and simplifies client access by exposing only one IP address to end users.
9.2 Dedicated HAProxy Virtual Machine
Instead of installing HAProxy on one of the application servers, a separate Ubuntu Server virtual machine was created. This approach prevents the load balancer from competing with ERPNext for CPU and memory resources and makes the architecture easier to manage.
The HAProxy virtual machine was configured as follows:
Component | Value |
|---|---|
Hostname | haproxy |
Operating System | Ubuntu Server 24.04.2 LTS |
Virtual Machine ID | 401 |
IP Address | 192.168.31.60 |
CPU | 2 vCPUs |
Memory | 2 GB |
Disk | 20 GB |
9.3 Network Verification
After the installation of Ubuntu Server, the network configuration was verified to ensure proper communication between the load balancer and all ERPNext application servers.
The following tests were successfully performed:
Connectivity to App1
Connectivity to App2
Connectivity to App3
Internet connectivity
DNS resolution
Successful ping responses confirmed that the HAProxy server could communicate with every backend application server before beginning the load balancer configuration.
9.4 Backend Application Servers
The three ERPNext application servers were configured as backend nodes for HAProxy.
Server | IP Address | Port |
|---|---|---|
App1 | 192.168.31.40 | 8844 |
App2 | 192.168.31.41 | 8844 |
App3 | 192.168.31.42 | 8844 |
Each application server was independently verified and accessible through a web browser before integration into HAProxy.
9.5 Load Balancing Strategy
The initial implementation uses the Round Robin algorithm.
Round Robin distributes incoming requests sequentially across all available backend servers. This method provides a simple and effective way to balance traffic evenly between ERPNext instances.
Advantages include:
Equal request distribution
Better utilization of server resources
Reduced load on individual application servers
Improved response time under concurrent user access
9.6 Health Check Mechanism
HAProxy continuously monitors the health of each backend server using HTTP health checks.
If one application server becomes unavailable, HAProxy automatically removes it from the backend pool and redirects incoming requests to the remaining healthy servers.
Once the failed server recovers, HAProxy automatically adds it back into the rotation without requiring manual intervention.
This mechanism significantly improves service availability during unexpected server failures.
9.7 Integration with Proxmox High Availability
The HAProxy load balancer works together with Proxmox High Availability.
The workflow is as follows:
A client sends a request to the HAProxy server.
HAProxy forwards the request to one of the healthy ERPNext application servers.
If an application VM fails, HAProxy detects the failure and stops routing traffic to that server.
Proxmox HA automatically restarts or migrates the failed virtual machine.
Once the application server becomes available again, HAProxy automatically resumes sending requests to it.
This combination provides both infrastructure-level recovery through Proxmox HA and application-level traffic management through HAProxy.
9.8 Benefits of the Final Architecture
The completed architecture provides several operational advantages:
Single entry point for all users
Automatic distribution of incoming traffic
Improved application availability
Automatic backend failure detection
Seamless integration with Proxmox High Availability
Simplified maintenance, as individual application servers can be restarted without affecting user access
Better scalability for future expansion
9.9 Screenshot Recommendations
Include the following screenshots in this chapter:
HAProxy VM in Proxmox
VM creation or summary page.
Ubuntu Installation Complete
hostnamectl output.
Network Verification
ip addr and ping outputs to all application servers.
HAProxy Configuration
/etc/haproxy/haproxy.cfg
HAProxy Service Status
sudo systemctl status haproxy
Browser Test
Accessing ERPNext through http://192.168.31.60
Failover Demonstration
Browser remains accessible after shutting down one application VM while HAProxy routes traffic to the remaining healthy nodes.