惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
有赞技术团队
有赞技术团队
博客园 - 三生石上(FineUI控件)
博客园_首页
博客园 - 【当耐特】
WordPress大学
WordPress大学
月光博客
月光博客
博客园 - 叶小钗
S
SegmentFault 最新的问题
雷峰网
雷峰网
H
Help Net Security
宝玉的分享
宝玉的分享
A
About on SuperTechFans
IT之家
IT之家
J
Java Code Geeks
Hugging Face - Blog
Hugging Face - Blog
D
DataBreaches.Net
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
B
Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Y
Y Combinator Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How I Cut Our Shopify API Usage in Half (Without Losing F...
Muhammad Masad Ashraf · 2026-06-18 · via DEV Community

If you build on Shopify long enough, you hit the wall. Throttled requests. Stalled inventory syncs. Webhook backlogs piling up during a flash sale.

Shopify does not charge you per call in dollars. It charges you in rate limits. Blow through them and your app slows to a crawl. The real cost shows up as engineering time, infrastructure bills, and lost sales from stale data.

Here is what actually moved the needle for us.

First, know what you are paying for

Shopify uses two rate-limiting models depending on the API.

API Model How it works
REST Admin Leaky bucket Fixed requests per second
GraphQL Admin Query cost Points based on complexity
Storefront Query cost Higher limits, complexity-based

The GraphQL model is your friend here. You pay for what you ask for. Ask for less, pay less.

Move from REST to GraphQL

This was our biggest single win. REST makes you stitch together multiple calls to get related data. GraphQL gets it in one.

Fetching an order with its line items, customer, and shipping in REST:

// REST: 4 round trips
const order = await fetch(`/admin/api/2024-01/orders/${id}.json`);
const customer = await fetch(`/admin/api/2024-01/customers/${custId}.json`);
const lineItems = await fetch(`/admin/api/2024-01/orders/${id}/line_items.json`);
const shipping = await fetch(`/admin/api/2024-01/orders/${id}/shipping_address.json`);

The same thing in GraphQL:

# GraphQL: 1 request, only the fields you need
query GetOrder($id: ID!) {
  order(id: $id) {
    name
    customer { firstName lastName email }
    shippingAddress { address1 city zip }
    lineItems(first: 50) {
      edges { node { title quantity } }
    }
  }
}

One request. No over-fetching. Lower cost.

The trap: people migrate to GraphQL and then request every field anyway. Don't. Every field adds to your query cost. If you only need a title and price, do not pull variants, images, and metafields.

Stop polling. Use webhooks.

Polling is the silent budget killer. An app that checks for new orders every few seconds burns thousands of calls a day, and most return nothing new.

Webhooks flip it. Shopify pushes the event the moment it happens.

// Instead of polling every 5 seconds...
app.post('/webhooks/orders/create', verifyWebhook, (req, res) => {
  const order = req.body;
  queue.add('process-order', order); // hand off, respond fast
  res.sendStatus(200);
});

Two things to get right:

  1. Respond fast. Acknowledge with a 200 immediately, then process async. Shopify retries if you are slow.
  2. Expect duplicates. Shopify sometimes sends the same event twice. Use an idempotency key so you do not fire redundant follow-up calls.
async function handleEvent(event) {
  const key = event.id;
  if (await seen(key)) return; // already processed
  await markSeen(key);
  await process(event);
}

Use Bulk Operations for big data sets

Paginating through 50,000 products with standard queries shreds your rate limit. The Bulk Operations API runs the whole thing async and hands you one file.

mutation {
  bulkOperationRunQuery(
    query: """
    { products { edges { node { id title } } } }
    """
  ) {
    bulkOperation { id status }
    userErrors { field message }
  }
}

Approach Calls Rate limit hit
Standard pagination Hundreds to thousands High
Bulk Operations One operation Minimal

Poll the operation status, download the JSONL when done, process locally.

Cache the stuff that does not change

A surprising amount of API traffic fetches data that is stable for hours or days. Product descriptions. Collection structure. Store settings.

Data Cache? Why
Product descriptions Yes Rarely changes
Collection structure Yes Stable
Store settings Yes Infrequent changes
Live inventory Carefully Changes constantly
Order status Short TTL Updates often

Invalidate on the relevant webhook instead of guessing at TTLs.

Handle rate limits like an adult

Even a lean app hits limits sometimes. Read the headers Shopify returns and throttle before you crash.

async function callWithBackoff(fn, retries = 5) {
  for (let i = 0; i < retries; i++) {
    const res = await fn();
    if (res.status !== 429) return res;
    const wait = Math.pow(2, i) * 1000; // exponential backoff
    await new Promise(r => setTimeout(r, wait));
  }
  throw new Error('Rate limited after retries');
}

Centralize this in a middleware layer so every call gets the same treatment. Do not scatter retry logic across your codebase.

The checklist

Tactic Impact Effort
REST to GraphQL High Medium
Request only needed fields High Low
Bulk Operations API High Medium
Cache stable data High Medium
Webhooks over polling Very High Medium
Batch requests Medium Low
Smart rate limiting Medium Medium
Deduplicate calls Medium Low
Async processing Medium High
Monitor usage High Low

Start here

If you do nothing else: replace polling with webhooks, switch to GraphQL with trimmed queries, and cache stable data. Those three alone cut our usage roughly in half.

Then layer in batching, async jobs, and monitoring for the long game.

I wrote a longer version with deeper architecture notes on our blog: Reducing Shopify API Consumption Costs. Happy to answer questions in the comments.

What is the worst API throttle situation you have run into? Drop it below.