any datagroup type solution for nginx
Francis Daly
francis at daoine.org
Fri May 7 14:20:23 UTC 2021
On Tue, Apr 27, 2021 at 02:49:04PM +0300, Oğuz Yarımtepe wrote:
Hi there,
> I have large list of paths going to same backend:
>
> location ~ /xxx { proxy_pass http://backend_foo; }
> location ~ /yyy { proxy_pass http://backend_foo; }
> location ~ /zzz { proxy_pass http://backend_foo; }
> location ~ /mmm { proxy_pass http://backend_foo; }
> ....
>
> The number of paths are 3254. So writing them line by line doesn't look so
> nice to me. any other more performance solution? Maybe with lua and in
> memory solution?
Are you concerned about writing 3000 lines, or with nginx being able to
handle a config with 3000 lines?
If it is "writing", then you can use your favourite templating or
macro-processing language to turn your input into the expected output.
If it is "handling", then I'd suggest that if you don't measure a
performance problem, there is not a performance problem that you care
about.
If the paths are really path-prefixes, then using
location ^~ /xxx {}
instead of the "~" regex marker will probably be faster to process.
And if they are all regex, and you measure a problem, then you might be
able to rearrange the order, or group some into fewer, bigger regexes,
to see if that helps the problem.
But unless you have an error message or a measured performance problem,
it is probably worth sticking with the "naïve" approach.
Cheers,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list