Proxy and loadbalancer example with HAProxy

We use HAProxy as a reverse proxy and loadbalancer as described in Topology for HA cluster.

The URI that can be redirected to the replica nodes are the queries that only retrieve data from the server (no absorption).

In this example, the following URI are redirected to the replica nodes:

  • pagelet execution queries: /rest/ui/dashboards/dashboard-.*/pagelets/pagelet-.*

  • parameters queries: /rest/ui/dashboards/dashboard-.*/pagelets/parameters-.*

Other queries are redirected to the active HA main node.

Configuration file

    maxconn 2000

    mode    http
    retries 3
    option redispatch
    timeout connect  5000
    timeout client  10000
    timeout server  10000

# Proxy URL to use for FLEX replicas configuration
listen flex_proxy
    mode http
    balance roundrobin
    option httpclose
    option forwardfor
    server node1 track queries/replica1
    server node2 track queries/replica2
# Define a group of servers for the UI query requests
frontend front
    mode http
    # Redirect all parameters and pagelet queries to the Replica servers
    acl url_api path_reg ^\/hvp\\/rest\\/ui\/dashboards\/dashboard-.*/(parameters|pagelet-)
    use_backend queries if url_api
    # Other queries are redirected to primary group
    default_backend primary

# Accept Replica node if heartbeat declares it is SYNCHRONIZED
backend queries
    mode http
    option httpchk GET /hvp/heartbeat/synchronizationStatus/status HTTP/1.1\r\n10.0.0.1
    http-check expect string "SYNCHRONIZED"
    server replica1 check
    server replica2 check
    server ha1 track primary/ha1
    server ha2 track primary/ha2
# Accept HA node if heartbeat declares it is HA MAIN (HTTP reply 200)
backend primary
    mode http
    option httpchk GET /hvp/heartbeat/ha HTTP/1.1\r\nHost:
    server ha1 check
    server ha2 check

Related Links