Forum Discussion
Matt_Breedlove_
Nimbostratus
May 02, 2009Global connection count variable
In LTM 9.3 how would one go about setting up a global connection variable? Goal is to atomically count each connection being made into LTM Virtual Server in a rolling counter
So if the Global var is ::CNT
then the first connection would set ::CNT to 1, then the next to 2, then the next back to 1 then the next back to 2, etc
Then in the iRule on the LTM it would choose which pool to send the current connection to based on whether ::CNT equals 1 or 2. So its a way to round robin or ratio round robin single Virtual server over multiple pools.
How would I do this safely and efficiently with global var? I would like to be able to add third or fourth pool also in future
Thanks
Matt
- The_Bhattman
Nimbostratus
I suppose in an irule you can create ::CNTwhen RULE_INIT { set ::CNT 0 } when HTTP_REQUEST { incr ::CNT } when CLIENT_CLOSED { ; decrement current connection counter if {$::CNT > 0} { incr ::cnt -1 } }
- Matt_Breedlove_
Nimbostratus
Thanks but I am confused by setting var to zero in RULE_INIT? Isn't that a local connection event so every new connection(exec of irule) will just reset it to zero killing any state value (0 or 1) between non local irule client connections? - The_Bhattman
Nimbostratus
RULE_INIT is only triggered when an iRule is added or is modified. This is where you set it up to initialize the global variable. - Matt_Breedlove_
Nimbostratus
Ah thanks for clarifying that. Also that connection limit rule, looks promising. I will check it out
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects