Commit Graph

34 Commits

Author SHA1 Message Date
Maxim Dounin
b713e480ca Better recheck of dead upstream servers.
Previously nginx used to mark backend again as live as soon as fail_timeout
passes (10s by default) since last failure.  On the other hand, detecting
dead backend takes up to 60s (proxy_connect_timeout) in typical situation
"backend is down and doesn't respond to any packets".  This resulted in
suboptimal behaviour in the above situation (up to 23% of requests were
directed to dead backend with default settings).

More detailed description of the problem may be found here (in Russian):
http://mailman.nginx.org/pipermail/nginx-ru/2011-August/042172.html

Fix is to only allow one request after fail_timeout passes, and
mark backend as "live" only if this request succeeds.

Note that with new code backend will not be marked "live" unless "check"
request is completed, and this may take a while in some specific workloads
(e.g. streaming).  This is believed to be acceptable.
2011-10-12 14:22:48 +00:00
Maxim Dounin
b7fcb430c1 Upstream: properly allocate memory for tried flags.
Previous allocation only took into account number of non-backup servers, and
this caused memory corruption with many backup servers.

See report here:
http://mailman.nginx.org/pipermail/nginx/2011-May/026531.html
2011-08-18 17:04:52 +00:00
Maxim Dounin
624fbe94a2 Fixing cpu hog with all upstream servers marked "down".
The following configuration causes nginx to hog cpu due to infinite loop
in ngx_http_upstream_get_peer():

    upstream backend {
        server 127.0.0.1:8080 down;
        server 127.0.0.1:8080 down;
    }

    server {
       ...
       location / {
           proxy_pass http://backend;
       }
    }

Make sure we don't loop infinitely in ngx_http_upstream_get_peer() but stop
after resetting peer weights once.

Return 0 if we are stuck.  This is guaranteed to work as peer 0 always exists,
and eventually ngx_http_upstream_get_round_robin_peer() will do the right
thing falling back to backup servers or returning NGX_BUSY.
2011-08-18 16:52:38 +00:00
Igor Sysoev
08b597592f do not try to reuse and save a SSL session for a peer created on the fly
by ngx_http_upstream_create_round_robin_peer(), since the peer lives
only during request so the saved SSL session will never be used again
and just causes memory leak

patch by Maxim Dounin
2011-07-22 16:30:17 +00:00
Igor Sysoev
302cedceb0 variable support for unix sockets in fastcgi_pass and proxy_pass 2008-12-23 19:35:12 +00:00
Igor Sysoev
333723e001 fix divide by zero if max_fails=0 2008-08-26 14:34:16 +00:00
Igor Sysoev
6a75019ad6 *) remove zero termination in ngx_inet_ntop() and ngx_sock_ntop()
*) use ngx_snprintf() in ngx_inet_ntop() and ngx_sock_ntop()
   as they are called just once per connection
*) NGX_INET_ADDRSTRLEN
2008-08-21 18:47:23 +00:00
Igor Sysoev
7f6b2ffc60 *) back out r2040
*) refactor ngx_palloc()
*) introduce ngx_pnalloc()
*) additional pool blocks have smaller header
2008-06-17 15:00:30 +00:00
Igor Sysoev
de8ec1efc8 use ngx_int_t in ngx_sort() callback 2008-03-24 13:04:02 +00:00
Igor Sysoev
665b9fd2e2 set absolute weight, this fixes bogus "no live upstream" case when
last upstream is down while live one has negative weight
2008-02-11 14:31:38 +00:00
Igor Sysoev
96dd8af8e6 proxy_pass variables support 2007-11-27 13:34:13 +00:00
Igor Sysoev
ab18bf2f02 use real weight, do not downground to one 2007-10-15 10:15:54 +00:00
Igor Sysoev
47a1ebb050 optimization 2007-10-10 13:58:47 +00:00
Igor Sysoev
7ed63ee75f use pool instead of ngx_conf_t 2007-10-08 08:55:12 +00:00
Igor Sysoev
a103646402 fix r1552 and r1464: test max fails in correct peer 2007-10-02 12:34:16 +00:00
Igor Sysoev
834e447234 fix r1464: test max fails in correct peer 2007-10-01 14:45:31 +00:00
Igor Sysoev
4b96baa417 u_char* is enough to keep file name 2007-09-15 17:11:06 +00:00
Igor Sysoev
fcd9dda633 balance more fair when there are several servers with equal weights,
side effect: now smallest weights go first
2007-09-09 18:23:21 +00:00
Igor Sysoev
7a69774721 fix case when server was marked as down after one failure 2007-09-05 15:30:19 +00:00
Igor Sysoev
4efa705cc0 backout r1426: return dynamic weights 2007-09-05 15:28:19 +00:00
Igor Sysoev
b3dd3fd359 style fix 2007-08-31 12:13:12 +00:00
Igor Sysoev
121bf2f955 cancel dynamic weights,
it seems that may permanently set lower weight or even mark server as down
2007-08-27 16:02:43 +00:00
Igor Sysoev
012f231bbc add guard code to prevent endless loop 2007-08-24 15:58:13 +00:00
Igor Sysoev
cc07609d11 fix long loop 2007-08-14 13:35:52 +00:00
Igor Sysoev
7a8e33993a sort upstream weights 2007-08-09 15:28:17 +00:00
Igor Sysoev
6876bcdad6 backup upstream servers 2007-08-09 13:54:33 +00:00
Igor Sysoev
3625a458d9 "down" server caused endless loop 2007-08-07 12:34:20 +00:00
Igor Sysoev
d12a5718d8 fair upstream weight balancer 2007-07-28 16:04:01 +00:00
Igor Sysoev
8b0a3d2810 fix segfault when session was freed twice 2007-07-10 21:04:37 +00:00
Igor Sysoev
0687cb9d99 fix worker endless loop on 64-bit platform if 33+ backend has fall 2007-05-21 13:48:14 +00:00
Igor Sysoev
db4e43c225 fix msvc build failure 2006-12-13 15:06:46 +00:00
Igor Sysoev
bf3aaac7ac rewritten upstream 2006-12-12 16:46:16 +00:00
Igor Sysoev
5d118d3f77 fix fastcgi and memcached upstreams 2006-12-11 08:59:30 +00:00
Igor Sysoev
3d2fd18a39 upstream choice modules 2006-12-04 16:46:13 +00:00