Forum Discussion

Michael_Farnan_'s avatar
Michael_Farnan_
Icon for Nimbostratus rankNimbostratus
May 25, 2007

DataGroup with > operator for connection limit

I am trying to limit the number of connections coming in, with 2 limits. One for projects that will be busy, and 1 for everything else.

The problem i've run into, is i'd like to be able to use Datagroups instead of the variables at the RULE_INIT but I can not seem to get the comparison to work when I switch it to use the integer data group.

This would allow us to adjust the maximums on the fly. With it in the RULE_INIT section, any time you adjust those numbers, it resets the activeConnections which means we lose track of all the connections we currently have.


when RULE_INIT {
This holds the number of currently active connections.
set ::activeConnections 0
This is the maximum number of connections allowed for high volume projects.
set ::maximumHighVolumeConnections 4
This is the maximum connections allowed for the entire datacenter.
set ::maximumConnections 6
}
if we have too many connections respond with an error page stating we're too busy.
if {$::activeConnections > $::maximumConnections}
{
log local0. "Maximum sessions exceeded active sessions is $::activeConnections max sessions is $::maximumConnections"
HTTP::respond 200 content "We are currently experiencing extermely high volume please try back later."
}
elseif { ($::activeConnections >  $::maximumHighVolumeConnections) and [matchclass [HTTP::path] starts_with $::HighVolumeProjects]}
{
if we have too many connections from high volume projects respond with an error page stating we're too busy.
log local0. "High Volume Client Not Allowed active sessions is $::activeConnections max sessions is  $::maximumHighVolumeConnections'"
HTTP::respond 200 content "We are currently experiencing high volume please try back later."
}

5 Replies

  • Additionaly i'm wondering if you can use the respond command to point to an actual html page stored on the LTM.
  • Can you post the example you're working on using datagroups? Can you add a log statement to see what string you're getting from the datagroup when trying to perform the comparison?

     

     

    Also, while you can't specify a filesystem page exactly using HTTP::respond, you can respond with content. Check this post for details (Click here)

     

     

    Aaron
  •  

    The way i've got it setup now is the same syntax with just a different name. I'm guessing I need to beable to refer to just a single element of the datagroup, but I haven't found a way to do this.

     

     

    if {$::activeConnections > $::maxConnections}

     

     

    Here is the log.

     

     

    May 29 12:42:11 tmm tmm[21376]: Rule BusyPage :Allowed active sessions is 1 max sessions is {2} max heavy sessions is {0}

     

     

    The only difference between this entry and the other one, is the curly brackets around the integers.

     

  • I was able to fix this using lindex (classname) (index)

     

     

    if we have too many connections respond with an error page stating we're too busy.

     

    if {$::activeConnections > [lindex $::maxConnections 0]}
  • Perfect. As you found, a datagroup is just a TCL list. So to reference the list item, you can specify the index of the element.

     

     

    Aaron