Skip to content
Mike Perham edited this page Oct 30, 2019 · 16 revisions

Faktory Enterprise allows you to throttle the rate jobs are fetched from a given queue.

Use Cases

  1. Let's say you have a "heavy" image processing job which can overwhelm a server if you process more than 4 at a time. With Faktory, there is no way to limit job dispatch. You could implement distributed locks within your application code but that's a daunting task for many.
  2. You have a bulk queue for low priority work but don't want a huge mass of bulk jobs to take every processing thread available, delaying the fetch of critical jobs. You can limit each worker to only process 5 bulk jobs at a time.

Throttles

Queue throttling is declared within conf.d/throttles.toml:

[throttles]
"image-processing" = { concurrency = 4, timeout = 30 }
another_queue = { worker = 1, timeout = 5 }

You declare the queue name and the set of properties for its associated throttle.

Types

There are two throttling algorithms today:

  1. Concurrency - process up to N jobs concurrently across your entire Faktory worker cluster
  2. Worker - process up to N jobs per worker across your entire Faktory worker cluster

Reminder: a worker is a process which fetches jobs from Faktory. You might have M worker processes per machine.

Timeout

Throttles require locks to be taken during FETCH and released upon ACK or FAIL. If a worker process crashes, any locks held on its behalf are effectively orphaned. To handle this case, all throttles must have a timeout, after which a lock expires.

Web UI

The Faktory Web UI contains a Throttles tab which shows each currently declared throttle and associated runtime usage metrics.

Clone this wiki locally