referer_hash_bucket_size

The `referer_hash_bucket_size` directive sets the size of the hash buckets used for storing HTTP referer headers in NGINX.

Syntaxreferer_hash_bucket_size size;
Default64
Contextserver, location
Arguments1

Description

The referer_hash_bucket_size directive is an essential configuration option for managing referer header storage in NGINX. It dictates the bucket size for the hash table that stores the referers, which can be particularly useful in high-traffic environments where the size of request headers can significantly impact performance. By optimizing the bucket size, you can improve the efficiency of hash function lookups, minimizing collisions and ensuring that referer entries are processed more swiftly.

This directive can be set within the http, server, or location contexts, allowing for flexible configuration based on application needs. The value specified should be a power of two or close to the optimal size to fit the expected number of referers. To achieve optimal performance, the value must be carefully chosen relative to the system’s architecture and expected traffic patterns, as improper values can lead to increased memory usage or inefficient hash table operations, affecting overall performance.

Adjusting this directive can be critical after analyzing server performance, especially when encountering large sets of unique referer headers. Essentially, referer_hash_bucket_size plays a crucial role in both memory management and response speed associated with referer processing, adding to the robustness of NGINX as a web server.

Config Example

http {
    referer_hash_bucket_size 128;
}

Setting the bucket size too small may lead to hash collisions, degrading performance.

Values should ideally be a power of two for optimal efficiency.

Changing this value after high traffic has been established without proper testing can impact live services.

← Back to all directives