Forum Discussion

Matt_Breedlove_'s avatar
Matt_Breedlove_
Icon for Nimbostratus rankNimbostratus
May 02, 2009

Global 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

4 Replies

  • I suppose in an irule you can create ::CNT

    Here is somewhat an example

     
     when RULE_INIT { 
        set ::CNT 0 
       } 
       when HTTP_REQUEST { 
        incr ::CNT 
       } 
        
     when CLIENT_CLOSED { 
        ; decrement current connection counter 
        if {$::CNT > 0} { 
          incr ::cnt -1 
        } 
       } 
     

    However, I am a bit puzzled as to why you would want to Round Robin a connection to multiple pools. This would indicate the nodes in the multiple pools are the same, therefore you wouldn't need to separate them in multiple pools but in one pool.

    CB

  • 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?

     

    Does RULE_INIT only fire the very first time VS comes up from down state and takes first connection?

     

    I thought it was every new connection on irule enhanced VS?

     

     

    We are evaluating two different paths. One is to use GTM and balance over our two LTM/pools (each pool has LTM VS at head), however we may have unrelated challenges using GTM so we are looking at using LTM only solution as plan b. Both LTM's are in same data center. We are using GTM to manage code risk over two banks of multi layer app servers with no crosstalk once entering the bank.

     

     

    One bank has end of life legacy physical hardware that is still taking majority of site load. Second bank is all vm guest servers, but only built to currently handle 15% of load. Slowly we are building out VM cluster and incrementally decom physical cluster. Trying to remove all dependency on the legacy pools, vs's, server, etc so we can just modulate traffic over to new pool and eventually just shutoff/delete legacy objects.

     

     

    So given the disparity in resources between the two I would probably have to start with something really safe like. Every 500 connections, send 1 to the new pool and then calibrate it for our peak spikes.

     

    So the global counter would incr say up to 500 (each local connection contributing to incr/decr), each time before pooling the connection to the larger pool, once hitting 500 it gets reset to 0 and then pooled to the new pool

     

     

    Sorry if I am being redundant, just wanted to be clear

     

     

    Thanks for you help!
  • 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.

     

     

    I found a sample irule that someone contributed to the samples section (Click here)

     

     

    The irule is for limiting connection BUT it can be modified to send traffic to a different pool when it reaches 500 connections OR if you want to send it to a different virtual servers you can send the client a javascript that redirects them altogether.

     

     

    Do you think this might help?

     

     

    CB

     

  • Ah thanks for clarifying that. Also that connection limit rule, looks promising. I will check it out

     

     

    Thanks again : )