Forum Discussion

msullivan_61147's avatar
msullivan_61147
Icon for Nimbostratus rankNimbostratus
Apr 07, 2010

Remove persistence for downtime site

I need some help with persistence for our sites.

 

 

We are using Weblogic as our app server, so we want to set persistence on a JSESSIONID in a cookie.

 

 

I created the following iRule:

 

 

when HTTP_RESPONSE

 

{ if { [http::cookie exists "JSESSIONID"] }

 

{ persist add uie [http::cookie "JSESSIONID"]

 

}

 

}

 

when HTTP_REQUEST

 

{ if { [http::cookie exists "JSESSIONID"] }

 

{ persist uie [http::cookie "JSESSIONID"] }

 

}

 

 

I have set up my virtual server to use the iRule as the default persistence profile. I then added two pool members that point to our application. The JSESSIONID shows up in the persistence statistics and our app jsp pages work fine.

 

 

Now I want to add a third member to the pool. This points to a downtime page which just displays HTML. I configured the two app members with priority group 30, set the downtime member to priority group 10 and enabled Priority Group Activation for less than one.

 

 

If both app members go down, the downtime page will show up. The problem is that the persistence applies to the downtime site. When the app members come back up, the downtime page still shows up until the persistence rule expires.

 

 

Is there a way to modify the iRule to remove the persistence rule from the downtime member? I know there are a few other ways of doing downtime/maintenance pages, but they don't work well for our environment.

 

7 Replies

  • when CLIENT_ACCEPTED {
    if { [active_members mypool < 1 } {
    set timeout 30
    } else {
    set timeout 300
    }
    }
    
    when HTTP_REQUEST {
    if { [HTTP::cookie "JSESSIONID"] != "" } {
    persist add uie [HTTP::cookie "JSESSIONID"] $timeout
    }
    }
    
    
    when LB_SELECTED {
    if { [LB::server addr] equals [ip of maint server] } {
    if { [HTTP::cookie "JSESSIONID"] != "" } {
    persist delete uie [HTTP::cookie "JSESSIONID"] 
    [HTTP::cookie remove "JSESSIONID"]
    }
    }
    }
    
    when HTTP_RESPONSE {
    if { [HTTP::cookie "JSESSIONID"] != "" } {
    persist add uie [HTTP::cookie "JSESSIONID"] $timeout
    }
    }
    
  • Nice one Ian. You could also use LB::server priority to determine whether the currently selected member is a normal member or one just used during outages:

    when HTTP_REQUEST {
    
        Add a persistence record if the client presents a Java cookie with a value
       if { [HTTP::cookie "JSESSIONID"] ne "" } {
          persist add uie [HTTP::cookie "JSESSIONID"] 3600
       }
    }
    when LB_SELECTED {
    
        Track whether to add a persistence record in the response
       set add_persist 1
    
        Check if the current selected server is less than the main pool members' priority
       if { [LB::server priority] < 30 } {
    
           Don't add a persistence record in the response
          set add_persist 0
    
           Delete the persistence record
          if { [HTTP::cookie "JSESSIONID"] ne "" } {
             persist delete uie [HTTP::cookie "JSESSIONID"] 
          }
       }
    }
    when HTTP_RESPONSE {
       if { [HTTP::cookie "JSESSIONID"] ne "" and $add_persist} {
          persist add uie [HTTP::cookie "JSESSIONID"] 3600
       }
    }
    

    Aaron
  • Nice! I had forgotten about LB::server priority. That is definitely going back in the toolkit.
  • Thanks for the replies. I tried tweaking the first code sample using "active_members mypool < 1" , but I couldn't get it to work. I'm testing a version with the LB::server priority that looks like it's working. I'll post the final code once I finish testing.

     

  • I updated the iRule above to fix a code rendering issue. Also, make sure to customize the persist add timeout if you want to persist longer than one hour. And set the LB::server priority of 30 to what you're actually using on the higher priority pool members.

     

     

    Aaron
  • Here is the final code. It is working fine for me. My app sites are set to priority 25 or higher and persist on the JSESSIONID. My downtime sites have a priority of less than 25 and do not persist. Thanks Ian and Aaron for your code advice. Thanks also to Doug Lohf at F5 for helping tune this.

     

     

    Michael

     

     

     

    when HTTP_REQUEST {

     

     

    Add a persistence record if the client presents a Java cookie with a value

     

    if { [HTTP::cookie "JSESSIONID"] ne "" } {

     

    persist uie [HTTP::cookie "JSESSIONID"]

     

    }

     

    }

     

    when LB_SELECTED {

     

     

    Track whether to add a persistence record in the response

     

    set add_persist 1

     

    Check if the current selected server is less than the main pool members' priority

     

    if { [LB::server priority] < 25 } {

     

     

    Don't add a persistence record in the response

     

    set add_persist 0

     

     

    Delete the persistence record

     

    if { [HTTP::cookie "JSESSIONID"] ne "" } {

     

    persist delete uie [HTTP::cookie "JSESSIONID"]

     

    }

     

    }

     

    }

     

    when HTTP_RESPONSE {

     

    if { [HTTP::cookie "JSESSIONID"] ne "" && $add_persist} {

     

    persist add uie [HTTP::cookie "JSESSIONID"]

     

    }

     

    if {($add_persist equals 0)} {

     

    HTTP::close

     

    }

     

    }
  • Thanks for posting the updated version. Out of curiosity, why did you use HTTP::close in responses that don't get a persistence record?

     

     

    Aaron