Forum Discussion
Andrew-F5
Sep 30, 2020Employee
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
}