To use Amazon Marketplace Web Service (Amazon MWS) successfully, you need to understand throttling. Throttling is the process of limiting the number of requests you can submit in a given amount of time. A request can be when you submit an inventory feed or when you make an order report request. Throttling protects the web service from being overwhelmed with requests and ensures all authorized developers have access to the web service.
Amazon MWS uses a variation of the leaky bucket algorithm to meter the web service and implement throttling. The algorithm is based on the analogy where a bucket has a hole in the bottom from which water leaks out at a constant rate. Water can be added to the bucket intermittently, but if too much water is added at once or if water is added at too high an average rate, the water will exceed the capacity of the bucket.
Now to apply this analogy to Amazon MWS. The bucket represents the maximum request quota, which is the maximum number of requests you can make at one time. The hole in the bucket represents the restore rate, which is the amount of time it takes to be able to make new requests. So, if you submit too many requests at once, then the bucket overflows and, in the case of Amazon MWS, throttling occurs. If you fill up the bucket, it takes some time before you can add more water to the bucket since the water leaks from the bucket at a steady rate. So the ability to submit more requests after you have reached the maximum request quota is governed by the restore rate, the time it takes to allow you to make new requests.
The definitions of these three parameters that control Amazon MWS throttling are as follows:
- Request quota - The number of requests that you can submit at one time without throttling. The request quota decreases with each request you submit, and increases at the restore rate.
- Restore rate (also called the recovery rate) - The rate at which your request quota increases over time, up to the maximum request quota.
- Maximum Request quota (also called the burst rate) - The maximum size that the request quota can reach.
While most Amazon MWS operations have a maximum request quota of 10 requests and a restore rate of one new request every minute, a few operations allow you to submit more requests initially (higher maximum request quota) but take longer to allow additional requests (a lower restore rate). For example, the RequestReport operation has a maximum request quota of 15, but the restore rate is one new request every two minutes.
To apply these ideas, consider this example. Say you want to use the SubmitFeed operation to submit 25 inventory update feeds. The SubmitFeed operation has a request quota of 15 and a restore rate of one new request every two minutes. If you submit all 25 feed requests at once, your requests will be throttled after 15 requests. You would then have to resubmit 10 feed requests once the request quota had been restored. Since the restore rate is one request every two minutes, it would take 20 minutes for you to be able to submit the remaining 10 feed requests.
So, instead of submitting all the requests and having to resubmit the requests that didn't get throttled, you could automate your process to submit feed requests incrementally. For example, you could submit 10 feed requests (out of your original 25 feeds), and the request quota would still have five requests left over. You could then wait 10 minutes, and the restore rate would have increased the request quota to 10 (one request ever two minutes for 10 minutes gives you five new requests). You could then submit 10 more feed requests. For the remaining 5 feed requests, you could wait ten more minutes and then submit them. If all things go well, you would have submitted all 25 of your inventory feeds in about 20 minutes.
You should consider automating your requests and have a fallback process where, if throttling occurs because you reached the maximum request quota or the web service experienced high traffic volumes, you could slow down the number of requests you make and you resubmit requests that initially fail.