Will this irule work okay to "Patch" a messed up web application
I am running version 10.2 and unfortunately there is a little problem with a "Cloud" Application that consists of several front end web servers that talk to a few db servers in the back.Every so often some kind of bad data hits the front end customer facing web servers returning a nasty confusing 500 error that looks like a BSOD message on steroids.
(If a user retries a few times they will get the output that is supposed to be correct)
So I thought maybe the F5 could save the day using it like a virtual software patch for now and hide the "500 error" from the end users
Anytime a pool member returns an error 500 just select the next pool member in line and see if it is okay. If it is, then just spit out the correct website.
And let the programmers work in peace while they fix the issue.
when CLIENT_ACCEPTED {
set variable def_pool to pool name queried by the LB command.
set the variable retries to zero
set def_pool [LB::server pool]
set retries 0
}
when HTTP_REQUEST {
set request_headers [HTTP::request]
}
when LB_SELECTED {
if { $retries >= 1 } {
LB::mode rr
LB::reselect pool $def_pool
}
}
when HTTP_RESPONSE {
if { [HTTP::status] starts_with "5" } {
incr retries
log local0. "5xx error caught: retry $retries out of [active_members [LB::server pool]]"
if { $retries < [active_members $def_pool] } {
HTTP::retry $request_headers
}
}
}
The command LB::reselect pool will advance the pointer down to the next available load balancer
LB::mode rr
LB::mode reselect
using mode rr to force into roundrobin mode because its set to least connections, hop to next server in line.