9

I have a system which is load balancing via a cookie, but I want to use a URL parameter as an alternative. (Specifically, I have a front end app which does not support cookies). My setup is a little complex - I have a multiplayer system and I use a stick table with this cookie to make sure different people playing the same game go to the same server. This works great, except that the URL parameters don't seem to do anything. This is all with haproxy 1.5dev17

My relevant backend is:

defaults
   log            global
   mode           http
   option         httplog
   option         dontlognull
   retries        3
   option         redispatch
   option         http-server-close

   maxconn        2000
   contimeout     5000
   clitimeout     50000
   srvtimeout     50000

backend simulate
    option httpchk OPTIONS /simulate/api/status
    stick-table type string len 40 size 5M expire 30m
    stick store-response set-cookie(SIMULATE_STICKY_SESSION) table simulate
    stick on cookie(SIMULATE_STICKY_SESSION) table simulate
    stick on url_param(SIMULATE_STICKY_SESSION) table simulate

    server app1 10.0.2.11:8080  cookie app1 check inter 10000
    server app2 10.0.3.11:8080  cookie app2 check inter 10000

Note that SIMULATE_STICKY_SESSION is generated by my app (based on player team).

When I call the URL, I need to pass a jsessionid (so that Tomcat will find the correct session). So I am doing

http://my.domain.com/myapp/url;SIMULATE_STICKY_SESSION=1918C909D3F30DB09C2F96B75C57D015.app1+jsessionid;jsessionid=1918C909D3F30DB09C2F96B75C57D015.app1

This doesn't seem to be picking up the sticky session parameter as 50% of the time it goes to the wrong server. I tried using the param as a query string (after a ? mark) but that didn't work either. What am I doing wrong?

1 Answer 1

3

A response was provided here on the haproxy mailing list

excerpt

simply update the line below in your configuration to:

 stick on url_param(SIMULATE_STICKY_SESSION,;) table simulate

By default, url_param search for a parameter after the question mark (?). The configuration above overwrite this by looking for your cookie from the semi-colon (;).

Note: you must be running a recent 1.5dev haproxy, preferably the dev 18.

1
  • As noted on the user list, the answer is to change the line to: stick on url_param(SIMULATE_STICKY_SESSION,;) table simulate
    – Will Glass
    Apr 6, 2013 at 17:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .