Skip to content

Provides a BulkheadPolicy (parallel throttle) for which the capacity can be adjusted dynamically

License

BSD-3-Clause, Unknown licenses found

Licenses found

BSD-3-Clause
LICENSE
Unknown
LICENSE.txt
Notifications You must be signed in to change notification settings

Polly-Contrib/Polly.Contrib.MutableBulkheadPolicy

Polly.Contrib.MutableBulkheadPolicy

Provides a BulkheadPolicy (parallel throttle) for which the capacity can be adjusted dynamically. This is the mutable version of the the bulkhead policy that came with Polly.

For more information on Bulkhead Policy see the Bulkhead doc.

For more background on Polly see the main Polly repo.

NuGet version Build status

Usage

Asynchronous executions

// To create:
AsyncMutableBulkheadPolicy bulkhead = AsyncMutableBulkheadPolicy
  .Create(int maxParallelization,
         [, int maxQueuingActions]
         [, Action<Context> onBulkheadRejected]);

// To adjust capacity at a later time:
bulkhead.MaxParallelization = 10;
bulkhead.MaxQueueingActions = 2;

Synchronous executions

// To create:
MutableBulkheadPolicy bulkhead = MutableBulkheadPolicy
  .Create(int maxParallelization,
         [, int maxQueuingActions]
         [, Action<Context> onBulkheadRejected]);

// To adjust capacity at a later time:
bulkhead.MaxParallelization = 10;
bulkhead.MaxQueueingActions = 2;

Adjusting the bulkhead capacity

The bulkhead capacity can be adjusted any time after creation, by setting the properties MaxParallelization or MaxQueueingActions, either together or individually:

bulkhead.MaxParallelization = 6;
bulkhead.MaxQueueingActions = 1;

If the adjustment increases capacity, the increased capacity will be granted immediately.

If the adjustment decreases capacity:

  • where the capacity to be removed is currently unused (no actions executing through those bulkhead slots), it will be removed immediately.
  • where capacity to be removed is currently in use (actions are executing through those bulkhead slots), the capacity will be removed when actions complete; actions in progress will not be terminated.

For example, consider a scenario where the capacity prior to adjustment is 10, of which 8 slots are currently occupied with executions. On a request to reduce capacity to 6, two slots will be removed from capacity immediately, and a further two slots will be removed from capacity as and when two further actions complete.

While a bulkhead is temporarily acting over-capacity (eg 8 executions are in progress but the bulkhead is pending reducing capacity to 6), incoming actions will be load-shedded until the bulkhead utilisation reduces to the desired capacity level.

Code of Conduct

We ask our contributors to abide by the Code of Conduct of the .NET Foundation.

License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the BSD 3-Clause license.

About

Provides a BulkheadPolicy (parallel throttle) for which the capacity can be adjusted dynamically

Resources

License

BSD-3-Clause, Unknown licenses found

Licenses found

BSD-3-Clause
LICENSE
Unknown
LICENSE.txt

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published