Skip to content

perf(retry): add jitter to retryWithBackoff to prevent thundering her…#811

Open
xtrial01 wants to merge 2 commits into
rinafcode:mainfrom
xtrial01:perf/740-retry-backoff-jitter
Open

perf(retry): add jitter to retryWithBackoff to prevent thundering her…#811
xtrial01 wants to merge 2 commits into
rinafcode:mainfrom
xtrial01:perf/740-retry-backoff-jitter

Conversation

@xtrial01

Copy link
Copy Markdown

Description

Add random jitter to retryWithBackoff to prevent thundering herd problem during server recovery.

Previously, all clients retried at identical deterministic intervals (1s, 2s, 4s), causing synchronized traffic spikes. Now each retry delay includes random jitter to spread the load.

Changes

  • Added jitterMs option (default 500ms) to retryWithBackoff
  • Delay formula: Math.min(initialDelay * factor^attempt + random * jitterMs, maxDelay)
  • Removed unused delayMs variable from previous implementation
  • Updated unit tests to account for jitter range

Related Issue

Closes #740

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@xtrial01 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Performance] retryWithBackoff has no jitter — causes thundering herd on server recovery

1 participant