Open Salakar opened 8 years ago
+1
I think rate-limiting for queues should be built-in disque
directly - so regardless of the number of messages being put by producers, the system itself throttles the max number of messages to consumers in a given time period.
Firstly, disque is great! \o/
Secondly are there any plans to implement queue throttling or some variation of it. I'll explain:
For example: X public web API has a limit of 100 http requests per 10 secs, and I use a single job to consume one of these requests.
Now normally in Redis I would achieve this using a mix of
EXPIRE
andINCR
- so I set the ttl to 10 seconds and INCR on each successful job run.Here's a rough redis lua implementation of the above, to demonstrate:
On a single queue job consumer this wouldn't be a problem really, could just keep counts locally, but I currently run a farm of queue workers (using redis), so would be no easy way to maintain the counts across all the servers without using redis alongside disque.
On
ADDJOB
I see there isDELAY
andMAXLEN
which is a good start though :+1:Possible solutions:
Or any other suggestions? Not sure if I'm the only one with this use case though? :hear_no_evil:
Thanks, Mike