AdaptiveThrottleManager
- Namespace:
PPDS.Dataverse.BulkOperations - Assembly:
PPDS.Dataverse - Kind: Class
Summary
Dynamically adjusts the degree of parallelism (DOP) for bulk DML operations
in response to Dataverse 429 (service protection limit) errors.
Complementary to PPDS.Dataverse.BulkOperations.AdaptiveBatchSizer which adjusts batch SIZE;
this class adjusts thread COUNT.
Members
Constructors
AdaptiveThrottleManager(int maxDop, int initialDop, int successThreshold, Nullable<TimeSpan> cooldownPeriod, Func<DateTime> clock)
AdaptiveThrottleManager(int maxDop, int initialDop, int successThreshold, Nullable<TimeSpan> cooldownPeriod, Func<DateTime> clock)
Initializes a new instance of the PPDS.Dataverse.BulkOperations.AdaptiveThrottleManager class.
-
Param
maxDop: Maximum degree of parallelism (upper bound). Must be at least 1. -
Param
initialDop: Initial active DOP. If zero or negative, defaults tomaxDop. Clamped to [1,maxDop]. -
Param
successThreshold: Number of consecutive successes required before DOP can increase. Default: 5. -
Param
cooldownPeriod: Minimum time after a throttle before DOP can increase. Default: 30 seconds. If null, usesPPDS.Dataverse.BulkOperations.AdaptiveThrottleManager.DefaultCooldownPeriod. -
Param
clock: Optional clock function for testability. Returns UTC now. If null, usesSystem.DateTime.UtcNow.
Methods
RecordSuccess
void RecordSuccess()
Records a successful batch execution. After PPDS.Dataverse.BulkOperations.AdaptiveThrottleManager.SuccessThreshold
consecutive successes AND PPDS.Dataverse.BulkOperations.AdaptiveThrottleManager.CooldownPeriod since the last throttle,
increments the active DOP by one (up to PPDS.Dataverse.BulkOperations.AdaptiveThrottleManager.MaxDop).
RecordThrottle
void RecordThrottle()
Records a throttle (429) event. Halves the active DOP (minimum 1), resets the consecutive success counter, and records the throttle timestamp.
Properties
ActiveDop
int ActiveDop { get; }
Gets the current active degree of parallelism.
ConsecutiveSuccesses
int ConsecutiveSuccesses { get; }
Gets the number of consecutive successes since the last throttle or DOP increase.
CooldownPeriod
TimeSpan CooldownPeriod { get; }
Gets the cooldown period after a throttle before DOP can increase.
LastThrottleTime
DateTime LastThrottleTime { get; }
Gets the timestamp of the last throttle event, or System.DateTime.MinValue
if no throttle has occurred.
MaxDop
int MaxDop { get; }
Gets the maximum degree of parallelism (upper bound for recovery).
SuccessThreshold
int SuccessThreshold { get; }
Gets the number of consecutive successes required before DOP can increase.
Fields
DefaultCooldownPeriod
TimeSpan DefaultCooldownPeriod
Default cooldown period after a throttle before DOP can increase.
DefaultSuccessThreshold
int DefaultSuccessThreshold
Default number of consecutive successes required before increasing DOP.