Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add truncated exponential backoff with full jitter #459

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

jooola
Copy link
Member

@jooola jooola commented Jun 13, 2024

  • Add a truncated exponential back off function with full jitter,
  • The existing exponential back off function is now capped to 60s.

https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/

BEGIN_COMMIT_OVERRIDE
feat: add truncated exponential backoff with full jitter (#459)
END_COMMIT_OVERRIDE

@jooola jooola requested a review from a team as a code owner June 13, 2024 15:46
@jooola
Copy link
Member Author

jooola commented Jun 13, 2024

I provided a ExponentialBackoffWithOpts function with some knobs, but we still need to discuss the default parameters for our ExponentialBackoff function.

Copy link

codecov bot commented Jun 13, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.

Project coverage is 71.49%. Comparing base (96d4226) to head (5df651a).

Files Patch % Lines
hcloud/client.go 85.71% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #459      +/-   ##
==========================================
+ Coverage   71.40%   71.49%   +0.08%     
==========================================
  Files          45       45              
  Lines        3864     3876      +12     
==========================================
+ Hits         2759     2771      +12     
  Misses        691      691              
  Partials      414      414              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jooola jooola force-pushed the capped-backoff-with-jitter branch from 94df1aa to 39ba358 Compare June 13, 2024 15:51
Copy link
Member

@apricote apricote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general. Could you describe where the 24 seconds are coming from?

@jooola jooola marked this pull request as draft June 18, 2024 12:00
@jooola jooola force-pushed the capped-backoff-with-jitter branch from 39ba358 to 72bc103 Compare June 24, 2024 12:36
@jooola jooola force-pushed the capped-backoff-with-jitter branch from 72bc103 to 62f2c0f Compare July 9, 2024 15:11
@jooola jooola changed the title feat: cap exponential backoff to 24s and add jitter feat: add truncated exponential backoff with full jitter backoff Jul 9, 2024
@jooola jooola force-pushed the capped-backoff-with-jitter branch from 62f2c0f to ae4bf37 Compare July 9, 2024 15:37
@jooola jooola force-pushed the capped-backoff-with-jitter branch from ae4bf37 to 5df651a Compare July 9, 2024 15:38
@jooola jooola marked this pull request as ready for review July 9, 2024 15:38
@jooola
Copy link
Member Author

jooola commented Jul 9, 2024

This PR now primarily adds a new back off function. The change to the existing ExponentialBackoff function is almost negligible (cap to 60s).

The change to the default values of the existing ExponentialBackoff should be done in a future PR or not at all.

@jooola jooola requested a review from apricote July 9, 2024 15:40
@jooola jooola merged commit fd1f46c into hetznercloud:main Jul 10, 2024
4 checks passed
@jooola jooola deleted the capped-backoff-with-jitter branch July 10, 2024 09:05
@jooola jooola changed the title feat: add truncated exponential backoff with full jitter backoff feat: add truncated exponential backoff with full jitter Jul 10, 2024
jooola pushed a commit that referenced this pull request Jul 23, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.11.0](v2.10.2...v2.11.0)
(2024-07-23)


### Features

* add truncated exponential backoff with full jitter
([#459](#459))
([fd1f46c](fd1f46c))
* allow configuring retry options
([#488](#488))
([2db9575](2db9575))
* **exp:** add sliceutil package
([#489](#489))
([f4ad6bc](f4ad6bc))
* **exp:** rename `*utils` package to `*util`
([#487](#487))
([19da475](19da475))
* respect cancelled contexts during retry sleep
([#470](#470))
([756f605](756f605))
* retry requests when the api gateway errors
([#470](#470))
([756f605](756f605))
* retry requests when the network timed out
([#470](#470))
([756f605](756f605))
* retry requests when the rate limit was reached
([#470](#470))
([756f605](756f605))


### Bug Fixes

* **exp:** set capacity for each batch
([#490](#490))
([57f53c1](57f53c1))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
apricote pushed a commit to hetznercloud/fleeting-plugin-hetzner that referenced this pull request Sep 12, 2024
…1.0 (hetznercloud/fleeting-plugin-hetzner!98)

This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/hetznercloud/hcloud-go/v2](https://github.com/hetznercloud/hcloud-go) | require | minor | `v2.10.2` -> `v2.11.0` |

---

### Release Notes

<details>
<summary>hetznercloud/hcloud-go (github.com/hetznercloud/hcloud-go/v2)</summary>

### [`v2.11.0`](https://github.com/hetznercloud/hcloud-go/releases/tag/v2.11.0)

[Compare Source](hetznercloud/hcloud-go@v2.10.2...v2.11.0)

##### Features

-   add truncated exponential backoff with full jitter ([#&#8203;459](hetznercloud/hcloud-go#459)) ([fd1f46c](hetznercloud/hcloud-go@fd1f46c))
-   allow configuring retry options ([#&#8203;488](hetznercloud/hcloud-go#488)) ([2db9575](hetznercloud/hcloud-go@2db9575))
-   **exp:** add sliceutil package ([#&#8203;489](hetznercloud/hcloud-go#489)) ([f4ad6bc](hetznercloud/hcloud-go@f4ad6bc))
-   **exp:** rename `*utils` package to `*util` ([#&#8203;487](hetznercloud/hcloud-go#487)) ([19da475](hetznercloud/hcloud-go@19da475))
-   respect cancelled contexts during retry sleep ([#&#8203;470](hetznercloud/hcloud-go#470)) ([756f605](hetznercloud/hcloud-go@756f605))
-   retry requests when the api gateway errors ([#&#8203;470](hetznercloud/hcloud-go#470)) ([756f605](hetznercloud/hcloud-go@756f605))
-   retry requests when the network timed out ([#&#8203;470](hetznercloud/hcloud-go#470)) ([756f605](hetznercloud/hcloud-go@756f605))
-   retry requests when the rate limit was reached ([#&#8203;470](hetznercloud/hcloud-go#470)) ([756f605](hetznercloud/hcloud-go@756f605))

##### Bug Fixes

-   **exp:** set capacity for each batch ([#&#8203;490](hetznercloud/hcloud-go#490)) ([57f53c1](hetznercloud/hcloud-go@57f53c1))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants