Forum Discussion
AppleBee_108607
Oct 31, 2010Historic F5 Account
CMP compatible Connection Limit per pool member
Hi,
I (think I) wrote an CMP compatible iRule to limit connnections per pool member, just by modificating the sample here:
v10.1 - The table Command - Examples (http://devcentral.f5.c...
spark_86682
Nov 01, 2010Historic F5 Account
I don't think that's quite right, no. You're trying to limit the number of connections (keys) that each pool member (subtable) has. So your subtable name should be the pool member, not the client.
Also, there's a tiny bug with some examples from that article series, but it's easily fixed:
when CLIENT_ACCEPTED {
set key "[IP::client_addr]:[TCP::client_port]"
when LB_SELECTED {
set tbl "connlimit:[LB::server]"
table set -subtable $tbl $key "ignored" 180
if { [table keys -subtable $tbl -count] > 5 } {
table delete -subtable $tbl $key
event CLIENT_CLOSED disable
reject
} else {
set timer [after 60000 -periodic { table lookup -subtable $tbl $key }]
}
when CLIENT_CLOSED {
after cancel $timer
table delete -subtable $tbl $key
}
I haven't tested this code, but it should work.
The purpose of the timer is to keep the entry in the subtable for as long as the connection exists. Otherwise the connection could still be alive but the subtable entry could expire. If the client closes normally, the CLIENT_CLOSED event will fire which will delete the entry and cancel the timer. If there's some very unusual condition and CLIENT_CLOSED doesn't fire, the timer will get cleaned up automatically, and the subtable entry will expire on its own, exactly preventing any zombie subtable entries (which would mess up the count).
Finally, if this solution doesn't work for you, you could just disable CMP on the virtuals which need this extremely low connection count.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