bandwidth-throttle / token-bucket

Implementation of the Token Bucket algorithm in PHP.
Do What The F*ck You Want To Public License
503 stars 77 forks source link

Probable memory eating for Memcached storage #20

Open alpha-and-omega opened 6 years ago

alpha-and-omega commented 6 years ago

I am talking about Memcached storage implementation (probably other too). Since you use memcached::set with ttl = 0, old unused buckets will stay in memory forever, and this is not good for websites with bucket-per-ip. For websites with 100000 visitors per day it will eat >100 bytes per record = 10Megabytes, and will grow each day. In a month it will eat ~ 300Megabytes and some vps servers will go down. I think it should be possible to set ttl to specific reasonable value.