Forum: NGINX Poor performance when loading huge number of server section

9965f804f999d522b1e537f19deff283?d=identicon&s=25 Anb (Guest)
on 2013-08-09 07:42
(Received via mailing list)
Hi there,
  I got a problem when using nginx as a reverse proxy. Configurations
using per server policy to set upstream host. Nginx spends significant
time loading config files as while as virtual server inscreased to a
large number. Here's a rough statistics:

| server sections | load time(sec) |
|-----------------+----------------|
|           50000 |            242 |
|           80000 |            910 |
|          100000 |           1764 |

I know this is an unusual usage of nginx, but there is such demand.

So I want to know:
1. Is nginx not designed to use such large number of config?
2. Does someone has some experience on this? Could you please show me a
clue?

Thanks.

--
anb
2013.8.9
2154be8b4430488454f0a067e09863b9?d=identicon&s=25 Ruslan Ermilov (Guest)
on 2013-08-09 10:22
(Received via mailing list)
On Fri, Aug 09, 2013 at 01:41:49PM +0800, Anb wrote:
> |          100000 |           1764 |
>
> I know this is an unusual usage of nginx, but there is such demand.
>
> So I want to know:
> 1. Is nginx not designed to use such large number of config?
> 2. Does someone has some experience on this? Could you please show me a clue?
>
> Thanks.

How about mapping $server_name to upstream instead?

map $server_name $upstream {
    default ...;
    [100k entries]
}

server {
    ...
    proxy_pass http://$upstream;
    ...
}
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.