This code autoscales a Resque worker pool running on Render based on the number of unfinished jobs
(enqueued jobs + in-progress jobs).
It computes this metric directly from the redis instance being used by Resque.
It assumes that the Resque workers are running as a multi-instance Render background worker.
The autoscaler can itself run as a single-instance Render background worker.
It takes the following config options as environment variables:
WORKER_SERVICE_ID (required): Service ID for the Resque worker pool running as a Render background worker.
INTERVAL (optional, defaults to 1s): Determines how often we sample the custom metric. After each measurement we wait for this amount of time before measuring again.
NUM_SAMPLES (optional, defaults to 1): How many samples to average over when calculating the desired number of worker instances.
SCALE_UP_DELAY (optional, defauls to 1m): Minimum time to wait after the last scaling event before scaling up.
SCALE_DOWN_DELAY (optional, defaults to 10m): Minimum time to wait after the last scaling event before scaling down.