Skip to content

Commit 591587c

Browse files
authored
Randomize sleep time in concurrent request limiter (#1606)
1 parent f410c2b commit 591587c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

services/libs/redis/src/rateLimiter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ export class ConcurrentRequestLimiter implements IConcurrentRequestLimiter {
4949

5050
if (!canMakeRequest) {
5151
if (retries > 0) {
52-
await timeout(sleepTimeMs)
52+
const randomizedSleepTime = sleepTimeMs + Math.floor(Math.random() * sleepTimeMs)
53+
await timeout(randomizedSleepTime)
5354
return this.checkConcurrentRequestLimit(integrationId, retries - 1, sleepTimeMs)
5455
} else {
5556
throw new Error(`Too many concurrent requests for integration ${integrationId}`)

0 commit comments

Comments
 (0)