Open danielparas opened 8 years ago
The observe pattern works better it you care about the latency between when a job becomes ready and when a worker requests the job. If minutes are fine, then there's no need to observe, but if seconds count, you don't want to poll at the frequency that would require.
Basically, as your tolerance for latency decreases, there's some crossover point where observing becomes more efficient than polling. Also, if you expect your workers to be at or near capacity, there is no need to observe, because each worker will ask for more work immediately after it completes each job.
If you only care about throughput for at capacity workers, it is better to poll, and use the prefetch
and/or payload
options to minimize the round-trip delay during which your worker would otherwise be idle.
@vsivsi thanks for the very clear answer! :)
Hi @vsivsi,
From the examples available it seems there are two ways for a worker to "check for work" - either by polling or by setting up observe on the job collection.
Are there any particular performance advantages between one and the other? As observe way seems cleaner however I have a hunch it's more resource / data-heavy since you need to subscribe to the collection.
Thanks, Daniel