Worker Configuration - nsweeting/qpush GitHub Wiki

Before reading this, please consult the Server Configuration section first.

A QPush server can be made up of a number of workers. Each worker runs as a different forked process, and can be unique in their setup. By default, our QPush server will launch a single worker with a default configuration.

There are a number of configuration options available for our workers. Below is a list of all of them with their default values.

# QPush worker config defaults
{
  namespace: 'default',
  priorities: 5,
  queue_threads: 2,
  perform_threads: 2,
  delay_threads: 1 
}

In order to create custom workers, we must build their configurations, and provide them to our server configuration.

To build a worker, we must do the following...

# QPush worker builder
mail_worker = QPush::Server.build_worker do |worker|
  worker.namespace = 'mail'
  worker.priorities = 10
  worker.queue_threads = 5
  # etc...
  # ...
  # ...
end

Then, during our server configuration setup, we can provide our mail_worker with an array.

# QPush server configuration
QPush::Server.configure do |config|
  # Simply an array of workers
  config.workers = [ mail_worker ]
  # etc...
  # ...
  # ...
end

Below is a list of the worker config options with brief explanations of their meanings:

namespace

The namespace is the key that our worker will use for all interactions with redis. Namespaces provide the ability to use the same QPush server for multiple projects and services.

priorities

Each job can be provided a priority. We can configure how many levels of priority our worker has here.

queue_threads

All jobs are initially sent to the 'queue' action. The 'queue' action will then sort them based on priority, and send them to their respective 'perform' action. We can edit the number of threads that are provided for our 'queue' action here. This should most likely match the number of perform_threads.

perform_threads

The 'perform' action is what will actually execute our job. We can edit the number of threads that are provided for our 'perform' action here. This should most likely match the number of queue_threads.

delay_threads

The 'delay' action is what takes any cron jobs, delayed jobs, or failed jobs, and sends them back to the 'perform' action once their time has come. We can edit the number of threads that are provided to our 'delay' action here. This is usually less than the number of 'perform' and 'queue' threads.