Using memcached to throttle connections

606 Views Asked by At

I'm trying to understand how rack-attack uses memcached to throttle connections.

As far as I can tell there's no easy way to manage lists in memcached, and no way to search keys by prefix. Yet rack-attack is somehow keeping a list count within cache, but I'm staring at the source code and can't figure out how it works?

https://github.com/kickstarter/rack-attack/blob/master/lib/rack/attack/throttle.rb https://github.com/kickstarter/rack-attack/blob/master/lib/rack/attack/cache.rb

1

There are 1 best solutions below

1
On BEST ANSWER

It's possible to emulate namespacing, tagging and indexing with memcached, which allows you to work around many limitations (in your case you could maintain prefixes as tags). This article has some good ideas, and the memcached docs have some neat tricks too.