Forum Discussion

Mathieu_Mathieu's avatar
Mathieu_Mathieu
Icon for Nimbostratus rankNimbostratus
Jan 04, 2007

LB::reselect'ing the same node

Hello everyone,

 

 

I'm trying to write an iRule to redirect HTTP requests from a failed server to a working one.

 

 

I wrote the following simple piece of code for testing purpose: replay client request when the selected node responds with a 503 status code.

 

 

My main problem is that sometime, the LB::reselect method is reselecting the same node again and again (but the other node was not tagged as down by monitors).

 

 

Is there a simple way to be sure to switch to a different node ?

 

 

when CLIENT_ACCEPTED {

 

set i 0

 

}

 

 

when HTTP_REQUEST {

 

set request [HTTP::request]

 

}

 

 

when LB_SELECTED {

 

if { ($i > 0) } {

 

LB::reselect

 

log local0. "next target is [LB::server addr]"

 

}

 

}

 

 

when HTTP_RESPONSE {

 

if { ([HTTP::status] == 503) } {

 

log local0. "Error code 503 from [LB::server addr]."

 

incr i

 

if { ($i < 3) } {

 

log local0. "Replaying client request."

 

HTTP::retry $request

 

} else {

 

log local0. "Too many errors from peers, giving up."

 

}

 

}

 

}

 

 

 

Results in:

 

 

Rule XXX HTTP_RESPONSE: Error code 503 from 10.1.1.1.

 

Rule XXX HTTP_RESPONSE: Replaying client request.

 

Rule XXX LB_SELECTED: next target is 10.1.1.1

 

Rule XXX LB_SELECTED: next target is 10.1.1.1

 

Rule XXX HTTP_RESPONSE: Error code 503 from 10.1.1.1.

 

Rule XXX HTTP_RESPONSE: Replaying client request.

 

Rule XXX LB_SELECTED: next target is 10.1.1.1

 

Rule XXX LB_SELECTED: next target is 10.1.1.1

 

Rule XXX HTTP_RESPONSE: Error code 503 from 10.1.1.1.

 

Rule XXX HTTP_RESPONSE: Too many errors from peers, giving up.

 

 

Thanks for your help.

 

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Interesting. Well, the LB::reselect command is only going to perform another LB decision, the same way it would occur if a new request were to hit the BIG-IP. Perhaps there's something in your configuration that's sending the request to this particular node? What load balancing mechanism are you using?

     

     

    Colin
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    I thought I remembered something awhile back posted in this forum indicating that an LB::detach might be required to force a true re-selection since the node is already selected & responding?

     

     

    I'd start by searching for LB::detach to see if you can find some referece to a scenario like yours

     

     

    HTH

     

    /deb