THROTTLE_ZONES = { # 限制请求频率 10次/分 'default': { 'VARY':'throttle.zones.RemoteIP', 'NUM_BUCKETS':2, # Number of buckets worth of history to keep. Must be at least 2 'BUCKET_INTERVAL':1 * 60, # Period of time to enforce limits. 'BUCKET_CAPACITY':10, # Maximum number of requests allowed within BUCKET_INTERVAL }, # 限制请求频率 50次/小时 'order': { 'VARY':'throttle.zones.RemoteIP', 'NUM_BUCKETS':2, # Number of buckets worth of history to keep. Must be at least 2 'BUCKET_INTERVAL':60 * 60, # Period of time to enforce limits. 'BUCKET_CAPACITY':50, # Maximum number of requests allowed within BUCKET_INTERVAL }, } THROTTLE_BACKEND = 'throttle.backends.cache.CacheBackend' # Force throttling when DEBUG=True THROTTLE_ENABLED = True
THROTTLE_ZONES = { # 限制请求频率 10次/分 'default': { 'VARY':'throttle.zones.RemoteIP', 'NUM_BUCKETS':2, # Number of buckets worth of history to keep. Must be at least 2 'BUCKET_INTERVAL':1 * 60, # Period of time to enforce limits. 'BUCKET_CAPACITY':10, # Maximum number of requests allowed within BUCKET_INTERVAL }, # 限制请求频率 50次/小时 'order': { 'VARY':'throttle.zones.RemoteIP', 'NUM_BUCKETS':2, # Number of buckets worth of history to keep. Must be at least 2 'BUCKET_INTERVAL':60 * 60, # Period of time to enforce limits. 'BUCKET_CAPACITY':50, # Maximum number of requests allowed within BUCKET_INTERVAL }, } THROTTLE_BACKEND = 'throttle.backends.cache.CacheBackend' # Force throttling when DEBUG=True THROTTLE_ENABLED = True