Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Server_names_hash_bucket_size problem of nginx

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report