uwsgi_buffering

The `uwsgi_buffering` directive controls whether NGINX buffers responses from uWSGI applications.

Syntaxuwsgi_buffering on | off;
Defaulton
Contexthttp, server, location
Argumentsflag

Description

The uwsgi_buffering directive is used within NGINX to determine how responses from an upstream uWSGI server are handled. When set to 'on', NGINX will buffer the entire response from the uWSGI application before sending it to the client. This can be useful for optimizing the delivery of content by allowing NGINX to handle responses internally, thus reducing the number of TCP packets sent to the client and improving the efficiency of connection handling.

Conversely, when set to 'off', NGINX will stream the response to the client as it is received from the uWSGI application. This setting can be beneficial for applications that produce output incrementally or when real-time response is necessary, such as in the case of long-polling or server-sent events.

The directive is flexible, allowing it to be used in the http, server, or location contexts. Its value is a flag, accepting either 'on' or 'off'. By default, if not explicitly set, buffering is enabled for uWSGI responses. It is important to carefully choose between buffering and non-buffering based on the performance characteristics and requirements of the application to avoid potential negative impacts on response times or resource utilization.

Config Example

location /myapp {
    uwsgi_pass myapp;
    uwsgi_buffering off;
}

Beware that setting buffering to 'off' can lead to increased resource usage due to more open connections maintained by NGINX.

When buffering is disabled, NGINX might not be able to compress responses effectively since it sends data as received.

Streaming a large response can result in delayed visibility for the client if the application responds slowly.

← Back to all directives