title: Is it possible in haproxy to have sticky sessions based on cookie and still load balance?
body: <p>So if this is the backend config:</p>
  
  <p><code>backend main
      mode http
      balance leastconn
      cookie serverid insert indirect nocache
      stick-table type string len 36 size 1m expire 8h
      stick on cookie(JSESSIONID)<br>
      option httpchk HEAD /web1 HTTP/1.0
      http-check expect ! rstatus ^5
      server monintdevweb 10.333.33.33:443 check cookie check ssl verify none #web1 
      server monintdevweb2 10.222.22.122:443 check cookie check ssl verify none #web2<br>
      server localmaint 10.100.00.105:9042 backup #maint 
      option log-health-checks<br>
      option redispatch
      timeout connect 1s
      timeout queue 5s 
      timeout server 3600s</code></p>
  
  <p>It seems it always sends all users to web1. i.e. its not evenly load balancing using leastconn algorithm specified. I tried with stick table using src IP and that does what i want - ie persist sessions but each new session should get balanced between servers. Is it not possible to have that using cookies?
  Another problem with cookies i noticed was that if I were to bring down  services on the web1, all users get redirected to web2 and then redirected back to web1 when web1 is restored!! What real life scenario would find this behavior be useful?</p>