I would like to use an iRule to direct traffic based on the response time of the back-end resource pool. Under normal operations, incoming requests (these are SOAP-based queries) will go to the primary resource pool. When the primary pool becomes unresponsive (response slower than 5-10 seconds), requests should be directed to a secondary pool which is configured to basically tell the client “come back later”.
I am using priority groups and health monitors to approximate this mechanism currently. But I think if I could find the right tools in iRule I would have more precise control.
Basically I need something like:
when HTTP_REQUEST {
[code to check response time here…]
if response_time < 10 {
pool primary_pool
return
}
else {
pool secondary_pool
return
}
}
Is there a command to test the back-end response? We are on BIG-IP 9.4.3
9.4.3 makes it a bit more difficult. I did something for this in 2010 on LDAP servers. But the iRule was designed to be pretty lightweight and the actual calculations for average response times etc was offloaded to a separate server, because different users were expected to have different SLA requirements. (See the LDAP_Stats_Measuring iRule).
The measurements and tracking of response times was tracked by user (ldap bind id), but it required tables. Assuming you don’t need that… Hmm.. Not sure. Would need a bit more thought. Any chance you could upgrade to v10.2?
Even then though, you have the problem of working out when the response times decrease again… v11 you could use a sideband connection…
You could use the after command in 10.0+ to set a timer and select a new pool if the currently selected server doesn’t reply. I think you’d need to call LB::detach in the after script and then call the second pool using the pool command.
See the last example on the wiki page for details: