MR_RJ
Dec 20, 2008Cirrus
iRule gets to many hits because of bad code?
Hi,
I noticed that my iRule gets a lot of hits according to the statistics. Now I understand why. The purpose of the iRule is if no members are available in the webfarm then show a "houston we have a problem"-page.
The rule is executed each time a "http get" arrives. This causes the iRule hits to go through the roof, like 10 hits / sec or more.
Any suggestions how I should rewrite this part?
//Robert
Here is the rule:
when RULE_INIT {
set maint_prefix "/maintenancepage"
set maint_len [string length $maint_prefix]
}
when HTTP_REQUEST {
set uri [HTTP::uri]
if { $uri equals ${::maint_prefix} } {
HTTP::respond 301 "Location" "${::maint_prefix}/"
return
}
if { $uri starts_with "${::maint_prefix}/" } {
set uri [string range $uri $::maint_len end]
switch $uri {
"/" -
"/index.html" { HTTP::respond 200 content [lindex $::something_something_Maintenance_index_page 0] "Content-Type" "text/html" }
"/logo.png" { HTTP::respond 200 content [b64decode [lindex $::something_something_Maintenance_png 0]] "Content-Type" "image/png" }
"/problems.html" { HTTP::respond 200 content [lindex $::something_something_driftstorningar_index_html 0] "Content-Type" "text/html" }
"/probs.png" { HTTP::respond 200 content [b64decode [lindex $::something_something_driftstorningar 0]] "Content-Type" "image/png" }
default { HTTP::respond 404 }
}
return
}
if { [active_members something_something_Online_Win2003_HTTP] == 0 } {
set current_time [clock seconds]
set ::time_min [clock scan {06:00}]
set ::time_max [clock scan {22:00}]
if {($current_time < $::time_min) or ($current_time > $::time_max)} {
HTTP::redirect "${::maint_prefix}/index.html"
log "No members in pool something_something_Online_Win2003_HTTP, redirecting to maintenancepage"
return
}
log local0. "No members in pool something_something_Online_Win2003_HTTP, redirecting to the critical state page"
HTTP::redirect "${::maint_prefix}/problems.html"
return
}
}