limit PUT, DELETE, POSTs to /a/c and /a/c/o

This commit is contained in:
David Goetz 2011-07-12 08:15:15 -07:00
parent e3ff894fab
commit 01307fd46f
2 changed files with 9 additions and 10 deletions
doc/source
swift/common/middleware

@ -35,20 +35,17 @@ rate_buffer_seconds 5 Number of seconds the rate counter can
faster than listed rate). A larger number
will result in larger spikes in rate but
better average accuracy.
account_ratelimit 0 If set, will limit all requests to
/account_name and PUTs to
/account_name/container_name. Number is in
requests per second
account_ratelimit 0 If set, will limit PUT, DELETE, and POST
requests to /account_name/container_name.
Number is in requests per second.
account_whitelist '' Comma separated lists of account names that
will not be rate limited.
account_blacklist '' Comma separated lists of account names that
will not be allowed. Returns a 497 response.
container_ratelimit_size '' When set with container_limit_x = r:
for containers of size x, limit requests
per second to r. Will limit GET and HEAD
requests to /account_name/container_name
and PUTs and DELETEs to
/account_name/container_name/object_name
per second to r. Will limit PUT, DELETE,
and POST requests to /a/c/o.
======================== ========= ===========================================
The container rate limits are linearly interpolated from the values given. A

@ -105,15 +105,17 @@ class RateLimitMiddleware(object):
:param obj_name: object name from path
"""
keys = []
limit_req_types = ['PUT', 'DELETE', 'POST']
# COPYs are not limited
if self.account_ratelimit and \
account_name and container_name and not obj_name and \
req_method in ('PUT', 'DELETE', 'POST'):
req_method in limit_req_types:
# account_ratelimit PUTs/DELETEs to acc_name/cont_name
keys.append(("ratelimit/%s" % account_name,
self.account_ratelimit))
if account_name and container_name and obj_name and \
req_method in ('PUT', 'DELETE', 'POST', 'COPY'):
req_method in limit_req_types:
# container_ratelimit PUTs/DELETEs to acc_name/cont_name/obj_name
container_size = None
memcache_key = get_container_memcache_key(account_name,