Forum Discussion
Bryan_38320
Nimbostratus
Jul 16, 2010class match instead of findclass
I recently did an upgrade from 9.x to 10.1. Under 9.x we were using a class data structure for several hundred redirects.
Example:
class noclass {
"/notthissite1 http://www.thissite1.com/"
"/notthissite2 http://www.thissite2.com/"
"/notthissite3 http://www.thissite3.com/"
}
rule classyrule {
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
set gohere [findclass $uri $::noclass " "]
if { $gohere ne "" } {
HTTP::redirect $gohere
}
}
}
In 10.1 that changed slightly, a few extra brackets in the class, but more importantly, the findclass command has a huge performance issue when multiple tmm are running. F5 says to use "class match" instead of findclass to fix that. After some research, it appears that this SHOULD work (but does not):
class noclass {
{
"/notthissite1 http://www.thissite1.com/"
"/notthissite2 http://www.thissite2.com/"
"/notthissite3 http://www.thissite3.com/"
}
}
rule classyrule {
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
set gohere [class match -value $uri equals noclass]
if { $gohere ne "" } {
HTTP::redirect $gohere
}
}
}
After some digging and adding some extra logs (removed for brevity) $gohere returns nothing and no redirect happens. Even if it did, the appropriate value isn't there to be redirected to.
I also looked into the format of the class. There appear to be several methods of defining the class. None of my efforts have been successful.
The most popular way seems to be something like this:
class noclass {
{
"/notthissite1" { "http://www.thissite1.com/" }
"/notthissite2" { "http://www.thissite2.com/" }
"/notthissite3" { "http://www.thissite3.com/" }
}
}
This behaves exactly the same way... $gohere does not return the value from the class.
I also tried an external file:
my file is noclass.class:
"/notthissite1" := "http://www.thissite1.com/",
"/notthissite2" := "http://www.thissite2.com/",
"/notthissite3" := "http://www.thissite3.com/",
bigip.conf:
class noclass {
type string
filename /config/noclass.class
}
rule classyrule {
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
set gohere [class match -value $uri equals noclass]
if { $gohere ne "" } {
HTTP::redirect $gohere
}
}
}
This one chokes on line 2 (I've tried several iterations of this as well, but above is my interpretation of the documentation).
I don't really care if it is an internal or external class, external might be a nice way to clean the config up a bit, I'm more concerned about getting the value back from my class lookup. I'm apparently going about something all wrong.
I thank you all for any constructive comments.
- hoolio
Cirrostratus
Hi Bryan,class my_string_datagroup { { "name1" { "value1" } "name2" { "value2" } "name3" { "value3" } } }
- Bryan_38320
Nimbostratus
I did not test other options as this was kind of a break-fix scenario at the time and since F5 suggested class match -value, I didn't see the need to look at other options. That said, the performance impact of using findclass in 10.1 was quite significant. Under load, the vip would start timing out at just 2,000 connections per second. Under v9 with findclass or under v10 with class match, it could easily handle 350,000 connections. - Bryan_38320
Nimbostratus
I was able to test the changes suggested by hoolio and that appears to have resolved the issue. We are running load tests now. - hoolio
Cirrostratus
I thought that class match -value returned the value portion of the name/value pair, but I'll give class search a shot.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects