On 2013/8/1 17:05, Godbach wrote:
> Hi Willy,
> 
> Haproxy will check the number of concurrent sessions assigned to the
> server after being selected from lb trees. Both leastconn and roundrobin
> use the same condition as below:
> 
> fwlc_get_next_server():
> if (!s->maxconn || (!s->nbpend && s->served < srv_dynamic_maxconn(s))) {
>       if (s != srvtoavoid) {
>               srv = s;
>               break;
>       }
>       avoided = s;
> }
> 
> fwrr_get_next_server():
> if (!srv->maxconn || (!srv->nbpend && srv->served <
> srv_dynamic_maxconn(srv))) {
>       /* make sure it is not the server we are trying to exclude... */
>       if (srv != srvtoavoid || avoided)
>               break;
> 
>       avoided = srv; /* ...but remember that is was selected yet avoided */
> }
> 
> It means that the server will not be used if there are sessions in
> pending queue or srv->served exceeds the dynamic maxconn of server with
> srv->maxconn set.
> 
> But static-rr ignores the sessions in pending queue and just uses
> srv->cur_sess to compare with dynamic maxconn ad below:
> 
> map_get_server_rr():
> if (!srv->maxconn || srv->cur_sess < srv_dynamic_maxconn(srv)) {
>       /* make sure it is not the server we are try to exclude... */
>       if (srv != srvtoavoid) {
>               px->lbprm.map.rr_idx = newidx;
>               return srv;
>       }
> 
>       avoided = srv;  /* ...but remember that is was selected yet avoided */
>       avoididx = newidx;
> }
> 
> So I am wondering that if there is something intentionally to use
> different check condition that I have not caught.
> 

Hi Willy,

It seems that static-rr should also use the same check condition for the
server after being selected as roundrobin and leastconn as below:

if (!srv->maxconn || (!srv->nbpend && srv->served <
srv_dynamic_maxconn(srv)))

not the following:

if (!srv->maxconn || srv->cur_sess < srv_dynamic_maxconn(srv)) {


-- 
Best Regards,
Godbach

Reply via email to