Poor performance when loading huge number of server section

Ruslan Ermilov ru at nginx.com
Fri Aug 9 08:21:46 UTC 2013


On Fri, Aug 09, 2013 at 01:41:49PM +0800, Anb wrote:
> 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.

How about mapping $server_name to upstream instead?

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

server {
    ...
    proxy_pass http://$upstream;
    ...
}



More information about the nginx mailing list