shm_queue

The shm_queue directive configures shared memory queues for inter-process communication in WebAssembly-based NGINX modules.

Syntaxshm_queue name size [max_size];
Defaultnone
Context
Arguments2-3

Description

The shm_queue directive is part of the NGINX Proxy-Wasm module that facilitates shared memory management for WebAssembly applications running in NGINX. This directive allows you to configure FIFO (first-in-first-out) queues in shared memory, which can be utilized for communication between different NGINX worker processes or between WebAssembly modules. The directive helps streamline the workflow by allowing data produced by one process to be consumed by another, enhancing the modularity and performance of complex applications that utilize shared resources.

The shm_queue directive accepts 2-3 parameters. The first parameter specifies the name of the queue, which must be unique within the NGINX configuration. The second parameter defines the size of the queue, which determines how many messages can be stored in it at once. Optionally, a third parameter can be provided to set the maximum size for each individual message or to specify custom settings for the encoded data. If this third parameter is omitted, a default maximum size will be applied based on the internal configuration of the module. This flexibility allows developers to tailor the queue's behavior to their application's specific requirements.

Config Example

shm_queue my_queue 1000 256;

Ensure the queue name is unique to avoid conflicts with other shared resources.

Properly manage the queue size to prevent overflow, as exceeding the defined size could lead to dropped messages or errors.

When using the optional max_size parameter, ensure that it aligns with the size of the data being sent to prevent truncation.

← Back to all directives