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
Thanks for this!