Open olttwa opened 1 year ago
Until Goose supports Throttling, there are 2 hacks that can help achieve that:
:threads
worker config and count of worker instances
:threads
count to 5 and running 4 worker instances, you can achieve a Throttle of max 20 Jobs executing concurrentlycc @rickerbh
Difference between Throttle and Rate-Limit
Both Throttling and Rate-Limiting are designed to limit count of processes at a given time. However, Rate-Limiting rejects the processes exceeding a limit and Throttling queues/pauses processes until current ones have completed.
Rate limiting protects a system by applying a hard limit on its access. Throttling shapes a system by smoothing spikes in traffic.
A background processor shouldn't reject exceeding tasks queued. That's best handled at load-balancer layer. For these reasons, in Goose, we'll use the term Throttling, and
not Rate-Limiting.Why the need to Throttle Jobs?
Often 3rd party APIs will enforce a rate limit. Ergo, the count of Jobs executing at a given time shouldn't exceed this limit.
Patterns of Throttling
As elaborated here, Throttling can be done in 4 ways:
Nuances of Throttling for a background processor
Make note of these things when implementing this feature:
lock_timeout
to ensure crashed processes do not hold a lock foreverwait_timeout
to ensure workers aren't waiting forever to acquire a lock. Upon timing out, User can configure to publish a metric, raise an alert or discard a Job altogetherImplementation Details
This is a complex feature to build. Some ideas after initial investigation: