Optimal nginx settings for websockets sending images

Maxim Dounin mdounin at mdounin.ru
Sun Mar 3 12:08:24 UTC 2013


Hello!

On Fri, Mar 01, 2013 at 11:54:06PM -0500, michael.heuberger wrote:

> thank you so much maxim
> 
> i have read the documentation at
> http://nginx.org/en/docs/http/ngx_http_proxy_module.html and am trying to
> understand all that. it's not easy ...
> 
> i'm serving video files (mp4 or webm). that's where these "an upstream
> response is buffered to a temporary file" warnings occur.
> 
> how can i find out how far i should increase the buffers until these
> warnings are gone? how would you do this?

As long as files are big - it probably doesn't make sense to even 
try to eliminate warnings by increasing buffers.  Instead, you 
have to derive buffer sizes from amount of memory you want to use 
for buffering, keeping in mind that maximum memory will be 
(proxy_buffer_size + proxy_buffers) / (worker_processes * 
worker_connections).

Note: as long as you have other activity on the host in question, 
including nginx with cache or even with just disk buffering, you 
likely want to keep at least part of the memory free - e.g., for VM 
cache.

> second problem:
> when i made changes in the css file, uploaded that, then the nginx server
> was still serving the older version. because of "proxy_cache_valid 200 302
> 304 10m;" - how can i tell nginx to refresh cache asap when a new file was
> uploaded?

While in theory you may remove/refresh file in nginx cache, it 
won't really work in real life - as the same file might be cached 
at various other layers, including client browser cache.

Correct aproach to the problem is to use unique links, e.g. with 
version number in them.  Something like "/css/file.css?42", where 
"42" is a number you bump each time you do significant changes to 
the file, will do the trick.

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



More information about the nginx mailing list