On Fri, May 09, 2014 at 07:54:33PM -0400, Rajat Chopra wrote:
> > No that much. I'm thinking about something. Maps can retrieve the first
> > matching prefix using "map_beg". So if you pass "base" to your map, you'll
> > have the host+path on input, and take the first matching prefix. Thus, it
> > will give you this :
> > 
> >    use_backend bk_%[base,map_beg(mapfile)]
> > 
> > The file would contain all the host+path sorted from the longest to the
> > shortest (basically just a sort -r) :
> > 
> >    domain1/path1/       backend1
> >    domain1/path2/       backend2
> >    domain1/             backend3
> >    domain2/path1/       backend1
> >    domain2/             backend4
> > 
> > The only problem is that the "beg" match needs to iterate over all entries,
> > so it will be slower than a tree based lookup, but much faster than running
> > 150k rules!
> > 
> 
> That looks great.
> Humble opinion here, or just my discomfort maybe. The map_beg will certainly
> solve my current case, but it feels like that a generic user callable
> function would offload the myriad other cases that might crop up in the
> future. Pretty sure someone will ask for a map_reg down the line - a map with
> keys as compiled regexes is compelling.

But it already exists as well. In fact, all the operators you have for the ACLs
also exist for the maps. Hmmm I just realized that for whatever reason, map_beg
was missing from the map_* table in the doc, which might explain why you didn't
find it. Just fixed it.

> > And further, I think that with some tweeking, we could make the "beg" match
> > use the longest prefix match function of the ebtrees. I remember that 
> > there's
> > something tricky about it related to the string length, but if we need to 
> > pad
> > with a zero or something like this, it might not be a big deal. So maybe in
> > the end we could improve the map match to lookup host+uri prefixes faster
> > than we do today.
> > 
> > That would be great for URL or Location rewriting!
> > 
> 
> May I ask about the ETA on this?

It's too early for me to know, I need to go down deep into the ebtrees first to
see if longest match is compatible with strings storage-wise, then I need to
study how patterns are built as trees to see how to do that as well. Possibly
it's just one or two days of work once I understand everything.

Regards,
Willy


Reply via email to