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.
当前每次都会去随机获取key有好处也有坏处。
好处是,每个人每次请求都可能有机会碰到可用的key,坏处是每次请求都可能需要很多次请求才能找到可用的key。
因此我的想法是,如果好不容易找到了一个可用的key,应该优先使用这个可用的key,这样至少可以保证最近的10次或者20次或者50次请求可以成功,而不是每次都可能不一定成功,这个可用的key不能用后再去碰运气按理来说,效果不会比当前的效果差,毕竟有10个人成功后,第11个人才失败的。
我唯一能想到的可能不如之前的效果的场景是极端场景,大并发访问,一秒就把这个key的rpm达到了导致它不可用了,比如一秒有100个人访问,rpm是50,那么这种情况下,他们中有50人可以从成功,另外50人中的部分人,可能会额外多了一次key的试错,但是理论上应该也只是少量人会多一次key试错才对。
我没有仔细去看rpm的值是多少,上面数字都只是举例子说明问题用的,如果数字不对,望包涵。