haproxyhaproxy-ingress

HAProxy: get stick-table size


I want to set limit of new users' connections if amount of active users exceeded the required threshold. Users connect to the load balancer via http. I use stick-table to limit the amount of http request per user (by unique ip):

frontend echo
    bind *:8881
    mode http

    stick-table  type ipv6 size 100 expire 100s store http_req_rate(10s)
    http-request track-sc0 src
    http-request deny deny_status 429 if { src_http_req_rate gt 100 }

    use_backend echo

How get current the amount ip addresses of "active" users which contains in the stick-table (looks like I have to get current size of the table)?


Solution

  • table_cnt may be helpful here
    something like:

    http-request deny deny_status 429 if { table_cnt gt 80 }
    

    in case of your stick-table this would block users if you get over 80 unique IPs in the last 100 seconds.