Welcome! Log In Create A New Profile

Advanced

Re: any datagroup type solution for nginx

Francis Daly
May 07, 2021 10:22AM
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@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

any datagroup type solution for nginx

Oğuz Yarımtepe April 27, 2021 07:50AM

Re: any datagroup type solution for nginx

Francis Daly May 07, 2021 10:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 298
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready