Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Resque-compatible reactor
Ruby
tree: 67fb0dac3e

Be resque-compatible when resque's namespace not equal to default 're…

…sque'

In this case let the developer set Pace.namespace equal to Resque.namespace
latest commit 67fb0dac3e
aignatev authored committed
Failed to load latest commit information.
bench Tag log lines with [pace] and start the fetch loop more reliably
examples Tag log lines with [pace] and start the fetch loop more reliably
lib Be resque-compatible when resque's namespace not equal to default 're…
spec Forget that [pace] tag business and combine the loggers again
.gitignore Restructure 'instruments'. Add abberant behavior detection instrument.
.rspec
BENCHLOG
Gemfile
LICENSE
README.md Remove load average logging
Rakefile
config.ru Add throughput time tracking
pace.gemspec Remove aberration completely

README.md

Pace - A Resque Reactor

Pace provides a high-throughput way to process Resque jobs inside an EventMachine reactor.

When combined with EM::HttpRequest you can send thousands of requests per second to a remote web service.

Tested under:

  • REE 1.8.7
  • MRI 1.9.2 (best memory performance)

Examples

To have fun with the examples, fire one up and then start enqueuing Resque jobs:

$ rake examples:http

$ irb
> require "rubygems"
> require "resque"
> class MyJob; def self.queue; "normal"; end; end
> Resque.enqueue(MyJob)
> 10.times { |n| Resque.enqueue(MyJob, :n => n) }

In a separate process, start up a worker:

require 'pace'

worker = Pace::Worker.new("normal")
worker.start do |job|
  klass = job["class"]
  options = job["args"].first

  # do work with options
end

Redis

Pace connects to Redis with a URI that's looked up in the following order:

  • Pace.redis_url attr_accessor
  • REDIS_URL environment variable
  • Defaults to 127.0.0.1:6379/0

Throttling

It's very easy to overwhelm a remote service with pace. You can specify the maximum number of jobs to consume per second.

Pace::Worker.new("queue", :jobs_per_second => 100)

Pause/Resume

If you need to pause a worker (for example, during remote service failure):

worker.pause

And when ready:

worker.resume

You can also pause for a set period of time. The worker will resume automatically.

worker.pause(0.5) # 500ms
Something went wrong with that request. Please try again.