Forum Discussion

uni's avatar
uni
Icon for Altostratus rankAltostratus
Nov 27, 2008

Switching LB mode based on request

I have been asked to look at switching LB mode based on the request URI. There are two approaches I see to this.

Change the LB:mode based on the request uri:

when HTTP_REQUEST { 
    if {[HTTP::uri] starts_with "/whatever/"} { 
       LB::mode rr 
    } else { 
       LB::mode leastconns 
    } 
 }

Presumably the LTM maintains a counter to decide which member to select when using round-robin. Does switching in and out of rr mode reset the round-robin counter, or does it use a "total requests" counter or similar?

Also, does the LB mode reset to the one defined in the pool at each request (i.e. is the "else" clause required)?

If it does reset the counter each time, I assume I would have to have a separate pool for each LB type and select them base on the uri.

when HTTP_REQUEST { 
    if {[HTTP::uri] starts_with "/whatever/"} { 
       pool roundrobin-pool 
    } else { 
       pool leastconns-pool 
    } 
 }

This is less desirable, as it means having a duplicate pool with duplicate monitoring, plus additional maintenance requirements.

Any other comments welcome (except "but why would you want to do that?").