I am working a lot with the Shopify API - which imposes rate limits on usage per shop (user in my system).
I have been trying different ways to manage the rate limit to avoid hitting errors and wondering if anyone had any opinions?
So far the safest way is for me to execute api calls sequentially for each user and monitor the rate limit, pausing if I need to. However, this means a queue worker could be held up waiting to complete a large amount of calls for a single user.
I have been experimenting with the Redis throttle feature to rate limit my queue jobs based on the user - this works very well, but because it releases the job if it is unable to get a lock the job is basically released to the bottom of the queue and could be some time before it gets tried again at which point it might fail again anyway - I'd like the job which has been rate limited to have priority somehow when the lock is freed - has anyone managed to create this sort of architecture?
Any ideas would be very helpful, thanks in advance!