Forum Discussion
Bruce_Bronczyk
Altostratus
Jun 13, 2014Randomly unpredictable rate limiting using the iRule iRules.virtual_server_connection_rate_limit_with_tables.ashx
Has anyone used this iRule, https://devcentral.f5.com/wiki/iRules.virtual_server_connection_rate_limit_with_tables.ashx, and seen issues with random rate limiting for some connections well below the ...
Kevin_Davies_40
Nacreous
Jun 13, 2014Try this and let me know how it performs for you...
when CLIENT_ACCEPTED {
this will give you 20 connections per second per source IP address
set cid [clock clicks]
set conns 20
set rate 1
table set -subtable [virtual]:[IP::client_addr] $cid 0 indef $rate
if {[table keys -subtable [virtual]:[IP::client_addr] -count] > $conns} {
table delete -subtable [virtual]:[IP::client_addr] $cid
TCP::close
}
}
In a BIGIP there will be many other instances of this iRule (one per TCP connection) running at the same time. When we get to the IF condition they could all say they are under the connection limit because they perform the test at the same moment in time.
To allow for this, we allocate the connection entry (table set), then backout (table delete) if we are over the limit (table keys -count). Since the table is always the source of truth, we never exceed the rate limit.
- Kevin_Davies_40Jun 13, 2014
Nacreous
One second is the lowest resolution of table expiry timer. You may want to up this a little so if its 20 connections per second, you may get better results with 200 per 10 seconds. - Kevin_Davies_40Jun 15, 2014
Nacreous
If any of the above posts have provided a solution to your issue, please indicate so by clicking the tick to the left of them. This gives feedback and recognition to the volunteers who responded to your issue - Bruce_BronczykJun 17, 2014
Altostratus
Thanks for the suggestion. I am not very experienced with editing iRules, so does your suggested change insert into the iRule at a specific spot or does it replace some of the existing iRule below the 'when CLIENT_ACCEPTED' point? Thanks. - Kevin_Davies_40Jun 17, 2014
Nacreous
It replaces the entire rate limiting iRule with what I have posted above.
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