Forum Discussion

saravana_kumar's avatar
saravana_kumar
Icon for Nimbostratus rankNimbostratus
Sep 04, 2020

Virtual server connection limite through iRule

 

Need iRule help connection limite and redirection

 

Requirement : we have two set of pool A & B, pool A having 8 nodes, Pool B having 3 node

 

We have to limit the connection 3000 on pool A and renaming new connection flow to pool B

 

If the active connection is less than 3000 new connection flow to pool A

  • You can probably reference this other DevCentral post to get most of the way to your goal, https://devcentral.f5.com/s/question/0D51T00006i7TIA/connection-limit-on-virtual-server

    The iRule below is an example I created but has not been tested for functionality or requirements.

    when RULE_INIT {
    	set ::active_connections 0
    	set ::max_connections 3000
    }
    when CLIENT_ACCEPTED {
    	#Check if we're over the maximum allowed connections
    	if {$::active_connections > $::max_connections } {
    		# We're over the max, send to pool B
    		pool B
    	} else {
    		# We're not over the max, so send to Pool A and increment active_connections
    		incr ::active_connections 1
    		pool A
    	}
    }
    when CLIENT_CLOSED {
    	# A connection was closed, so decrement the global counter
    	incr ::active_connections -1
    }