Forum Discussion

Terry_Luedtke_1's avatar
Terry_Luedtke_1
Icon for Nimbostratus rankNimbostratus
Sep 08, 2009

Persistence by pool rather than VIP?

Hi,

 

 

Is it possible to set persistence by pool rather than by VIP? For example, if we had an iRule like the following:

 

 

when HTTP_REQUEST {

 

switch [HTTP::path] {

 

"*.jpg" -

 

"*.gif" -

 

"*.png" { pool image_pool }

 

"*.asp" { pool dynamic_pool }

 

default { pool web_pool }

 

}

 

}

 

 

How would we set connections to the dynamic pool to be persistent, but connections to the image and web pools run free? I'm experimenting with setting up two VIPS and using "virtual dynamic_vip" to forward to another VIP with persistence turned on, though that seems overly complicated.

 

 

- Terry Luedtke

 

 

  • Hi Terry,

    You could invoke persistence on specific pool selections

      
     when HTTP_REQUEST {  
      switch -glob [HTTP::path] {  
        "*.jpg" -  
        "*.gif" -  
        "*.png" {   
         pool image_pool   
         persist none  
                }  
        "*.asp" {   
         pool dynamic_pool   
         persist source_addr 255.255.255.255 30  
                }  
        default {   
         pool web_pool   
         persist none  
                }  
     }  
     }  
     

    Click here to learn more about the persist command.

    Thanks,

    CB
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Minor suggestions: if you want to use wildcards with switch, you need to use the -glob flag. And if it's an IIS based app, the objects aren't case sensitive. So you could set the path to lower case:

     

     

    switch -glob [string tolower [HTTP::path]] {

     

  • Thanks, the persist command took care of it. I had seen that command, but got the impression it would obliterate any existing persistence associated with the VIP (and therefore the dynamic pool).

     

     

    By the way, the iRule code in my post was just an example I copied from an article on the site that demonstrated my need. My iRule, unfortunately, is more complicated.

     

     

    http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=244

     

     

    and

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/PoolBasedOnExtension.html

     

     

    are both missing the -glob flag.

     

     

    - Terry
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi Terry,

     

     

    I edited the Codeshare example. You could try posting a comment on the article to fix the one example which uses wildcards without the -glob flag.

     

     

    Thanks,

     

    Aaron