Hi Rajat, On Thu, Mar 27, 2014 at 08:57:09PM -0400, Rajat Chopra wrote: > Hi! > This solution very much solves the problem that I have been facing i.e. > large number of acl rules causing latency in requests. Been in discussions > separately about it and today I got a chance to test out this patch. I > report that it works great! I have been able to route 150k backends with > this and the latency added because of the dynamic lookup is in order of > microseconds (compared to 24ms earlier).
Thanks for the performance measurement. > The usage 'use_backend bk_%[hdr(Host)] if TRUE' works for my use-case but > originally I was wondering if one could do a map based lookup for the > backend. Yes, it works the same. We need to make the condition optional by the way. > As posted here : > http://stackoverflow.com/questions/22025412/how-to-use-thousands-of-backends-in-haproxy-is-the-new-map-feature-useful-for-t > > Most of the issues in the above question are now solved, but I tested this > with the patch -> > use_backend bk_%[hdr(Host), map(host_to_backend_map.file)] if TRUE > And it does not work. Haproxy 1.5 and earlier cut the lines in words around spaces, so above your expression does not work because it's split in two. Just remove the space before "map" and it will do exactly what you need. Also I think it's better to use a map than the plain header because this way you can ensure what the exact list of accessible backends will be, and you can also get rid of some matching details such as lower/upper case etc... > I am not yet familiar with code to determine why this does not work. Again, > the current proposal works well for me but an enhancement should probably > consider using maps within dynamic lookup. > > +1 for the patch. Great, thanks for your feedback! Do you think that use-server would simplify your configuration (eg: have only one backend with thousands of servers, one per host) ? We could then imagine something like this : frontend foo use_backend bk_%[hdr(host),map(host_to_backend.map)] bk_host_xxx server 1 ... server 2 ... bk_virtual_hosted use-server srv_%[hdr(host),map(host_to_server.map)] server srv_1 ... server srv_2 ... The idea would be to have a few backends for multi-server hosts, and a single backend with all single-server hosts and as many servers. But maybe this would make the config more complex in the end, I don't know. I think the natural next step is the "usedst" server directive that people who want to run proxies are requesting :-) Willy

