On Tue, Aug 21, 2012 at 11:19:57AM -0400, S Ahmed wrote:
> Hello,
> 
> Any updates or guestimates on if sticky-table feature will be released?
> 
> Just haven't been watching this list for a while and curious if there has
> been any progress.

Just thinking out loud, until the "track url" feature is implemented, I
believe you could chain two instances of haproxy and achieve what you need :

  listen first-layer
     bind :80
     stick-table type string len 100 size 250k
     stick-match url
     balance round-robin
     server limit 127.0.0.1:1111 weight 0 id 1 maxconn 1000
     server srv1 192.168.1.1:80
     server srv2 192.168.1.2:80
     server srv3 192.168.1.3:80

  listen second-layer
     bind 127.0.0.1:1111
     rate-limit 100
     balance round-robin
     server srv1 192.168.1.1:80
     server srv2 192.168.1.2:80
     server srv3 192.168.1.3:80

Above, the first layer receives requests. If the URL is found in the stick
table, it uses the server stored there, otherwise it uses the normal servers
(srv1..srv3) which are the only ones with a non-zero weight. The idea is to
only assign server "limit" to the URLs which match the stick table so that
this server is selected only for URLs you want.

When this second server is selected, the traffic is forwarded to the second
proxy (second-layer) which uses the same servers (for instance) and applies
a rate-limit of 100 req/s. Since the first layer's maxconn also has a maxconn,
excess requests will be queued.

In order to force the ID, I see two possibilities :
  - use a "store-request url if XXX" statement where XXX is a condition
    on the request which also ensures that the requested server will be
    used, for instance based on a cookie or source address. For instance :

      stick store-request url if { src 192.168.0.0/24 }
      use-server limit if { src 192.168.0.0/24 }

    That way entries will only be added when the traffic is sent to that
    server. However I don't see how to remove them.

  - manually feed these entries on the CLI :

      echo "set table first-layer key /a/b/c" | socat stdio 
/var/run/haproxy.sock

The advantage of the last method is that you can add/remove/list table
entries from the same control point, which is much better in my opinion.

Hoping this helps,
Willy


Reply via email to