nginx could not the server_names_hash solution

  • 2020-05-06 12:13:16
  • OfStack

nginx "nginx could not build the server_names_hash" solution

Add a few site aliases to a server, almost 20 of them.

When restarting nginx, prompt:

could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32

solution:

Add a line in the http{} section of the configuration file to configure
server_names_hash_bucket_size 64;
If 64 is not enough, then add a multiple of 32.

The following is an excerpt from the Chinese wiki:

The hash table holding the server name is controlled by the directives server_names_hash_max_size and server_names_hash_bucket_size. The hash bucket size parameter is always equal to the size of the hash table and is a multiple of the size of the processor cache. After reducing the number of accesses in memory, it is possible to accelerate the lookup of hash table keys in the processor. If hash bucket size is equal to the size of the processor cache along the way, the number of worst-case lookups in memory is 2 when the key is found. The first time is to determine the address of the storage unit, and the second time is to look up the key value in the storage unit. Therefore, if Nginx indicates that you need to increase hash max size or hash bucket size, the first thing to do is to increase the size of the previous parameter.

Related articles: