NServiceBus.RateLimiter 2.0.0-beta0001

This is a prerelease version of NServiceBus.RateLimiter.
There is a newer version of this package available.
See the version list below for details.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package NServiceBus.RateLimiter --version 2.0.0-beta0001
NuGet\Install-Package NServiceBus.RateLimiter -Version 2.0.0-beta0001
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="NServiceBus.RateLimiter" Version="2.0.0-beta0001" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NServiceBus.RateLimiter --version 2.0.0-beta0001
#r "nuget: NServiceBus.RateLimiter, 2.0.0-beta0001"
#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.
// Install NServiceBus.RateLimiter as a Cake Addin
#addin nuget:?package=NServiceBus.RateLimiter&version=2.0.0-beta0001&prerelease

// Install NServiceBus.RateLimiter as a Cake Tool
#tool nuget:?package=NServiceBus.RateLimiter&version=2.0.0-beta0001&prerelease

NServiceBus.RateLimiter

Before NServiceBus 6 there was the ability to throttle the number of messages processed per second. This feature was deprecated because throttling can be conflicting with the different types of tranports and transaction modes. This package restores this functionality.

Version compatibility

NServiceBus NServiceBus.RateLimiter
v6.x v1.x
v7.0 v2.x

Use cases

Rate limiting can be used to reduce the pressure on your infrastructure or the infrastructure of others. Lets assume you send out a mass mailing and you do not want to consume a lot of bandwidth or maybe you are calling into a third party services that doesn't allow more then 100 requests per second. Rate limiting can help to make the whole processing more efficient without triggering unneeded retry logic.

Important

The packages registers itself in the first stage of the pipeline (ITransportReceiveContext) this means that when this behavior is called the message is actually already retrieved from the queue. If you use a transactional queue this means that your transport transaction duration will increase (MSMQ, SQL Server, etc.). If you use lease based transport (Azure Storage Queues).

For this reason a warning log entry is written is the delay takes more then 5 seconds.

Message 'A88A7826-79B3-4203-BB3C-266DE76754F0' delayed by 00:01:15 due to throttling or due to other handlers taking a lot of time to complete. This can conflict with message lease times or transaction timeouts. Consider lowering the concurrency level or to shorten the rate limiting duration.

Consider lowering the concurrency level as that might cause the rate limit to be reached very fast.

Installation

Install the Nuget package NServiceBus.RateLimiter

Configuration

Automatic interval calculation

Calculates the smallest interval based on rate expressed in items per second based on the allowed concurrency.

endpointConfiguration.ApplyRateLimiting(int limitPersecond, int concurrency)

Limits the processing rate per second based on limitPersecond. It will calculate the smallest interval based on the specified concurrency.

Example:

If you allow for 100 messages per second, with a concurrency of 4 then the logic will limit processing of 4 messages every 400 milliseconds.

endpointConfiguration.ApplyRateLimiting(limitPerSecond:10, concurrency:4);

Manual

Manual control over the rate limit and duration.

endpointConfiguration.ApplyRateLimiting(int limit, TimeSpan duration)

If you do not want to use the smallest interval, but want to allow for higher burst rates then set concurrency to the max burst size.

Example:

If you allow for burst of 250 items as a rate of 10 messages per second then the logic will limit processing of 250 messages every 25 seconds.

endpointConfiguration.ApplyRateLimiting(limitPerSecond:10, concurrency:250);

Using this logic you can cope with sudden peaks of incoming messages but still maintain - on average - your rate of 10 messages per second.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.5.2

  • .NETStandard 2.0

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
3.1.0 622 7/16/2023
3.0.0 312 12/9/2022
2.1.0 62,854 5/23/2020
2.0.0 1,606 9/24/2019
1.0.4 3,151 11/25/2017

Targeting NServiceBus 7.0.0 beta0012