Hi,
I am having some issues with X-RateLimit-Remaining. It seems to be very erratic and is dropping randomly. I am doing a cooldown code which reacts to X-RateLimit-Remaining, the closer I am to zero to more cooldown I do. However, somtimes after a few calls I get the value drop below 15, one call later it goes below 10. I am doing a lot of cooldowns which, when added together give me way less than 40calls in 10sec window, so thats a problem.
I am trying to get an understanding of how rate limiter works, is it tied to the size of the result as well?
Thanks, /m
找不到电影或剧集?登录并创建它吧。
mmitrovic@gmail.com 的回复
于 2018 年 11 月 07 日 4:05上午
For example:
you see, the call count does not correspond to values I get from headers back. I am definitely the only one on this IP. Could this be an issue with your IP address grouping in limit calculation?
mmitrovic@gmail.com 的回复
于 2018 年 11 月 08 日 7:12上午
Any news on this? This broken limiter is a real issue , with faulty remaining rates it took us 2h to process something it would take 30mins with 40calls per 10sec.
Travis Bell 的回复
于 2018 年 11 月 08 日 7:27下午
Hi,
I'm not sure if I understand the issue you're describing 100%. So let's walk through this. When you make your first request, you'll get these 3 headers back:
The
X-RateLimit-Reset
header is saying when the current bucket will expire, and reset your count to 40. This is a rolling 10 second window that starts at the time you make the first request. So by looking at both of those headers you should know when to pause and resume your requests. Here's some mock Ruby code I threw together, and the subsequent run I let go for a minute or so. I am adding a 1 second buffer to my sleep since even though my computer and the server should be in sync, they could be slightly off.Does that help clear it up at all?
mmitrovic@gmail.com 的回复
于 2018 年 11 月 09 日 7:15上午
Ah, ok, this acatually explains a lot. let me work this into y solution and see how it works now. I guess I was under the impression that the 10sec window was a rolling one.
mmitrovic@gmail.com 的回复
于 2018 年 11 月 09 日 7:56上午
Ok, works now! Thanks.
Travis Bell 的回复
于 2018 年 11 月 09 日 10:01上午
Perfect, happy to help!