Changeset 7123:6c52b24fcf8e in nginx


Ignore:
Timestamp:
10/05/17 14:42:59 (2 years ago)
Author:
Maxim Dounin <mdounin@…>
Branch:
default
Phase:
public
Message:

Upstream hash: limited number of tries in consistent case.

While this may result in non-ideal distribution of requests if nginx
won't be able to select a server in a reasonable number of attempts,
this still looks better than severe performance degradation observed
if there is no limit and there are many points configured (ticket #1030).
This is also in line with what we do for other hash balancing methods.

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/http/modules/ngx_http_upstream_hash_module.c

    r6705 r7123  
    504504    ngx_http_upstream_rr_peers_wlock(hp->rrp.peers);
    505505
     506    if (hp->tries > 20 || hp->rrp.peers->single) {
     507        ngx_http_upstream_rr_peers_unlock(hp->rrp.peers);
     508        return hp->get_rr_peer(pc, &hp->rrp);
     509    }
     510
    506511    pc->cached = 0;
    507512    pc->connection = NULL;
     
    578583        hp->tries++;
    579584
    580         if (hp->tries >= points->number) {
    581             pc->name = hp->rrp.peers->name;
     585        if (hp->tries > 20) {
    582586            ngx_http_upstream_rr_peers_unlock(hp->rrp.peers);
    583             return NGX_BUSY;
     587            return hp->get_rr_peer(pc, &hp->rrp);
    584588        }
    585589    }
  • src/stream/ngx_stream_upstream_hash_module.c

    r6705 r7123  
    506506    ngx_stream_upstream_rr_peers_wlock(hp->rrp.peers);
    507507
     508    if (hp->tries > 20 || hp->rrp.peers->single) {
     509        ngx_stream_upstream_rr_peers_unlock(hp->rrp.peers);
     510        return hp->get_rr_peer(pc, &hp->rrp);
     511    }
     512
    508513    pc->connection = NULL;
    509514
     
    579584        hp->tries++;
    580585
    581         if (hp->tries >= points->number) {
    582             pc->name = hp->rrp.peers->name;
     586        if (hp->tries > 20) {
    583587            ngx_stream_upstream_rr_peers_unlock(hp->rrp.peers);
    584             return NGX_BUSY;
     588            return hp->get_rr_peer(pc, &hp->rrp);
    585589        }
    586590    }
Note: See TracChangeset for help on using the changeset viewer.