PollyBackoff 1.0.4

dotnet add package PollyBackoff --version 1.0.4
                    
NuGet\Install-Package PollyBackoff -Version 1.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PollyBackoff" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PollyBackoff" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="PollyBackoff" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PollyBackoff --version 1.0.4
                    
#r "nuget: PollyBackoff, 1.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PollyBackoff@1.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PollyBackoff&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=PollyBackoff&version=1.0.4
                    
Install as a Cake Tool

PollyBackoff

<img src="icon.png" width="100" align="right" />

NuGet CI

Backoff delay strategies for Polly v8 resilience pipelines.

Polly.Contrib.WaitAndRetry was built for Polly v7's WaitAndRetry() API. Polly v8 uses a DelayGenerator delegate — this package provides the same beloved strategies in the new API.

Install

dotnet add package PollyBackoff

Usage

Fluent extension on RetryStrategyOptions

using PollyBackoff;

var pipeline = new ResiliencePipelineBuilder<HttpResponseMessage>()
    .AddRetry(new RetryStrategyOptions<HttpResponseMessage>
    {
        MaxRetryAttempts = 5,
        ShouldHandle = new PredicateBuilder<HttpResponseMessage>()
            .Handle<HttpRequestException>()
            .HandleResult(r => !r.IsSuccessStatusCode)
    }
    .UseDecorrelatedJitter(baseDelay: TimeSpan.FromMilliseconds(100)))
    .Build();

Direct Backoff factory

var backoff = Backoff.DecorrelatedJitter(baseDelay: TimeSpan.FromMilliseconds(100));

var pipeline = new ResiliencePipelineBuilder()
    .AddRetry(new RetryStrategyOptions
    {
        MaxRetryAttempts = 5,
        DelayGenerator = args => new ValueTask<TimeSpan?>(backoff(args.AttemptNumber))
    })
    .Build();

Strategies

Based on the algorithm from Marc Brooker's blog and AWS guidance. Each delay is randomly chosen from [baseDelay, previous × factor], capped at maxDelay. Avoids retry storms by spreading attempts across time.

options.UseDecorrelatedJitter(
    baseDelay: TimeSpan.FromMilliseconds(100),
    factor: 3.0,              // default
    maxDelay: TimeSpan.FromSeconds(30));  // default

Exponential Backoff

delay = min(maxDelay, baseDelay × factor^attempt), with optional full jitter.

options.UseExponentialBackoff(
    baseDelay: TimeSpan.FromMilliseconds(100),
    factor: 2.0,              // default
    maxDelay: TimeSpan.FromSeconds(30),
    addJitter: true);

Linear Backoff

delay = baseDelay + increment × attempt, capped at maxDelay.

options.UseLinearBackoff(
    baseDelay: TimeSpan.FromMilliseconds(100),
    increment: TimeSpan.FromMilliseconds(100),  // defaults to baseDelay
    maxDelay: TimeSpan.FromSeconds(10),
    addJitter: false);

Constant Backoff

Fixed delay every attempt, with optional ±jitter.

options.UseConstantBackoff(
    delay: TimeSpan.FromSeconds(1),
    addJitter: true,
    jitterFactor: 0.1);  // ±10%

Composing with existing DelayGenerator

Each strategy also exposes a Func<int, TimeSpan> you can use directly:

var backoff = Backoff.ExponentialBackoff(TimeSpan.FromMilliseconds(100), addJitter: true);

// attempt 0 → ~100ms, attempt 1 → ~200ms, attempt 2 → ~400ms (with jitter)
TimeSpan delay = backoff(attemptNumber);

License

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.4 82 6/22/2026
1.0.1 81 6/17/2026
1.0.0 83 6/17/2026

1.0.2: Added net6.0 and net9.0 targets; improved discoverability tags.