|  |  
 |   |   
 NAMEAlgorithm::Backoff::MIMD - Multiplicative Increment, Multiplicative Decrement (MIMD) backoff VERSIONThis document describes version 0.009 of Algorithm::Backoff::MIMD (from Perl distribution Algorithm-Backoff), released on 2019-06-20. SYNOPSIS use Algorithm::Backoff::MIMD;
 # 1. instantiate
 my $ab = Algorithm::Backoff::MIMD->new(
     #consider_actual_delay => 1, # optional, default 0
     #max_actual_duration   => 0, # optional, default 0 (retry endlessly)
     #max_attempts          => 0, # optional, default 0 (retry endlessly)
     #jitter_factor         => 0.25, # optional, default 0
     min_delay              => 2, # optional, default 0
     #max_delay             => 100, # optional
     initial_delay              => 3,   # required
     delay_multiple_on_failure  => 2,   # required
     delay_multiple_on_success  => 0.5, # required
 );
 # 2. log success/failure and get a new number of seconds to delay, timestamp is
 # optional but must be monotonically increasing.
 # for example, using the parameters initial_delay=3,
 # delay_multiple_on_failure=2, delay_multiple_on_success=0.5, min_delay=2:
 my $secs;
 $secs = $ab->failure();   # => 3    (= initial_delay)
 $secs = $ab->failure();   # => 6    (3 * 2)
 $secs = $ab->failure();   # => 12   (6 * 2)
 $secs = $ab->success();   # => 6    (12 * 0.5)
 $secs = $ab->success();   # => 3    (6 * 0.5)
 $secs = $ab->success();   # => 2    (max(3*0.5, min_delay=2))
 $secs = $ab->failure();   # => 4    (2 * 2)
Illustration using CLI show-backoff-delays (4 failures followed by 5 successes, followed by 3 failures):  % show-backoff-delays -a MIMD --initial-delay 3 --min-delay 2 \
     --delay-multiple-on-failure 2 --delay-multiple-on-success 0.5 \
     0 0 0 0   1 1 1 1 1   0 0 0
 3
 6
 12
 24
 12
 6
 3
 2
 2
 4
 8
 16
DESCRIPTIONUpon failure, this backoff algorithm calculates the next delay as: D1 = initial_delay D2 = max(min(D1 * delay_multiple_on_failure, max_delay), min_delay) ... Upon success, the next delay is calculated as: D1 = initial_delay D2 = max(min(D1 * delay_multiple_on_success, max_delay), min_delay) ... "initial_delay", "delay_multiple_on_failure", and "delay_multiple_on_success" are required. "initial_delay" and "min_delay" should be larger than zero; otherwise the next delays will all be zero. There are limits on the number of attempts (`max_attempts`) and total duration (`max_actual_duration`). It is recommended to add a jitter factor, e.g. 0.25 to add some randomness to avoid "thundering herd problem". METHODSnewUsage: new(%args) -> obj This function is not exported. Arguments ('*' denotes required arguments): 
 Return value: (obj) HOMEPAGEPlease visit the project's homepage at <https://metacpan.org/release/Algorithm-Backoff>. SOURCESource repository is at <https://github.com/perlancar/perl-Algorithm-Backoff>. BUGSPlease report any bugs or feature requests on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=Algorithm-Backoff> When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. SEE ALSOAlgorithm::Backoff::LILD Algorithm::Backoff::LIMD Algorithm::Backoff::MILD Algorithm::Backoff Other "Algorithm::Backoff::*" classes. AUTHORperlancar <perlancar@cpan.org> COPYRIGHT AND LICENSEThis software is copyright (c) 2019 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. 
 
 |