Google的有关指数补偿的文档是否不一致? [英] Is Google's documentation on exponential backoff inconsistent?

查看:70
本文介绍了Google的有关指数补偿的文档是否不一致?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在线Google云端硬盘文档中描述指数补偿的示例代码似乎与同一页面。该代码从0到4循环运行(因此最多尝试5次请求),但是代码之前的文本编号列表描述了最多进行6次API请求(在步骤1中进行1次正常尝试,然后在5次中重试)。步骤3.,5、7、9和11)。在此处

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

推荐答案

关于算法的重要部分是它的指数性,而不是尝试次数。

给您多少次尝试,只要您每次迭代的等待时间加倍即可。

您可以找到其他Google和非Google示例,其中添加了较小的随机延迟(例如0到2秒之间),


我同意文档应与代码及其解释保持一致。

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.

这篇关于Google的有关指数补偿的文档是否不一致?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆