HAProxy community

HAProxy nested loadbalancing


I have written following config file:

frontend http-in
bind *:8010
default_backend gateway

frontend http-in-1
    bind *:8011
    default_backend bucket-1

frontend http-in-2
    bind *:8012
    default_backend bucket-2

backend gateway
    balance url_param hello
    hash-type consistent
    server lb-1-1 localhost:8011
    server lb-1-2 localhost:8012

backend bucket-1
    balance roundrobin
    server server1-1 hello_web_1:4000 check
    server server1-2 hello_web_2:4000 check
    server server1-3 hello_web_3:4000 check

backend bucket-2
    balance roundrobin
    server server2-4 hello_web_4:4000 check
    server server2-5 hello_web_5:4000 check

The idea behind it is to always forward traffic to the same bucket based on parameter in URL and then split it on multiple workers inside bucket.

Following configuration is equal to two loadbalancers behind a gateway. I am not happy with this solution, cause it requires 4 IO operations to process a packet.

I was wondering, could it only forward traffic from one backend to another. In this situation from gateway directly to bucket-1 and bucket-2? This operation should be done on CPU.


I’m pretty sure this can be done via ACLs. Reading this should help: https://stackoverflow.com/questions/20606544/haproxy-url-based-routing-with-load-balancing . I hope I understood your request correctly.