How to Solve “Shopify: Exceeded 2 Calls per Second for API Client” for Webhooks
Building a headless ecommerce platform with Shopify where multiples services are in play (ex: Shopify, Sanity.io and Algolia and everything is communicating by webhooks can be complex to manage. You want to make sure to respect the service’s rate limits to avoid causing problems downstream.
In this article, we explain how to solve Shopify’s rate limiting issues by using Hookdeck as a queue to throttle the request rates.
Shopify errors caused by rate limiting
After performing a bulk update on a promotion for Black Friday, you may receive the following error:
errors: 'Exceeded 2 calls per second for api client. Reduce request rates to resume uninterrupted service.'
This Shopify error is due to a limitation on API calls, which unfortunately for you impacts your ability to handle events that trigger a lot of webhooks simultaneously. You can read more on Shopify’s documentation.
Introducing a message queue to solve the request rates limit
How can you reduce your request rates to comply with Shopify’s rate limit?
The answer is by introducing a message queue. By decoupling the ingestion and processing of events, you can throttle the delivery of the webhooks to your server. This allows you to manage the throughput and comply with Shopify’s rate limit.
Rate limit webhooks with Hookdeck
With Hookdeck you can manage your throughput. Controlling the speed at which your services receive webhooks will solve the rate limitation.
How to set up Hookdeck’s rate limit
- Create a connection.
Select your Destination and click the three dots to edit.
Check the box titled “Enable Delivery Rate Limiting.”
Enter 1 request per second as your rate limit.
- Shopify’s rate limit is 2 requests per second, but best practice recommends leaving a safety margin to avoid triggering the rate limit.
- Replace your webhook endpoint with Hookdeck’s URL.
That’s it! You are all set up.
In 4 short steps, you successfully managed to introduce a queue to control your request rates. You will now be receiving webhooks at a pace of 1 request per second, and in turn will avoid triggering Shopify’s rate limit.