Optimal nginx settings for websockets sending images

Maxim Dounin mdounin at mdounin.ru
Fri Mar 1 12:59:01 UTC 2013


Hello!

On Thu, Feb 28, 2013 at 11:06:05PM -0500, michael.heuberger wrote:

> Thanks man :)
> 
> > >         proxy_buffers 8 2m;
> > >         proxy_buffer_size 10m;
> > >         proxy_busy_buffers_size 10m;
> > 
> > Buffers used looks huge, make sure you have enough memory.
> 
> Mmmhhh, do you think I should remove these and trust nginx's default values
> for these buffer?

You should make sure you have enough memory for the buffers 
configured.  If your system will start swapping - there will 
obvious performance degradation compared to smaller buffers.

Default buffers indeed might be better unless you have good 
reasons for the buffers sizes set, or you might start with default 
sizes and tune them till you are happy with the result.  Exact 
optimal sizes depend on a particular use case.

> > >         proxy_cache one;
> > >         proxy_cache_key "$request_uri|$request_body";
> > 
> > Usuing request body as a cache key isn't really a good idea unless 
> > all request bodies are known to be small.
> 
> Ok, I changed that to:
> proxy_cache_key "$scheme$host$request_uri";
> 
> I also made few additions under location/:
> 
>     proxy_cache_valid 200 302 304 10m;
>     proxy_cache_valid 301 1h;
>     proxy_cache_valid any 1m;
> 
>     proxy_next_upstream error timeout invalid_header http_500 http_502
> http_503 http_504 http_404;
> 
> Do you think these are good and justified?

This depends on what and how long you want to cache and how you 
would like to handle upstream errors.

> Unfortunately I'm seeing these warnings now:
> "an upstream response is buffered to a temporary file"
> 
> Any hints why? Help is much appreciated

The message indicate that an (uncacheable) response was buffered to 
a temporary file.  It doesn't indicate the problem per se, but 
might be useful to track sources of I/O problems.  It also might 
appear as a side effect from other problems - e.g. if you have 
network issues and clients just can't download files requested 
fast enough.

If you see such messages it might be just ok if they are rare 
enough.  Or might indicate that you should configure bigger 
buffers (if you have enough memory), or consider disabling disk 
buffering.

Try reading here for more information:

http://nginx.org/r/proxy_buffering

-- 
Maxim Dounin
http://nginx.org/en/donation.html



More information about the nginx mailing list