To set up HAProxy, modify the haproxy.cfg file. You can find the file under the following path:
.../etc/haproxy/haproxy.cfg
Primary setup (required)
Add frontend and backend sections necessary for HAProxy operation.
The frontend section
Add bind and default_backend settings to the frontend section.
-
In the bind setting, specify the address and the port that will receive requests distributed by HAProxy.
-
In the default_backend section, specify the name that will match the name of the backend section.
As a result, the setup will look as follows:
frontend frontend_example
bind *:80
default_backend backend_example
The backend section
Add 2 required setting to the backend section:
-
In the balance parameter, specify the type of balancing, e.g., leastconn. More information about different types of balancing is available in HAProxy documentation.
-
Use the server parameter to specify all servers (or “nodes”) for distributing the load.
Add a separate “server” parameter for each server (i.e. the deployed bpm’online application instance) and specify the server and port addresses. For example, if you need to distribute the load between 2 bpm’online application servers, add 2 “server” parameters to backend:
server node_1 [server address]:[port]
server node_2 [server address]:[port]
As a result, the setup will look as follows:
backend backend_example
balance leastconn
#nodes for balance
server node_1 10.0.14.155:91
server node_2 10.0.15.107:92
The new settings will be applied as soon as you restart HAProxy. To restart HAProxy, use the following command:
service haproxy restart
web Statistics setup (optional)
To enable web-statistics, add a new “listen” section with the following parameters: bind, mode http, stats enable, stats uri. The syntax is as follows:
listen stats # Define a listen section called "stats"
bind :9000 # Listen on localhost:9000
mode http
stats enable # Enable stats page
stats uri /haproxy_stats # Stats URI
As a result, the web-statistics of bpm’online load balancing will be available for viewing in the browser.
To view the statistics, follow the path: [balancer address]:9000/haproxy_stats.