Apr
17th
Thu
17th
Comment Cool-Down Using memcached
Caught this nice tip from the makers of Forumwarz, re: preventing users or bots from flooding you with form submissions:
“Memcached allows you to set an expiry for any key you set. So, instead of using the timestamp column in the database [to prevent multiple requests within a timeframe], you can simply set a key in memcached with an expiry of your cool down period. Then, when you are about to insert, check to see if the key exists in memcached. If it does, don’t insert. If it doesn’t, insert your row and then add the key there.”
Nice to remember when scaling makes it worth adding memcached to your infrastructure (memcached requires some sort of vlan for secure deployment, otherwise _anyone_ can write to your caches).
You could also use Amazon’s SimpleDB or (for small sites) a session key. The point is to prevent flooders from tying up your database at all, if possible.