I do it using htable. I maintain a rolling 3-second sample of number of
calls in 'htable', the tail of which is auto-expired. The need to
implement CPS limits was the basis for the 'updateexpires' option I
added to the htable code in Dec 2011--I wanted updates not to cause
entries' expiration time to be reset.
Divide by 3, get CPS. It's crude, but effective. One can, of course,
have a longer sampling window.
--
Alex Balashov - Principal
Evariste Systems LLC
Tel: +1-678-954-0670
Web:
http://www.evaristesys.com/,
http://www.alexbalashov.com/
Please be kind to the English language:
http://www.entrepreneur.com/article/232906