# Question about workers and proxying to dead upstream

**URL:** <https://www.ruby-forum.com/t/question-about-workers-and-proxying-to-dead-upstream/167168>\
**Category:** NGINX\
**Created:** [May 4, 2009, 11:58pm UTC](https://www.ruby-forum.com/t/question-about-workers-and-proxying-to-dead-upstream/167168 "2009-05-04T23:58:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adrian\_Bak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Adrian\_Bak](https://www.ruby-forum.com/u/Adrian_Bak)\
**Post date:** [May 4, 2009, 11:58pm UTC](https://www.ruby-forum.com/t/question-about-workers-and-proxying-to-dead-upstream/167168/1 "2009-05-04T23:58:31Z")

</div>

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?

best,  
Adrian

---

<div class="post-metadata">

**Author:** ![Adrian\_Bak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Adrian\_Bak](https://www.ruby-forum.com/u/Adrian_Bak)\
**Post date:** [May 5, 2009, 7:30am UTC](https://www.ruby-forum.com/t/question-about-workers-and-proxying-to-dead-upstream/167168/2 "2009-05-05T07:30:02Z")

</div>

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

> worker\_processes 1;  
> location / {  
> # setting extra header  
> proxy\_buffers 4 32k;  
> 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.

---

<div class="post-metadata">

**Author:** ![Adrian\_Bak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Adrian\_Bak](https://www.ruby-forum.com/u/Adrian_Bak)\
**Post date:** [May 5, 2009, 8:50pm UTC](https://www.ruby-forum.com/t/question-about-workers-and-proxying-to-dead-upstream/167168/3 "2009-05-05T20:50:02Z")

</div>

Thanks… That’s what I wanted to hear.  
Now I go on and try to sell it to the “big man upstairs” 🙂

best,  
Adrian

2009/5/5 Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
