Nginx upstream servers status

Hi,

I am trying to configure nginx with upstream.

We have 3 machines where we run application server and proxy passing all
requests from nginx to application serves.

I used following configuration in nginx:

upstream appcluster {

server host1.example.com:8080 max_fails=2 fail_timeout=300s;

server host2.example.com:8080 max_fails=2 fail_timeout=300s;

}

Now issue is if the request comes to nginx when one server is down
due to unknown reasons its waiting for a long time getting response or
some times its getting connection timeout.

Is there any module in nginx to get upstream servers status and forward
requests only working upstream server.

Can someone suggest me right configuration to get response from
appcluster without latency or connection time out whenever a server wont
respond.

Thanks,
Sandeep.


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

you allow 600 seconds to pass until you npotice, that your
upstream-server
is not responsible.

… max_fails=2 fail_timeout=300s;

why?

Posted at Nginx Forum:

@Parikh I tried with proxy_next_upstream also but facing same issue.
Regarding fail_timeout I used values from 10s to 30s but facing same
issue.
I used following configuration, just check and let me know If I am
missing any thing.
upstream appcluster { server host1.example.com:8080 max_fails=2
fail_timeout=10s; server host2.example.com:8080 max_fails=2
fail_timeout=10s;}

server { listen *; location / {
proxy_pass http://appcluster;
proxy_next_upstream error timeout http_404 http_500 http_502 http_503
http_504 off; proxy_set_header X-Real-IP
$remote_addr; }}

Thanks,Sandeep.


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

you are sure, your upstream-servers are not answering on given ports?

http://wiki.nginx.org/HttpUpstreamModule#server

vs

http://wiki.nginx.org/NginxHttpProxyModule#proxy_connect_timeout
http://wiki.nginx.org/NginxHttpProxyModule#proxy_read_timeout

Posted at Nginx Forum:


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

i’d suggest you’ll start with low-level-debugging:

  • goto host1 and make a tcpdump port 8080 / tail -f against access-logs
    of that server;
  • make a request
  • check., what happens to that request, e.g. where it “hangs”

you could also, just in case, make a “tcpdump port 808 and host host2”
onm
your nginx, just to make sure that nginx is sending the requests to the
right server

Posted at Nginx Forum:

I have 2 upstream servers host1 and host2.
host1 is up and running and listening on port 8080host2 is powered off.
When I sent a request to nginx, I received response after 2 minutes.
Until 2 minutes the request is waiting.
Thanks,Sandeep.

While looking at logs following message appeared:
[error] 16488#0: *80 upstream timed out (110: Connection timed out)
while connecting to upstream, client: IP, server: , request: “GET
/assets/images/transparent.png HTTP/1.1”, upstream:
http://host2.example.com:8080/assets/images/transparent.png”, host:
“hostname”, referrer: “http://hostname
Thanks,Sandeep.

Hi,
After experimenting with some parameters I used following configuration.
upstream appcluster { server
host1.example.com:8080 max_fails=1 fail_timeout=1s;
server host2.example.com:8080 max_fails=1 fail_timeout=1s; }
server { listen *; location / {
proxy_pass http://appcluster;
proxy_next_upstream error timeout http_404 http_500 http_502 http_503
http_504; proxy_set_header X-Real-IP
$remote_addr; proxy_connect_timeout 2;
proxy_send_timeout 2; proxy_read_timeout
5; } }
The issue I am facing here is - with similar configuration in lighttpd
response time per request 0.3 seconds, where as with nginx it is around
2.5 seconds.
Can someone suggest me how to response time with nginx?
Thanks,Sandeep.

From: [email protected]
To: [email protected]
Subject: RE: Nginx upstream servers status
Date: Wed, 3 Jul 2013 14:29:23 +0530

While looking at logs following message appeared:
[error] 16488#0: *80 upstream timed out (110: Connection timed out)
while connecting to upstream, client: IP, server: , request: “GET
/assets/images/transparent.png HTTP/1.1”, upstream:
http://host2.example.com:8080/assets/images/transparent.png”, host:
“hostname”, referrer: “http://hostname
Thanks,Sandeep.