kqueue_events

The kqueue_events directive configures NGINX to utilize the kqueue event notification framework on BSD systems for efficient event handling.

Syntaxkqueue_events;
Defaultnone
Contextevents
Arguments1

Description

The kqueue_events directive is specifically designed for use in the events context of the NGINX configuration. It instructs NGINX to use the kqueue event notification mechanism, which is highly efficient and particularly suited for handling a large number of simultaneous connections on BSD-compatible operating systems like FreeBSD and macOS. By leveraging kqueue, NGINX can actively monitor multiple file descriptors, reducing CPU overhead associated with polling and enabling more scalable performance under load.

When the kqueue_events directive is enabled, it affects how worker processes handle events by allowing them to wake idle connections only when there's an actual event, such as data coming in or the connection being closed. This is in contrast to older event mechanisms that might require periodic polling, which can drain resources as connections grow. It's important to ensure that your NGINX installation is compiled with kqueue support, as this directive will not function if the underlying OS or build does not support kqueue.

This directive takes a single argument, which serves to toggle the use of kqueue. If correctly configured, the benefits include lower resource consumption and improved speed due to faster event handling. It’s essential to test the configuration in a staging environment to ensure that it’s working as expected without introducing unforeseen issues.

Config Example

events {
    kqueue_events;
}

Ensure that NGINX is built with kqueue support; otherwise, the directive will have no effect.

Using kqueue is ideal only for BSD systems; using this directive on unsupported platforms may result in errors.

← Back to all directives