Setting Up HAProxy Balancer Using Web Forms

Web forms work via the WebSocket protocol. If a cluster is created for a developed application, and web forms are supposed to be used, it is required to determine balancer additional settings. The settings given below assume that balancer works via HTTP protocol. To get information about balancer work via HTTPS protocol, see the Setting Up HAProxy Balancer via HTTPS Protocol section.

It is assumed that balancer and web application are deployed on the same computer.

  1. Install HAProxy:

sudo apt-get install haproxy

  1. Open the settings file:

sudo nano /etc/haproxy/haproxy.cfg

The file contains four main sections: global, defaults, frontend and backend.

  1. In the defaults section set connection timeout, client idle timeout, request handling time by server. Add work time in the tunnel mode that is used during the work via the WebSocket protocol. The time without prefix is set in milliseconds, the time with the "s" prefix is set in seconds:

defaults

...

timeout connect 5s

timeout client 300s

timeout server 300s

timeout tunnel 3600s

...

  1. Add the frontend section with balancer settings for HTTP requests:

frontend ft_web_bi

bind *:555

bind-process all

acl bisom path -i -m sub /fpBI_App_v10.x/axis2/services

acl biproxy path -i -m sub /PPService.axd

use_backend bk_bi if  bisom || biproxy

default_backend bk_web

  1. Add the backend section with web application settings:

backend bk_web

mode http

option forwardfor

server web <balancer IP address>:8110 check #URL of server with deployed balancer and web application

  1. Add the backend section with settings for a group of BI servers, between which load will be distributed:

backend bk_bi

mode http

option forwardfor

balance roundrobin #Balancing algorithm

cookie IDBI insert indirect nocache

server bi1 <IP address of the first BI server>:8810 cookie sb1

server bi2 <IP address of the second BI server>:8810 cookie sb2

...

  1. Add the frontend section with balancing settings for WebSocket:

frontend ft_ws_bi

bind *:8080

bind-process all

default_backend bk_ws_bi

  1. Add the backend section with settings for a group of BI servers during the work via WebSocket:

backend bk_ws_bi

option forwardfor

balance roundrobin

cookie IDBI insert indirect nocache

server bi1 <IP address of the first BI server>:9091 cookie sb1

server bi1 <IP address of the second BI server>:9092 cookie sb2

...

  1. Add settings to enable balancer work statistics collection, in the future the statistics will be available at: http://<balancer IP address>:8404/stat:

frontend stats

bind *:8404

stats enable

stats uri /stats

stats refresh 10s

  1. Restart HAProxy:

sudo systemctl restart haproxy

The HAProxy protocol is set up and ready to work now. One should also set up the web application and BI servers to make sure all the work is executed via the set balancer.

  1. In the config.json we application configuration file specify balancer address and port to work via WebSocket:

{

  "targetRepo": "",

  "serviceUrl": "http://<balancer IP address>:555/fp10.x/app/PPService.axd",

  "locale": "ru",

  "locales": ["ru"],

  "title": "FAP10",

  "baseUrl": "",

  "themes": ["fap10"],

  "webSocketPort": 8080

}

In serviceUrl in the balancer address specify the port from the ft_web_bi section, and in webSocketPort specify the port from the ft_ws_bi section of HAProxy balancer settings.

  1. In the registry or the settings.xml settings file of each BI server set a proper port, via which work via the WebSocket protocol will be executed. Ports should correspond to the ports that were specified in the bk_ws_bi section of HAProxy balancer settings:

<Configuration>

<Root>

<Key Name="PP">

<BIS>

<Key Name="System">

<WebForms Port="9091"/>

</Key>

</BIS>

</Key>

</Root>

</Configuration>

The setup is finished now. If everything is correct, the web application will be available at: http://<balancer IP address>:555/fp10.x/r/#/.

See also:

Creating BI Servers Cluster