Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backoff straitegy #2

Open
huan opened this issue Apr 23, 2020 · 0 comments
Open

Backoff straitegy #2

huan opened this issue Apr 23, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@huan
Copy link
Member

huan commented Apr 23, 2020

GRPC Connection Backoff Protocol

When we do a connection to a backend that fails, it is typically desirable to not retry immediately (to avoid flooding the network or the server with requests) and instead do some form of exponential backoff.

We have several parameters:

  1. INITIAL_BACKOFF (how long to wait after the first failure before retrying)
  2. MULTIPLIER (factor with which to multiply backoff after a failed retry)
  3. JITTER (by how much to randomize backoffs).
  4. MAX_BACKOFF (upper bound on backoff)
  5. MIN_CONNECT_TIMEOUT (the minimum time we're willing to give a connection to complete)

gRPC Proposed Backoff Algorithm

ConnectWithBackoff()
  current_backoff = INITIAL_BACKOFF
  current_deadline = now() + INITIAL_BACKOFF
  while (TryConnect(Max(current_deadline, now() + MIN_CONNECT_TIMEOUT))
         != SUCCESS)
    SleepUntil(current_deadline)
    current_backoff = Min(current_backoff * MULTIPLIER, MAX_BACKOFF)
    current_deadline = now() + current_backoff +
      UniformRandom(-JITTER * current_backoff, JITTER * current_backoff)

See

@huan huan added the enhancement New feature or request label Apr 23, 2020
@huan huan pinned this issue Mar 21, 2021
huan added a commit that referenced this issue Mar 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant