Closed ynaft closed 1 year ago
I reproduced it with a script: https://gist.github.com/ynaft/83aafef6c66009a610f1bc670b171857
The numbers totally confuse me, as the original question.
Perhaps the documentation refers to a "guaranteed stable rate", so the smart thing would be to:
x2. There seems to be some undocumented logic about the throttling algorithm.
It appears that there is some per-item throttling in place, instead of the per-request throttling alluded to in the docs and hinted at here, at least on the /products/pricing/v0/competitivePrice
endpoint.
If this is true, with the upcoming SP API throttling reductions, we have big worries about our use case being slowly deprecated (related 1 2).
We have users trying to analyze ~100k products at a time. Coming from MWS with a 10 items / sec limitation to the planned change in the SP API of 1 item every 2 seconds will increase the minimum run time to analyze 100k products for our users by 20x (jumping from ~2.7 hours to a whopping 54 hours).
The correlation between asins per call and the number of throttling errors is quite apparent.
If the API was really throttling on a per-request basis (as documented), we should see near zero throttling errors for all asin counts. But that is clearly not the case.
Tests done on the /products/pricing/v0/competitivePrice
endpoint. To test, I essentially looped through 1,000 iterations with a different number of ASINs in each call, calling the endpoint in a separate thread.
for i := 0; i < 1000; i++ {
go callGetCompetitivePricing(asins)
time.Sleep(100 * time.Millisecond)
}
Looks like I commented prematurely and naively, as we're now experiencing the same inverse relationship between the number of asins per call vs error rate, so something is definitely off. It doesn't seem Amazon engineers know what they're doing either or has either of you got any meaningful response out of them?
This is a very old issue that is probably not getting as much attention as it deserves. We encourage you to check if this is still an issue after the latest release and if you find that this is still a problem, please feel free to open a new issue and make a reference to this one.
closed for inactivity
I'm trying to figure out the "token bucket algorithm" for rate limiting how many API requests a user can make. so I have a burst of 10, which means the bucket has initially 10 tokens, so I can make 10 requests, then I have a restore rate of 45 seconds, which means it takes 45 seconds for a token to be deposited in to the bucket, so I should be able to make another one request.
Now based on what I understand, if I empty out all 10 at once, then I'll have to wait 45 seconds to get one token back in, and then at 90 seconds I'll have 2 tokens back in and at 135 I'll have 3 and so on until the bucket is filled with 10 tokens. but when I'm actually testing it with the Selling Partner API, I get a total different picture.
My test with a stopwatch showed, that when I finished emptying the whole bucket (10 requests) which took 00:00:11.50 I was able to get a new token (execute a successful request) at 00:00:48.14 which is less than 45 seconds from the 'last' request, so I figured maybe I have to count from the 'first' request, but then at the later requests I saw a totally mixed up pattern how they come in, the next one was in at 26 seconds than one at 4 seconds and so on with different time laps, see screenshot.
Can anyone explain?