mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-10 03:02:28 +00:00
MINOR: lb/first: use a read lock in fas_get_next_server()
The "first" algorithm creates a lot of contention because all threads focus on the same server by definition (the first available one). By turning the exclusive lock to a read lock in fas_get_next_server(), the request rate increases by 16% for 8 threads when many servers are getting close to their maxconn.
This commit is contained in:
parent
58bc9c1ced
commit
f76a21f78c
@ -300,7 +300,7 @@ struct server *fas_get_next_server(struct proxy *p, struct server *srvtoavoid)
|
|||||||
|
|
||||||
srv = avoided = NULL;
|
srv = avoided = NULL;
|
||||||
|
|
||||||
HA_RWLOCK_WRLOCK(LBPRM_LOCK, &p->lbprm.lock);
|
HA_RWLOCK_RDLOCK(LBPRM_LOCK, &p->lbprm.lock);
|
||||||
if (p->srv_act)
|
if (p->srv_act)
|
||||||
node = eb32_first(&p->lbprm.fas.act);
|
node = eb32_first(&p->lbprm.fas.act);
|
||||||
else if (p->lbprm.fbck) {
|
else if (p->lbprm.fbck) {
|
||||||
@ -336,7 +336,7 @@ struct server *fas_get_next_server(struct proxy *p, struct server *srvtoavoid)
|
|||||||
if (!srv)
|
if (!srv)
|
||||||
srv = avoided;
|
srv = avoided;
|
||||||
out:
|
out:
|
||||||
HA_RWLOCK_WRUNLOCK(LBPRM_LOCK, &p->lbprm.lock);
|
HA_RWLOCK_RDUNLOCK(LBPRM_LOCK, &p->lbprm.lock);
|
||||||
return srv;
|
return srv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user