boto / botocore

The low-level, core functionality of boto3 and the AWS CLI.
Apache License 2.0
1.44k stars 1.06k forks source link

Fix calculation of truncated binary exponential backoff #3178

Closed jamesls closed 1 month ago

jamesls commented 1 month ago

The intent of the jitter in the exponential backoff calculation is to create a uniform random distribution. However, the current calculation applies the truncation after the randomization. This results in clamped/truncated distribution which is not what we want.

This only affects cases where the calculated backoff exceeds the MAX_BACKOFF, and is more pronounced the more you exceed MAX_BACKOFF. The current default of 3 max attempts is well below this value so this change has no effect on the default behavior. A user would have to have a max attempts of at least 6 before this started to affect backoff times.

As an example, this is a distribution based on 10,000 events with attempt=10 (x-axis is backoff time in seconds):

current

And here's the distribution with 10,000 events with attempt=10 with the changes in this PR:

fixed

codecov-commenter commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 93.14%. Comparing base (52e97a5) to head (47bfd56). Report is 367 commits behind head on develop.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #3178 +/- ## ======================================== Coverage 93.14% 93.14% ======================================== Files 66 66 Lines 14237 14248 +11 ======================================== + Hits 13261 13272 +11 Misses 976 976 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.