Is Google's documentation on exponential backo

2019-07-30 15:07发布

The example code in the online Google Drive documentation describing exponential backoff seems to be "off by one" when comparing it to the textual description given on the same page. The code goes in a loop from 0 to 4 (so trying the request at most 5 times), yet the textual numbered list before the code describes making the API request at most 6 times (1 normal try in step 1. and 5 retries in steps 3., 5., 7., 9. and 11.). The same problem is also there in the example code given for the Analytics API here.

Is my interpretation of the textual description off or is there really a mismatch between the code and the text?

(If there was a normal support forum, I would've posted this there, but there isn't, so S.O. it is...)

1条回答
冷血范
2楼-- · 2019-07-30 15:16

The important part about the algorithm is that its exponential, and not about the number of tries.
Its up to you how many tries you do as long as you double wait time on each iteration.
You can find other google and non-google samples where a small random delay (say between 0-2sec) is added, which reduces the odds of other requests bundling together.

I agree the docs should be consistent between the code and its explanation thou.

查看更多
登录 后发表回答