Forum Discussion

Eric_Frankenfie's avatar
Eric_Frankenfie
Icon for Nimbostratus rankNimbostratus
Nov 07, 2016

iRule vs. Local Traffic Policy vs. Rewrite Profile

Rewrite URI and send to specific pool/node.

 

I have a pool with 6 members which is applied to a virtual server. Our support team would like to have the ability to test against each of the 6 members individual to determine the performance of each member.

 

VS: app.example.com_443_vs

 

Pool: app.example.com_443_pool

 

Nodes: node[x].company.com

 

Host: https://app.example.com

 

URI: /myApp

 

I have decided to publish internally https://app.example.com/n[x]/myApp where x is each of the six members. In the past, I would have written an iRule to rewrite /n[x]/myapp to /myApp and select the pool/node based on /n[x], but now I have Local Traffic Policies and Rewrite Profiles at my disposal.

 

My question is should I perform the rewrite and pool/node selection in an iRule or is it more efficient to utilize a local traffic policy to perform those functions?

 

3 Replies

  • It is your choice. I prefer iRules for the flexibility. If you have already done similar such iRules, I would recommend sticking with iRules.

     

  • This is the iRule I created. Do you recommend using IF or CASE statements, or does it not matter?

    when HTTP_REQUEST { 
        if { [HTTP::uri] starts_with "/n1" } { 
            HTTP::path "/myApp" 
            pool n1-app.example.com_443_pool
        } elseif { [HTTP::uri] starts_with "/n2" } { 
            HTTP::path "/myApp" 
            pool n2-app.example.com_443_pool
        } elseif { [HTTP::uri] starts_with "/n3" } { 
            HTTP::path "/myApp" 
            pool n3-app.example.com_443_pool
        } elseif { [HTTP::uri] starts_with "/n4" } { 
            HTTP::path "/myApp" 
            pool n4-app.example.com_443_pool
        } elseif { [HTTP::uri] starts_with "/n5" } { 
            HTTP::path "/myApp" 
            pool n5-app.example.com_443_pool
        } elseif { [HTTP::uri] starts_with "/n6" } { 
            HTTP::path "/myApp" 
            pool n6-app.example.com_443_pool
        } else {
            pool app.example.com_443_pool
        }
    }
    
  • You also asked about

    if
    vs.
    switch
    . For a multi-case conditional like you have above, you should definitely use
    switch
    . In this case, it's simply because it will only evaluate
    HTTP::uri
    once, rather than for each branch. In the worst case for your rule, it will evaluate 6 times.