From 98709a437250b9da0d15bf5d579c71deac295a5f Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Mon, 29 Apr 2024 21:19:15 +0200 Subject: [PATCH] retry: reduce total number of retries Retries in restic try to solve two main problems: - retry a temporarily failed operation - tolerate temporary network interruptions The first problem only requires a few retries, whereas the last one benefits primarily from spreading the requests over a longer duration. Increasing the default multiplier and the initial interval works for both cases. The first few retries only take a few seconds, while later retries quickly reach the maximum interval of one minute. This ensures that the total number of retries issued by restic will remain at around 21 retries for a 15 minute period. As the concurrency in restic is bounded, retries drastically reduce the number of requests sent to a backend. This helps to prevent overloading the backend. --- internal/backend/retry/backend_retry.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/backend/retry/backend_retry.go b/internal/backend/retry/backend_retry.go index e40cce122..7f2b4f745 100644 --- a/internal/backend/retry/backend_retry.go +++ b/internal/backend/retry/backend_retry.go @@ -108,6 +108,9 @@ func (be *Backend) retry(ctx context.Context, msg string, f func() error) error bo := backoff.NewExponentialBackOff() bo.MaxElapsedTime = be.MaxElapsedTime + bo.InitialInterval = 1 * time.Second + bo.Multiplier = 2 + if fastRetries { // speed up integration tests bo.InitialInterval = 1 * time.Millisecond