Driple Docs

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 THROTTLED in 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

  1. Driple reads Shopify's rate limit headers from the response:
    • REST: X-Shopify-Shop-Api-Call-Limit (e.g., 32/40)
    • GraphQL: extensions.cost.throttleStatus in response body
  2. Updates the internal bucket model for that store
  3. On the next request, predicts whether the bucket has room
  4. 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:

HeaderExampleDescription
X-Driple-Storemy-storeTarget store name
X-Driple-Usage142Your current monthly request count
X-Driple-Limit1000Your 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

  1. Use GraphQL when possible — it's more efficient for complex queries and has a larger bucket
  2. Batch where Shopify allows — fewer requests means less bucket consumption
  3. Spread requests over time — sudden bursts fill the bucket; steady flow stays under the leak rate
  4. Monitor your usage — check X-Driple-Usage headers to track monthly consumption

On this page