Forum Discussion
Sarnoth_81568
Nimbostratus
Aug 01, 2008LB::reselect problem
Let me give you some background before I get in to the problem.
We have a web application that uses session replication. A node can fail in such a way that it always return 5xx error pages. We would like BigIP to route people to the same node as long as it is up, but if it is down (returning 5xx) it should retry their request on the other node.
To accomplish this I worked from the example in the documentation for HTTP::retry. My irule is at the bottom of the post. The problem is that the logs show it selecting the other node for a retry on a 5xx error, but in reality it tries to connect to the same node twice. If anyone has an idea about how I can make this work I would appreciate it very much.
BigIP log message:
Jul 31 15:26:10 tmm tmm[934]: 01220002:6: Rule methcheck_retry_on_error : Sticky to 1573653002.25635.0000
Jul 31 15:26:10 tmm tmm[934]: 01220002:6: Rule methcheck_retry_on_error : Trying node 10.10.204.93:9060
Jul 31 15:26:10 tmm tmm[934]: 01220002:6: Rule methcheck_retry_on_error : 5xx error caught: retry 1 out of 2
Jul 31 15:26:10 tmm tmm[934]: 01220002:6: Rule methcheck_retry_on_error : Removing cookie
Jul 31 15:26:10 tmm tmm[934]: 01220002:6: Rule methcheck_retry_on_error : Trying node 10.10.204.93:9062
It looks like it is trying port 9060 once and port 9062 once, but in reality two requests come in on port 9060 and none come in on 9062. The second request does not have the BIGipServer cookie and has two x-forwarded-for headers as expected.
irule:
when CLIENT_ACCEPTED {
set retries 0
}
when HTTP_REQUEST {
if { $retries >= 1 } {
HTTP::cookie remove "BIGipServermethcheck"
log "Removing cookie"
}
if { [HTTP::cookie exists "BIGipServermethcheck"] } {
log "Sticky to [HTTP::cookie value "BIGipServermethcheck"]"
}
set request [HTTP::request]
}
when LB_SELECTED {
if { $retries >= 1 } {
LB::mode rr
LB::reselect
}
log "Trying node [LB::server addr]:[LB::server port]"
}
when HTTP_RESPONSE {
if { [HTTP::status] starts_with "5" } {
incr retries
log "5xx error caught: retry $retries out of [active_members [LB::server pool]]"
if { $retries < [active_members [LB::server pool]] } {
HTTP::retry $request
}
}
}
- Nicolas_Menant
Employee
Hi, - Can anyone shine any light for me as to why this may not be working:
- dennypayne
Employee
Have you verified with HTTPWatch or LiveHTTPHeaders that no 500's are returning? Maybe just some element of the the page is returning a 500? - Thanks for the reply, and for those problems. I verified that no 500/503 errors are being put up with livehttpdheaders (I was also checking the apache log).
- dennypayne
Employee
Thinking about this again, I think the problem is that the LB_SELECTED event happens before HTTP_RESPONSE, so this approach won't work. I think you need something more along the lines of the passive health monitoring as described here ( Click here ). You probably don't need all the timing logic in that post though. So something like this:when HTTP_RESPONSE { if { [HTTP::status] eq "503" } { LB::down LB::reselect pool [LB::server pool] } }
- Thanks. That is sort of what I was thinking but when I tried it last time, it didn't let me:
- hoolio
Cirrostratus
You would want to use a local variable ($failure) not a global variable ($::failure) as a global variable would get updated across all TCP connections. Also, you would need to initialise the variable in all paths through the iRule or check to see if it's set before trying to use it. You can check to see if a variable is defined using [info exists var_name]. Keep in mind that LB_SELECTED will occur before HTTP_RESPONSE on the first request on a new TCP connection. - Switching servers is OK. The session info is replicated between cluster members. So no re-try is necessary.
- hoolio
Cirrostratus
A successful response to a monitors would mark the pool member back up. If the application isn't stateful and you're very concerned about failed responses, you could configure a monitor with an interval of 5 seconds and a timeout of 6 seconds. Then set the pool's action on service down to reselect. Anyone have concerns/suggestions on this idea? - dennypayne
Employee
If session state is replicated and no re-try is necessary, what about just this:when HTTP_RESPONSE { if { [HTTP::status] eq "503" } { LB::down } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects