Rate Limiting
How Driple manages Shopify's leaky bucket algorithm.
Shopify's Rate Limits
Shopify uses a leaky bucket algorithm for rate limiting:
REST API
- Bucket size: 40 requests
- Leak rate: 2 requests/second
- When the bucket is full, Shopify returns
429 Too Many Requests
GraphQL API
- Bucket size: 1,000 cost points
- Leak rate: 50 points/second
- When the bucket is full, Shopify returns
THROTTLEDin the response
How Driple Handles This
Driple tracks each store's bucket state using a Durable Object — a stateful, per-store rate limiter running on Cloudflare's edge network.
What happens on each request
- Driple reads Shopify's rate limit headers from the response:
- REST:
X-Shopify-Shop-Api-Call-Limit(e.g.,32/40) - GraphQL:
extensions.cost.throttleStatusin response body
- REST:
- Updates the internal bucket model for that store
- On the next request, predicts whether the bucket has room
- If full, holds the request and retries after the estimated drain time
Per-store isolation
Each Shopify store gets its own Durable Object instance. Rate limit state for store-a never affects store-b, even if both are accessed with the same API key.
Response Headers
Driple adds metadata headers to every proxied response:
| Header | Example | Description |
|---|---|---|
X-Driple-Store | my-store | Target store name |
X-Driple-Usage | 142 | Your current monthly request count |
X-Driple-Limit | 1000 | Your plan's monthly limit |
GraphQL Cost Tracking
For GraphQL requests, Driple parses the extensions.cost field from Shopify's response:
{
"extensions": {
"cost": {
"requestedQueryCost": 12,
"actualQueryCost": 8,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 980,
"restoreRate": 50
}
}
}
}This data is used to track the GraphQL bucket separately from REST, ensuring accurate rate limit predictions for mixed API usage.
Tips for Optimal Performance
- Use GraphQL when possible — it's more efficient for complex queries and has a larger bucket
- Batch where Shopify allows — fewer requests means less bucket consumption
- Spread requests over time — sudden bursts fill the bucket; steady flow stays under the leak rate
- Monitor your usage — check
X-Driple-Usageheaders to track monthly consumption