<div dir="ltr">Thank you, that makes sense and a bit of testing reveals that is correct.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 16, 2014 at 8:59 PM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<div><div class="h5"><br>
On Wed, Apr 16, 2014 at 08:38:10PM +1000, SplitIce wrote:<br>
<br>
> Hi all,<br>
><br>
> I have spent the day troubleshooting why one server in our network reloaded<br>
> / tested configuration extremely slowly.<br>
><br>
> We have found that server_names scales very poorly, once a certain point is<br>
> reached (approx 5.5k entries globally, 5k entries for a single host)<br>
> performance drops from a <0.5s reload time to 15s+.<br>
><br>
> The large host of ~5,000 entries is a malware domain zone and all server<br>
> names in this zone are using the wildcard name format.<br>
><br>
> For now we have resolved this issue by fixing an inefficiency in our<br>
> configuration (namely using *.<a href="http://domain.com" target="_blank">domain.com</a> and <a href="http://domain.com" target="_blank">domain.com</a>) however I feel<br>
> this is most likely a bug or at-least an unintended behaviour.<br>
><br>
> Relevant configuration entries:<br>
> server_names_hash_max_size 8000;<br>
> server_names_hash_bucket_size 128;<br>
<br>
</div></div>With max_size 8000, and 5k entries - probability of collisions<br>
while building a cache is high (think of birthday paradox).  And<br>
bucket_size 128 isn't high enough to allow multiple collisions.<br>
As a result, nginx may (and likely will) spend a lot of time trying<br>
to build an optimal hash.<br>
<br>
Trivial solution is to use higher max_size and/or bucket_size.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Maxim Dounin<br>
<a href="http://nginx.org/" target="_blank">http://nginx.org/</a><br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</font></span></blockquote></div><br></div>