socket_buffer_reuse

The `socket_buffer_reuse` directive controls the reuse of socket buffers for WebAssembly modules in NGINX.

Syntaxsocket_buffer_reuse on | off;
Defaultoff
Context
Arguments1

Description

The socket_buffer_reuse directive is part of the NGINX configuration for managing WebAssembly modules, particularly within the context of the Proxy-Wasm architecture. This directive specifies whether to allow the reuse of socket buffers when working with WebAssembly filters. When enabled, it can improve performance by reducing the overhead associated with creating new socket buffers for each request processed by a WebAssembly module.

This directive is primarily relevant when configuring WebAssembly modules that interact with network sockets, particularly in high-throughput scenarios where creating new buffers for each operation might introduce latency. By reusing buffers, the NGINX instance may handle requests more efficiently, as it minimizes memory allocation and deallocation overhead. The directive takes a single argument that determines the enablement of socket buffer reuse, allowing configuration flexibility depending on the application's needs.

When deploying the socket_buffer_reuse directive, users should keep in mind that while reusing socket buffers can enhance performance, it may also introduce complexity in buffer management, particularly in concurrent request handling. This necessitates careful consideration of the application's specific requirements to balance efficiency with potential complications arising from buffer state management.

Config Example

wasm {
    module my_filter /path/to/filter.wasm;
    socket_buffer_reuse on;
}

Ensure that the socket buffer reuse is appropriate for your application workload, as inappropriate buffer management can lead to issues with data integrity.

Be cautious about enabling this directive in contexts where buffer state needs to be consistent across requests.

← Back to all directives