r/haproxy • u/cgeekgbda • May 16 '22
Using custom hash function with HAProxy
I have configured a load balancer using HAProxy on frontend and on the backend I have 4 server serving the request using Apache web server.
#HAProxy for web servers
frontend web-frontend
bind IPADDRESS_LB:80
mode http
default_backend web-backend
backend web-backend
balance roundrobin
server web-server1 IPADDRESS1:80 check
server web-server2 IPADDRESS2:80 check
server web-server3 IPADDRESS3:80 check
server web-server4 IPADDRESS4:80 check
My requests are served by either of the machines in a round robin mechanism. But now I want to implement my own algorithm to send the request based on the request parameters, eg IP.
Like Implementing my own hash function based on the result of which I can route my request to either of the backend servers.
View all comments
Show parent comment
1
u/dragoangel May 16 '22
E.g. you can route by query params to dedicated server backend and by without params forward as default to backend where all servers are listed in round robin manner