PagerDuty / pdpyras

Low-level PagerDuty REST/Events API client for Python
MIT License
129 stars 29 forks source link

Randomize rate limit cooldown to mitigate thundering herd effect #20

Closed Deconstrained closed 4 years ago

Deconstrained commented 4 years ago

A nice-to-have.

The cooldown time increases by a constant factor after each attempt. If there are many concurrent API requests, they will all retry at exactly the same time.

E.G.

import random
...
                sleep_timer *= self.sleep_timer_base*(1+random.random())