Add exponential backoff to downloads#715
Open
shelvacu wants to merge 1 commit into
Open
Conversation
Sometimes the API thinks you're doing too many requests and so returns an error; continuing to repeat the request many times per second is a great way to make the steam server not like you very much. This adds a simple exponential backoff when attempting to grab a manifest and when downloading chunks. It waits 1.3 ^ (attempts so far - 1) seconds up to a maximum of 120 seconds. As a table, the wait times looks like this: n | time in seconds that it will wait after the nth request ---|------- 1 | 1.00 2 | 1.30 3 | 1.69 4 | 2.20 5 | 2.86 6 | 3.71 7 | 4.83 8 | 6.27 9 | 8.16 10 | 10.60 11 | 13.79 12 | 17.92 13 | 23.30 14 | 30.29 15 | 39.37 16 | 51.19 17 | 66.54 18 | 86.50 19 | 112.46 20+| 120.00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sometimes the API thinks you're doing too many requests and so returns an error; continuing to repeat the request many times per second is a great way to make the steam server not like you very much.
This adds a simple exponential backoff when attempting to grab a manifest and when downloading chunks.
It waits 1.3 ^ (attempts so far - 1) seconds up to a maximum of 120 seconds. As a table, the wait times looks like this:
Note: The numbers here (min 1s, exponent 1.3, max 120s) were chose somewhat on vibes. They seem roughly right to me, but if you have a better idea I'm happy to change it.