Forum Discussion

Keya_60860's avatar
Keya_60860
Icon for Nimbostratus rankNimbostratus
Aug 11, 2009

Attempting to redirect based on uri with persistenace at pool level

Hello,

 

 

I am new to scripting iRules and need some assistance in one that i have created. The objective is to direct client traffic based on uri to different pools and then apply persistance at the pool-level instead of the VIP level with version 9.x. The basis of the iRule is that I have create Data List to define the uri instead of having the iRule modify when a uri needs to be add or removed. Data Lists are fastlane_7000, fastlane_7200, fastlane_7300. I create 3 cookies, for cookie insert, fastlane_cookie_7000, fastlane_cookie_7200 and fastlane_cookie_7300. Then I added the following statements to the iRule for cookie persistence at the pool level. I am inquiring if this script would cause any problems that you may know of, I researched on DevCentral and I did not see any reference to problems with this script in other users usage; however, this iRule is very custom. Please let me know your input.

 

 

URI Load Balancing for Fastlane Spilt

 

Objective is to load-balacning FL applications as individual apps across several defined pools

 

DataList contains variable definition for this iRule

 

If uri needs to be added please add through Data List

 

 

when HTTP_REQUEST {

 

log "The incoming uri is [HTTP::uri]"

 

if {[HTTP::uri] starts_with "fastlane_7000" or [HTTP::uri] equals "/"} {

 

pool fastlane_test_7000

 

persist cookie insert fastlane_cookie_7000 0

 

log local0. "[IP::client_addr][TCP::client_port]: fastlane_7000 request"

 

} elseif {[HTTP::uri] starts_with "fastlane_7200"} {

 

pool fastlane_test_7200

 

persist cookie insert fastlane_cookie_7200 0

 

log local0. "[IP::client_addr][TCP::client_port]: fastlane_7200 request"

 

} elseif {[HTTP::uri] starts_with "fastlane_7300"} {

 

pool fastlane_test_7300

 

persist cookie insert fastlane_cookie_7300 0

 

log local0. "[IP::client_addr][TCP::client_port]: fastlane_7300 request"

 

}

 

else {

 

pool fastlane_test_7000

 

persist cookie insert fastlane_cookie_7000 0

 

log local0. "[IP::client_addr][TCP::client_port]: fastlane_7000 request"

 

}

 

}

 

3 Replies

  • The logic looks sound. However, my suggestion would be to use switch statement instead of IF-ELSEIF statement. You would get better performance.

     

     

    I hope this helps.

     

    cb
  • Also, if you want to compare a URI with a datagroup list, you should use matchclass (Click here):

     

     

    if {[matchclass [HTTP::uri] starts_with datagroup_name]}

     

     

    Aaron