Get the App
SLTechnology News&Howtos  ›  Servers  › 

Server_names_hash_bucket_size problem of nginx

Shulou Source: shulou.com Published: 2022-06-02 08:44:43 10月13日 Update

Before, nginx can be started normally, but later, for the convenience of testing, some more domain names have been added and all transferred to the same upstream, which cannot be started.

Go to logs/errors.log and find the following words:

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

It turns out that after adding multiple domain names, the hash can no longer be stored normally under the default size, so you need to modify the size of this parameter.

Modify the http section in conf/nginx.conf to the following example

Http {

Server_names_hash_bucket_size 64

Include mime.types

Default_type application/octet-stream

. Omit

In order to increase convenience in the future, it is not directly modified to the size of 32 indicated in the log, but to 64.

Start again and run normally

The following is an excerpt from the Chinese wiki

The hash table that holds the server name is controlled by the instructions server_names_hash_max_size and server_names_hash_bucket_size. The parameter hash bucket size is always equal to the size of the hash table and is a multiple of the cache size of one processor. After reducing the number of access times in memory, it is possible to speed up the lookup of hash table key values in the processor. If hash bucket size is equal to the size of a processor cache, then when looking for keys, the number of times to look in memory at worst is 2. The first time is to determine the address of the memory unit, and the second time is to look up the key value in the memory unit. Therefore, if Nginx gives a hint that you need to increase hash max size or hash bucket size, the first thing is to increase the size of the previous parameter.

Tags: Size parameters processor processing storage memory unit is in number of times cache prompt same multiple again name address domain name multiple domain name word case Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux NVidia Microsoft Huawei Shulou Information