Forum: NGINX question about workers and proxying to dead upstream.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A1596689d95b70287cfeecee6f37f39f?d=identicon&s=25 Adrian Bak (Guest)
on 2009-05-04 23:58
(Received via mailing list)
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
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-05-05 07:30
(Received via mailing list)
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.
A1596689d95b70287cfeecee6f37f39f?d=identicon&s=25 Adrian Bak (Guest)
on 2009-05-05 20:50
(Received via mailing list)
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 Sysoev <is@rambler-co.ru>:
This topic is locked and can not be replied to.