We have a mobile game client running on websocket connections and we want to use HAProxy as a load balancer. There are two main conditions:
- Set sticky session based on url parameter ID (varying string between 32 to 64 chars) and then select server based on least connections
- If there is no ID parameter select the first or default server
Here is the sample configuration for handling first condition:
backend app
balance leastconn
stick-table type string len 64 size 5M expire 30m
stick store-request url_param(ID) table app
stick on url_param(ID) table app
server app1 127.0.0.1:5001 check
server app2 127.0.0.1:5002 check
The problem is sticky session doesn't work as expected and doesn't connect to last connected server. Can you provide any suggestions to improve it and ideally satisfy the second condition?
We are using HAProxy version 1.8.17 provided with CentOS SCL.
Thanks in advance.