While I'm learning how to use Nginx, I was instructed to update the server_names_hash_bucket_size
(/etc/nginx/nginx.conf
) value from 32 to 64, but I don't understand why should I increase the value to 64.
References that have been read so far:
- See the Server names, Optimization section.
- See setting up hashes
- See server_names_hash_bucket_size
- See server_names_hash_max_size
- The default value of
server_names_hash_bucket_size
depends on the size of the processor’s cache line - If a large number of server names are defined, or unusually long server names are defined, tuning the server_names_hash_max_size and server_names_hash_bucket_size directives at the http level may become necessary.
- If the default value of server_names_hash_bucket_size used at the server is not enough, means nginx complained with
could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
, the directive value should be increased to the next power of two (e.g. in this case to 64). - If a large number of server names are defined, and nginx complained with the following error
could not build the server_names_hash, you should increase either server_names_hash_max_size: 512 or server_names_hash_bucket_size: 32
. try to set server_names_hash_max_size to a number close to the number of server names. Only if this does not help, or if nginx’s start time is unacceptably long, try to increase server_names_hash_bucket_size. - The hash bucket size parameter is aligned to the size that is a multiple of the processor’s cache line size
With only 50 subdomains I had an NGinx crash with this error "could not build server_names_hash, you should increase server_names_hash_bucket_size: 64" just after adding a new one.
Investigating the issue : the last sub-domain added was 32 carracters long (total server_name with domain&tld = 48)
I don't understand why the length of server names is limited by this parameter, i'm still far from the official (RFC) limits for URLs. (and very very far from hash collisions)
I need to have a close look on this topic because in my case several subdomains are created arround a client choice for the "base name", so I need to know wich limit should I impose for this "base name".