What is the best approach to throttling the number of actions a user can do to one per minute?
@route('/do_something/<cmd>',method=['GET','POST'])
def my_command(cmd):
# Only allow this to be executed once every 60s per user/ip.
I am looking for a server side solution, as I want to enforce this based on the users IP-address.
There may be already existing throttling
solutions in python and more specifically bottle framework.
You may roll out your own using a storage, and some minor scripting.
Since,your throttling period is pretty small i.e. 1 minute, memcache would be a good candidate to store the values.
3 (a). Value does not exist : - Store current timestamp integer in memcache with this hash as key, TTL 1 minute.
(b) Value exists : - Discard the request.
Here is a very good decorator written for redis ( for flask framework, but will work anywhere else too ) :