# Poor performance when loading huge number of server section

**URL:** <https://www.ruby-forum.com/t/poor-performance-when-loading-huge-number-of-server-section/236141>\
**Category:** NGINX\
**Created:** [August 9, 2013, 7:42am UTC](https://www.ruby-forum.com/t/poor-performance-when-loading-huge-number-of-server-section/236141 "2013-08-09T07:42:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [August 9, 2013, 7:42am UTC](https://www.ruby-forum.com/t/poor-performance-when-loading-huge-number-of-server-section/236141/1 "2013-08-09T07:42:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Anb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e0b2c6/32.png) [@Anb](https://www.ruby-forum.com/u/Anb)\
**Post date:** [August 9, 2013, 10:22am UTC](https://www.ruby-forum.com/t/poor-performance-when-loading-huge-number-of-server-section/236141/2 "2013-08-09T10:22:30Z")

</div>

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;  
…  
}
