I'm trying to configure two URL path groups for relatively different usage scenarios and resource consumption in nginx. Both are served by same uwsgi application.

  • Group 1: Regular HTML pages up to cca 128k in size, default
  • Group 2: Large XML "files" up to many MB in size (created by the app on the fly)

The requirement is for both to be gzipped, and the XMLs should be cached 1hr as well.

What I don't quite understand is the meaning of the number of buffers and how to optimally set their number and sizes according to expected traffic and content size, both for uwsgi and gzip.

Also, for the below configuration I get error from nginx:

"uwsgi_busy_buffers_size" must be less than the size of all "uwsgi_buffers" minus one buffer in /etc/nginx/nginx.conf:113

uwsgi_busy_buffers_size appears to be undocumented.

location ~ /path/to/(.+)\.xml {
    uwsgi_hide_header       "Set-Cookie";
    uwsgi_ignore_headers    "Set-Cookie";
    uwsgi_buffers           2 8M;
    uwsgi_cache             xmlfiles;
    uwsgi_cache_key         $request_uri;
    uwsgi_cache_valid       200 1h;
    uwsgi_cache_valid       04 5m;
    uwsgi_cache_use_stale   error;
    expires                 +1h;

    gzip                    on;
    gzip_types              application/xml;
    gzip_buffers            2 8M;

    try_files               $uri @backend;

location / {
    try_files       $uri @backend;
    gzip            on;
    gzip_buffers    8 256k;
    uwsgi_buffers   8 256k;

    try_files       $uri @backend;

location @backend {
    include      uwsgi_params;
    uwsgi_pass   unix:///tmp/uwsgi-app.sock;

Please help. nginx 1.0.14


uwsgi_busy_buffers_size has the same meaning as fastcgi_busy_buffers_size, but for uwsgi.

Limits the total size of buffers that can be busy sending a response to the client while the response is not yet fully read. In the mean time, the rest of the buffers can be used for reading a response and, if needed, buffering part of a response to a temporary file. By default, size is limited by two buffers set by the uwsgi_buffer_size and uwsgi_buffers directives.

p.s. default values of the buffers related directives in nginx have optimal values for most cases. So, you should tune them only if you are fully understand what you're doing and why.

  • Thanks for your answer. My problem is a) I don't know what is the effect of buffer count, and b) I want to avoid hitting disc for uwsgi response and gzipping content if the said content is bigger than the default buffer size. – V. K. May 16 '12 at 23:53

Just as a side-note, the maximum allowed size for each gzip buffer is 8k.

To get the same overall size you would need to use gzip_buffers 2048 8k;.

I'm not sure if the same limitation applies to uwsgi_buffers.

In general, it's better to have more small buffers available than a few huge buffers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.