Hi Joao,

On Tue, Feb 02, 2021 at 09:03:06PM -0300, Joao Morais wrote:
> 
> Hello list, I've about 5000 hostnames + path that should be mapped to 3000 
> backends or so. I'm using map converters and the lay out is something like 
> this:
> 
> /dir/file.map
>     d1.tld/path/sub back1
>     d1.tld/path back2
>     d2.tld/path/sub/other back3
>     d2.tld/path/sub back4
>     d2.tld/path back5
>     d3.tld/path/sub back6
>     d3.tld/path back7
> 
> And frontend looks like this:
> 
>     http-request set-var(req.backend) base,map_beg(/dir/file.map)
>     use_backend %[var(req.backend)] if { var(req.backend) -m found }
> 
> The problem here is that the map has about 5k lines and the search isn't
> indexed. I could eg split this map into smaller ones and create an index of
> maps stored in another map, but cannot use the result because the file name
> param in the converter cannot be dynamic. Any other idea to help haproxy find
> the backend in a faster way?

Not sure why you're saying it's not indexed. It uses map_beg so it will
use a prefix tree for the lookup, it should be pretty fast.

By the way, you could simplify your rules this way:

     use_backend base,map_beg(/dir/file.map)

Indeed, a use_backend rule which doesn't find the backend will do nothing
and continue to next rules.

Willy

Reply via email to