A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello,
I cant wrap my head around the documentation regarding rate limitation for GraphQL api found here https://shopify.dev/api/admin-graphql#rate_limits
The part I dont understand is that it says "The API supports a maximum of 1000 cost points per app per store per minute.". But then quota replenishes at a rate of 50 cost points per second. If I only look how the quota replenishes I would be able to use more than 1000 points per minute (50 points*60 seconds=3000 points).
Am I understanding it correctly that I have to keep track of the 1000 points/minute myself or is that reflected in the extension response somewhere, as I can not find any information regarding that limit (1000 points/minute) from the examples?
Please help me understand the logic behind this.
Hi @mannenson
I've not tested this with the graphQL API but have with the old rest limits and I'm assuming that they work in the same way.
The leaky bucket algorithm (https://en.wikipedia.org/wiki/Leaky_bucket) explains this quite well.
You are essentially filling the bucket with calls. In this case you have 1000 points worth of calls that can be made over 60 seconds. Let's say you make 1000 points worth of calls at second 0, at second 1 you'll have 950 points in the bucket, at second 2 you'll have 900 etc... You'll be able to make more calls if the bucket already has calls in it, but only up to the 1000 point limit. So don't think of the bucket as having 3000 points worth of calls, it only has 1000 points worth, but they drain at 3000 points/min.
You can keep track of this in your own app, or you could try to design something that will never exceed the limit (good luck!). In the past I've just set up timers and globals to keep track of this and I've not had any failures using that method.
Cheers,
Elliott
Thanks for the explanation. I think I understand the leaky bucket algo now. However i still think that Shopifys explanation is contradicting.
When they say that 1000 points per minute is max but it replenishes at 50/second it doesnt add up to me. As you wrote ”it only has 1000 points worth, but they drain at 3000 points/min.” wouldnt that exceed 1000 points per minute limit?
Maybe there is something vital im missing here 😞
You don't have 3000 points / minute though. That would imply that you can make 3000 points in a single call, which you can't do.
You have a 1000 point limit at any given time, but you can make up to 3000 points of call / minute if you divide them over time.
What you write makes sence with a bucket size of 1000 and replenish rate of 50. But Shopify on the link in my original post writes: "The API supports a maximum of 1000 cost points per app per store per minute.". I dont understand how this limit relates bucket size and replenish rate as it contradicts each other.
Is my cost point per minute 1000 or 3000?