def addRequest(self, r): HARD_QUOTA = 45 SOFT_QUOTA = 25 STEPS = 10 divisor = (HARD_QUOTA - SOFT_QUOTA) / STEPS self.received += 1 self.req_modulus = (self.req_modulus + 1) % STEPS # Are we overloaded? load = self.getLoad() # Become progressively more likely to reject requests # once load > soft quota; reject everything once load # hits hard limit. threshold = int((HARD_QUOTA - load) / divisor) if self.req_modulus < threshold: # We're not too loaded self.active_requests.append(r) self.accepted += 1 else: self.rejected += 1
0 件のコメント :
コメントを投稿