HTTP:Retry and LB:Reselect not working as expected.
Hello,
We are using ASP.net Session state via SQL server behind our BIGIP Version 10.2.4. Session state is working great. We do not want the user to ever see a service unavailable. We tried setting the http monitor to a very low value, but there was still a delay before we would finally get moved to a different server. In the meantime, the user would see 503 errors. We contacted F5, and they said this was the only way to do it. However, I found this iRule which seemed like it would do the trick: https://devcentral.f5.com/wiki/iRules.HTTP__retry.ashx
As I understand it, it inspects each request and if there is a 5xx error, it will retry to a different pool member. The problem is that it does not work. The client still sees 5xx errors until the http monitor marks the pool member down. If I look in the lTM log, I can see it logging that a 5xx error was received, and that it is retrying and re-loadbalancing. However, from the client point of view, this is not occurring. Am I missing something in the setup? Here is my code:
Retry requests to the virtual server's default pool if the server responds with an error code (5xx status)
when CLIENT_ACCEPTED {
On each new TCP connection track that we have not retried a request yet
set retries 0
Save the name of the virtual server default pool
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
We only want to retry GET requests to avoid having to collect POST payloads
Only save the request headers if this is not a retried request
if { [HTTP::method] eq "GET" && $retries == 0 }{
set request_headers [HTTP::request]
}
}
when LB_SELECTED {
Select a new pool member from the VS default pool if we are retrying this request
if { $retries > 0 } {
LB::reselect pool $default_pool
log local0. "Re-loadbalancing"
}
}
when HTTP_RESPONSE {
Check for server errors
if { [HTTP::status] starts_with "5" } {
Server error, retry the request if we have not already retried more times than there are pool members
incr retries
log local0. "5xx error caught: retry $retries out of [active_members $default_pool]"
if { $retries < [active_members $default_pool] } {
Retry this request
HTTP::retry $request_headers
Exit this event from this iRule so we do not reset retries to 0
return
}
}
If we are still in the rule we are not retrying this request
set retries 0
}
Thanks.