question about workers and proxying to dead upstream.

Igor Sysoev is at rambler-co.ru
Tue May 5 09:18:47 MSD 2009


On Mon, May 04, 2009 at 11:49:45PM +0200, Adrian Bak wrote:

> Hey guys...
> 
> We have a setup where we serve static files from our nginx servers and
> if the file doesn?t exist we proxy to a backend server (that generates
> a static file, and we have another app to delete the static files when
> they get to old).
> 
> The config file looks something like this (on my machine i am testing
> with an apache running on port 8888):
> 
> worker_processes  1;
> events {
>     worker_connections  5; # 5 for testing. would be much higher in production
> }
> 
> ...
> 
> upstream dynamic {
>         server localhost:8888;
> }
> 
> location / {
>             ssi on;
>             try_files $uri $uri/index.html @nothere;
>             break;
> }
> 
> location @nothere {
>             break;
> 
>             proxy_redirect on;
> 
>             # setting extra header
>             proxy_set_header   X-Real-IP        $remote_addr;
>             proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
> 
>             # setting timeout values for the proxying
>             proxy_connect_timeout      90;
>             proxy_send_timeout         90;
>             proxy_read_timeout         90;
> 
>             # setting proxy buffer sizes
>             proxy_buffer_size          4k;
>             proxy_buffers              4 32k;
>             proxy_busy_buffers_size    64k;
>             proxy_temp_file_write_size 64k;
> 
>             proxy_pass http://dynamic;
>     }
> 
> Anyways my question is: what happens if there are 5 (number of
> worker_connection*number_worker_processes) connections to a non
> existing file (it has to proxy) and the backend server times out (i
> have a sleep in my php for testing purpose)?
> Can nginx still serve static files (file that exist)?
> Will it allow 5 connections to the upstream?
> 
> I can?t find the answer on the wiki anywhere and my own test?s with ab
> and curl show that it won?t allow for 5 connections to upstream
> servers if it?s hanging on one of them (it will show a ?The page you
> are looking for is temporarily unavailable.
> Please try again later.?) - is this correct?

Yes. Note also, that one connection is required for client side,
and one connection is required for proxy/fastcgi side. Therefore
for each proxied request you need 2 connections.


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list