January 24, 2020
Resque is amazing but sometimes it get a little backed up. Here is how you can easily access resque details inside or ruby.
To get an overview of resque run the following:
require 'resque'
Resque.info
Response:
{
:pending=>100,
:processed=>200,
:queues=>3,
:workers=>4,
:working=>2,
:failed=>25,
:servers=>["redis://192.168.1.10:6379/0"],
:environment=>"production"
}
If you want to only know how many pending jobs are waiting to be processed, run:
Note this will work with all of the keys return from above(pending
, processed
, queues
, workers
, working
, failed
, servers
, environment
)
require 'resque'
Resque.info[:pending]
Response:
100
Resque.info
is very useful but it will not let you know where to problem is located.
You will have to use queues to determine which is backed up
Here is how to get a list of queues:
require 'resque'
Resque.queues
Response:
["example1", "example2", "example3"]
Once you know which queue you want to investage, you can get the size of it:
require 'resque'
Resque.size('example1')
Response:
100
Now you know how to check on the size of a queue, you can send a text message using twilio or auto scale using heroku platform-api formation.