This document explains the load balancer configuration for the Panchayatseva project, detailing ACLs, backend settings, health checks, sticky sessions, timeouts, and monitoring.
The following configuration defines Access Control Lists (ACLs) to route incoming requests to the appropriate backend servers based on the Host
header:
acl ACL_pssb_webservers hdr(host) -i sb.panchayatseva.com
acl ACL_pssb_webservers hdr(host) -i app.sb.panchayatseva.com
acl ACL_pssb_webservers hdr(host) -i api.sb.panchayatseva.com
acl ACL_pssb_webservers hdr(host) -i apd.sb.panchayatseva.com
use_backend pssb_webservers if ACL_pssb_webservers
ACL_pssb_webservers
: Matches requests with the following hostnames:
sb.panchayatseva.com
app.sb.panchayatseva.com
api.sb.panchayatseva.com
apd.sb.panchayatseva.com
All domains here using the same Access Control List(ACL) means it does have single backend webserver.
use_backend pssb_webservers if ACL_pssb_webservers
: Routes requests matching ACL_pssb_webservers
to the backend pssb_webservers
.This setup ensures that traffic is directed to the correct backend based on the requested domain, improving scalability and ensuring proper handling of traffic for different subdomains.
The load balancer manages the pool of web servers under the pssb_webservers
backend. Below is a line-by-line explanation of the configuration:
backend pssb_webservers
timeout queue 25s
balance leastconn
option httpchk
http-check send meth GET uri /apm/mon/health
http-check expect status 200
timeout check 15s
cookie pssblb insert indirect nocache
stick-table type ip size 1m expire 12h
stick on cookie(pssbhz)
option redispatch
server pssb1avm001 172.21.0.61:8182 maxconn 5000 check inter 55s fall 3 rise 3 cookie pssb1avm001 observe layer4 error-limit 9 on-error mark-down
server pssb1avm002 172.21.0.62:8182 maxconn 5000 check inter 55s fall 3 rise 3 cookie pssb1avm002 observe layer4 error-limit 9 on-error mark-down
server pssb1abm003 172.21.0.63:8182 maxconn 5000 check inter 55s fall 3 rise 3 cookie pssb1abm003 observe layer4 error-limit 9 on-error mark-down
server pssb1avm004 172.21.0.64:8182 maxconn 5000 check inter 55s fall 3 rise 3 cookie pssb1avm004 observe layer4 error-limit 9 on-error mark-down
server pssb1avm005 172.21.0.65:8182 maxconn 5000 check inter 55s fall 3 rise 3 cookie pssb1avm005 observe layer4 error-limit 9 on-error mark-down
timeout queue 25s
: Sets a maximum queue wait time of 25 seconds for client requests when all servers are busy.balance leastconn
: Routes traffic to the server with the least active connections, ensuring even distribution.option httpchk
: Enables HTTP-based health checks.http-check send meth GET uri /apm/mon/health
: Sends a GET
request to /apm/mon/health
for health verification.http-check expect status 200
: Expects an HTTP 200 OK
response from the health check API.timeout check 15s
: Configures a timeout of 15 seconds for receiving a health check response.cookie pssblb insert indirect nocache
: Inserts a session cookie named pssblb
in responses, ensuring stickiness, while preventing it from being cached.stick-table type ip size 1m expire 12h
: Tracks client-server mapping for up to 1 million IP addresses, expiring entries after 12 hours.stick on cookie(pssbhz)
: Bases sticky session behavior on the pssbhz
cookie.timeout queue 25s
: Sets the maximum time a request waits in the queue.timeout check 15s
: Limits the time to receive a health check response.Each server in the backend is configured with the following parameters:
server pssb1avm001 172.21.0.61:8182 maxconn 5000 check inter 55s fall 3 rise 3 cookie pssb1avm001 observe layer4 error-limit 9 on-error mark-down
pssb1avm001
.172.21.0.61:8182
.maxconn 5000
: Limits the maximum concurrent connections to 5000.check inter 55s
: Performs health checks at 55-second intervals.fall 3 rise 3
: Marks a server down after 3 consecutive failures and up after 3 consecutive successes.cookie pssb1avm001
: Assigns a unique cookie for sticky sessions.observe layer4
: Monitors TCP-level errors.error-limit 9
and on-error mark-down
: Marks the server as down if it exceeds 9 TCP errors.The /apm/mon/health
endpoint provides status codes to identify issues with the underlying stack components. These codes are returned during health checks:
520
, 521
, 522
.526
, 527
, 528
.531
, 532
, 533
.536
, 537
, 538
.541
, 542
, 543
.These codes allow targeted diagnosis of the stack component causing issues.
HAProxy statistics can be viewed at the following URL:
haproxy
1!Qhaproxy
This dashboard provides real-time insights into load balancer performance and server health.
This load balancer configuration ensures:
This setup optimizes the availability and performance of the Panchayatseva application.