Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drexler/7350aeb96897292a03a73d0ce51d1bf1 to your computer and use it in GitHub Desktop.
Save drexler/7350aeb96897292a03a73d0ce51d1bf1 to your computer and use it in GitHub Desktop.
Nginx: What is server_names_hash_bucket_size?

Background

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

References that have been read so far:

Key takeaways

  • 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment