Skip to content

Add exponential backoff to downloads#715

Open
shelvacu wants to merge 1 commit into
SteamRE:masterfrom
shelvacu-forks:patch-add-backoff
Open

Add exponential backoff to downloads#715
shelvacu wants to merge 1 commit into
SteamRE:masterfrom
shelvacu-forks:patch-add-backoff

Conversation

@shelvacu

Copy link
Copy Markdown
Contributor

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

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.

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
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.

1 participant