Forum Discussion
mrintzler
Nimbostratus
Feb 04, 2008iRule causing ever-increasing TMM CPU utilization
I've adapted an iRule written by Deb Allen to rate limit (in count, not in bps) PDF downloads from one of our web applications. It basically counts the number of PDF's downloaded in the past 10 secon...
Deb_Allen_18
Feb 06, 2008Historic F5 Account
To answer your question, I've used the clock to trigger periodic housekeeping in other circumstances, something like this:
when RULE_INIT {
set ::pdfappmaxRate 10 ;set later per user from class
set ::pdfappwindowSecs 10 ;global
init array if non-existent
array set ::pdfHistory { }
wipe array if already existent
array unset ::pdfHistory
set ::housekeeping_clock [clock seconds]
set ::housekeeping_interval 900
}
when HTTP_REQUEST {
if { [clock seconds] > [expr {$::housekeeping_clock + $::housekeeping_interval}] }{
wipe array if already existent
array unset ::pdfHistory
}
...
}
However, this code block should reap the old entries from the array upon every request:
count GETs within the window, delete those that are older
foreach { requestID requestTime } [array get ::pdfHistory ${pdfapp_session}*] {
count pdf downloadss with start time > $pdfappwindowStart, delete the rest
if { $requestTime > $pdfappwindowStart } {
incr pdfCount 1
} else {
unset ::pdfHistory($requestID)
}
}Not sure why it isn't doing so. Before I added another periodic housekeeping function, esp one that's indiscriminate like that above, I'd try to figure out why this isn't working. I'd start by adding some logging here to see if anything is matching the delete condition.
HTH
/deb
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
