Welcome! Log In Create A New Profile

Advanced

Re: upstream retries with a single server

November 21, 2010 08:24AM
On Nov 21, Maxim Dounin wrote:
>Hello!
>
>On Sat, Nov 20, 2010 at 09:48:15PM +0530, Arvind Jayaprakash wrote:
>
>> Hello,
>> From the way I understand if there are 'n' servers listed as part of
>> an upstream block & upstream returns failure (as defined by
>> proxy_next_upstream), then nginx retries the same request on another
>> upstream server and this repeats till every upstream is tried once
>> (excluding those that are considered to be down).
>
>Yes.
>
>> If an upstream block is defined with exactly one active server, I see
>> that the request gets retried on the same upstream in case of a failure
>> upto 'max_retries' number of times. Logically, I'd expect it to try just
>> once and then give up if upstream fails to provide a suitable response.
>
>There is no such thing as 'max_retries'. As in previous case, all
>(i.e. the only one in this case) upstreams are tried once and then
>appropriate error returned.

My bad, I meant max_fails.


I've managed to reproduce a problem where the same upstream gets
retried.

When an upstream block contains one active and one backup server, the
same request gets retried. Commenting out the backup (line 22 in the
conf) however seems to exhibit the defined behaviour of try exactly
once. The access log contains the status for the 2 cases.

I've been able to reproduce this on many versions (0.8.[33,34,53])
127.0.0.1 - - [21/Nov/2010:18:35:30 +0530] "GET /err.php HTTP/1.1" UP:(502) (0.000) (127.0.0.1:80)502 383 "-" "lwp-request/5.827 libwww-perl/5.831" "-"
127.0.0.1 - - [21/Nov/2010:18:35:35 +0530] "GET /err.php HTTP/1.1" UP:(502, 502, 502, 502, 502, 502) (0.000, 0.000, 0.000, 0.000, 0.000, 0.000) (127.0.0.1:80, 127.0.0.1:80, 127.0.0.1:80, 127.0.0.1:80, 127.0.0.1:80, 127.0.0.1:801)502 383 "-" "lwp-request/5.827 libwww-perl/5.831" "-"

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
error_log logs/error.log debug;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {

upstream ussss
{
server 127.0.0.1:80 max_fails=5;
server 127.0.0.1:801 max_fails=5 backup;
}

upstream w2
{
server 127.0.0.1:80 weight=1 max_fails=2 fail_timeout=60;
server 127.0.0.1:801 weight=100 max_fails=2 fail_timeout=60;
}

include mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'UP:($upstream_status) ($upstream_response_time) ($upstream_addr)'
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 8081;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
proxy_pass http://ussss;
proxy_connect_timeout 2;
proxy_read_timeout 2;
}

location /autodocs {
proxy_pass http://w2;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
location /wireframes {
proxy_pass http://localhost:8000;
}

location /advertiser {
proxy_pass http://localhost:8000;
}

location ~ /adv(css|js|images)
{
root /home/arvindj/src/people/anomalizer/dj-m3/inmobi_ui/media-ui;
}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

upstream retries with a single server

anomalizer November 20, 2010 11:22AM

Re: upstream retries with a single server

Maxim Dounin November 20, 2010 06:16PM

Re: upstream retries with a single server

anomalizer November 21, 2010 08:24AM

Re: upstream retries with a single server

Maxim Dounin November 21, 2010 12:50PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 298
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready