How to handle shopify admin API calls rate limit in django app

I have a shopify app that built in django app with some celery workers, each worker can send a lot of request to shopify and the types of request have several priority in my app, now I want to build a shared priority queue between workers for each store to handle shopify rate limit and priority:

celery worker 1:

import shopify 
import time

# update more than 1000 of variants 
for variantId in variantIds:
    with shopify_session(store.domain, store.token):
        shopifyVariant = shopify.Variant.find(variantId)
        # here some cahnges on variant

celery worker 2:

import shopify 
import time

# update store info
for store in stores:
    with shopify_session(store.domain, store.token):
        shopInfo = shopify.Shop.current()
        # update shop info in app database

web app:

class TagList(APIView):
    def get(self, request):
            data = ShopifyGraphQl().tags()
        except BaseException as err:
            return JsonResponse({"message": str(err), 'success': False})
        return JsonResponse({"data": data, "success": True})

These are a few examples of api calls in my app that can be called in one second and shopify will response with 429 too many request status code

What is the best architecture for implement queues and handle the shopify rate limit?

Back to Top