Forum Discussion

Peter_Baughn_84's avatar
Peter_Baughn_84
Icon for Nimbostratus rankNimbostratus
Apr 05, 2007

iRule performance

I have a rule that "overloads" a single virtual server with 100+ pools. In its current state its a simple if loop like this:

 

 

when HTTP_REQUEST {

 

set uri [HTTP::uri];

 

if { $uri starts_with "/name" } {

 

pool name

 

} elseif { $uri starts_with "/name1" } {

 

pool name1

 

} elseif { $uri starts_with "/name2" } {

 

pool name2

 

} elseif { $uri starts_with "/name3" } {

 

pool name3

 

} elseif { $uri starts_with "/name4" } {

 

pool name4

 

...

 

} elseif ( $uri starts_with "/name100" } {

 

pool name100

 

} else {

 

HTTP::redirect "http://sitedown.domain.com"

 

}

 

}

 

 

 

In all but rare cases the pool name always matches the first portion of the uri. In an attempt to tune this for higher performance/less CPU usage I am planning on putting all the URI values into a class list and just check each URI against the list. Any ideas on whether this will really help performance or not? I think I can get the entire above rule into the following.

 

 

class pool_list {

 

"name"

 

"name1"

 

...

 

"name100"

 

}

 

 

when HTTP_REQUEST {

 

set uri [HTTP::uri];

 

set pool [getfield $uri "/" 2];

 

if { [matchclass $pool equals $::pool_list] } {

 

pool $pool

 

} else {

 

HTTP::redirect "http://sitedown.domain.com"

 

}

 

}

 

No RepliesBe the first to reply