Forum Discussion

Jesse_Anderson1's avatar
Jesse_Anderson1
Icon for Nimbostratus rankNimbostratus
Sep 12, 2009

Throttling sessions based on JSESSIONID

As a temp fix to an issue we are having, we are thinking of keeping track of sessions into our application on the F5 by tracking the assigned JSESSIONID that the application assigns the users. Based on some examples that I found, this is what I have come up with:

 

 

when RULE_INIT {

 

set ::total_active_clients 0

 

set ::max_active_clients 1

 

set session_error {

 

 

 

 

EPAS: Max Number of Sessions

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ePAS has reached the maximum number of sessions. Please try again later.

 

 

Message Source: Load Test - SDLCLBSSL

 

 

 

 

 

 

}

 

 

log local0. "rule session_limit initialized: total/max: $::total_active_clients/$::max_active_clients"

 

}

 

 

 

when HTTP_RESPONSE {

 

if {[HTTP::cookie "JSESSIONID"] != ""}{

 

if {$::total_active_clients < $::max_active_clients}{

 

incr ::total_active_clients +1

 

log local0. "under session total/max: $::total_active_clients/$::max_active_clients"

 

} else {

 

if { [HTTP::status] == 200 } {

 

HTTP::respond 503 [subst $::session_error]

 

log local0. "over session session: total/max: $::total_active_clients/$::max_active_clients"

 

}

 

}

 

}

 

}

 

 

But I can't get this to work right. It's my first serious iRule that I'm trying to write and could use some tips or a point in the right direction. Right now I just want to make sure that the HTTP_RESPONSE has a JSESSIONID and once the limit is reached then send all other requests the HTTP::RESPOND that I set up as a 503 even if they are succesful to login to the application. This way if the max JSESSIONID is reached they don't get into the application, but it allows all original HTTP requests to go in and not throttle on the request.

 

 

Thanks for the help.
  • Your irule is not correctly tracking the active sessions or connection (connections and disconnections)

     

     

    The following a discussion thread that is similar to what you are looking to do

     

     

    http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&postid=1990

     

     

    Hope this helps

     

    CB

     

  • Thanks so much. I think this helps out a lot. I didn't have an array set up, just trying to count HTTP responses with the JSESSIONID cookie. I think I may have a better grasp on this now, just have to redo it a little bit.