diff --git a/doc/source/ratelimit.rst b/doc/source/ratelimit.rst index 4924b71153..ac88d22f96 100644 --- a/doc/source/ratelimit.rst +++ b/doc/source/ratelimit.rst @@ -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 diff --git a/swift/common/middleware/ratelimit.py b/swift/common/middleware/ratelimit.py index f5bb00a254..9780da6b16 100644 --- a/swift/common/middleware/ratelimit.py +++ b/swift/common/middleware/ratelimit.py @@ -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,