Forum Discussion

John_Woods_4557's avatar
John_Woods_4557
Icon for Nimbostratus rankNimbostratus
Jan 11, 2007

poorly performing URI rule

 

80% of our traffic needs to use the WebPool2, but I am having difficulties getting this rule to perform well. Users are timing out completely trying to get to WebPool2. Can anyone help me optimize this quickly?

 

 

 

if (tolower(substr(http_uri, 0, 4)) == "/ab/") {

 

use pool WebPool1

 

}

 

else if (tolower(substr(http_uri, 0, 7)) == "/cdefg/") {

 

use pool WebPool1

 

}

 

else {

 

use pool WebPool2

 

}

 

 

 

Thanks in advance!

1 Reply

  • Since you are just looking for the first characters in the string, have you tried the "starts_with" operator? substr actually allocates another string which has some overhead.

    if (tolower(http_uri) starts_with "/ab/") {
      use pool WebPool1
    } else if (tolower(http_uri) starts_with "/cdefg/") {
      use pool WebPool1
    } else {
      use pool WebPool2
    }

    Or, you could combine the first two checks into the first if

    if ( (tolower(http_uri) starts_with "/ab") or 
         (tolower(http_uri) starts_with "/cdefg/") ) {
      use pool WebPool1
    } else {
      use pool WebPool2
    }

    Those should both perform roughly the same though.

    I'm not sure you could optimize this rule more that this.

    -Joe