Forum Discussion

Jaymz_mynes_653's avatar
Jaymz_mynes_653
Icon for Nimbostratus rankNimbostratus
Nov 30, 2006

Efficient iRule writing

I am getting ready to create some iRules and because the rules are going to cover a lot of area I am concerned about the efficiency in which they are written. Here is the scenario, I have just put together an IIS 6.0 webfarm that uses the BigIP v9 LTM as its load balancer. The previous implementation of our website relied heavily on access DBs (yuck, I know), some of those are gone, but some are still around, so what I have to do is create iRules that redirect (based on uri) to the first node in the farm. The first node houses those access DBs… I was happy to find out how easy it was, but then I started to worry about what the iRule was starting to look like when I was writing it.

 

 

Basically I have around 80 redirects I have to make, so do I…

 

-Create an iRule for each redirect (I hope not)?

 

-Put all of the redirects in 1 iRule using a more efficient method than "or"?

 

-Put all of the redirects in 1 iRule and use the Logical Operator “or” as many times as it takes? (Like below, but with many more redirects)

 

 

 

when HTTP_REQUEST {

 

if { ([HTTP::uri] contains "/Microsoft") or ([HTTP::uri] contains "/Cisco") or ([HTTP::uri] contains "/Photogallery") } {

 

node 10.102.180.69 80

 

}

 

}

 

3 Replies

  • If you have 80 URI's to match against, it would probably be easiest to administer if you defined them in a class (data group in the GUI) and used the matchclass function to perform the test.

    Here's an example class:

    
    class uris {
       "/uri1/"
       "/uri2"
    }

    And a rule that references the class:

    
    when HTTP_REQUEST {
       if { [string tolower [matchclass [HTTP::uri]] contains $::uris] }{
          node 10.102.180.69 80
       }
    }

    Aaron

  • I am trying to edit the bigip.conf file to add this data group, but when i do, the changes do not show up in the GUI... Am I doing something wrong?
  • After editing the config file you'll have to load it into memory with the "b load" command. If you loaded it via the command line and it's still not showing up in the GUI, odds are you got something wrong with the format of the class definition.

     

     

    Be warned that you should backup your config file before making any manual changes to it.

     

     

    -Joe