

Resque with Redis To Go - waratuman
http://blog.redistogo.com/2010/07/26/resque-with-redis-to-go/

======
callmeed
Looks pretty awesome. I'd love to use it on an upcoming project.

2 questions:

1\. Do jobs (in app/jobs/whatever.rb) have full access to your Rails models
(so you can pass it an ID and it can do whatever)?

2\. How does the rake task/worker best work in a production environment (other
than Heroku)? Use monit to keep the worker(s) up?

Thanks

~~~
kgo
1\. It's optional.

"rake environment resque:work" will give you access to the whole rails
environment, so you can write normal rails code. But it of course uses a bunch
of memory.

If you're doing something quick and dirty and don't need the rails model
(sending out a password email or whatever), you can just run "rake
resque:work" and avoid the overhead of the whole rails environment.

~~~
waratuman
The line `task "resque:setup" => :environment` in the rake file does the same
thing. That way it will load the env on Heroku.

~~~
kgo
Yes, of course, I guess I was just trying to say that rails is optional, not
required, and that resque is a pretty nice general purpose job queue.

------
klochner
Great idea - I don't believe there was previously a Redis solution for Heroku
users.

I'm not seeing an obvious benefit for people self-hosting though.

------
delano
Great stuff!

Also, for the extremely anal, uri-redis is aware of the database number:

    
    
        require 'uri-redis'
        conf = URI.parse 'redis://localhost:6379/1'
        conf.host      # => localhost
        conf.port      # => 6379
        conf.db        # => 1

~~~
soveran
Redis also manages URLs directly: Redis.connect('redis://localhost:6379/1')
works as expected.

~~~
malomalo
Does that work with passwords?

~~~
soveran
Yes, works as expected.

------
jdeeden
You can make the resque-web app available under /resque simply by:

require 'resque'

MyApp::Application.routes.draw do

    
    
      mount Resque::Server.new, :at => "/resque"
    

end

Requires Rails 3.

------
rramsden
If you're looking for something a little simpler to process jobs using mongodb
check out mongo_queue <http://github.com/skiz/mongo_queue>

------
soveran
Redis understands URLs, so you can send it directly via connect:

    
    
        Resque.redis = Redis.connect(ENV["REDISTOGO_URL"])

------
aaronblohowiak
Use the best tool for the job. For queueing, that's probably 0mq or ActiveMQ
or RabbitMQ, depending on your needs.

~~~
waratuman
These are primarily messaging systems. I've considered using them before.
Nothing, however, has come close to letting me do introspection like Resque
does, and the best part is that I don't need to do any work to get it.

~~~
aaronblohowiak
They are message queues. What makes introspection a critical requirement?

~~~
waratuman
For me it was because I was unable to access the log files if a job failed
since I was on Heroku. Also it gives me a general idea of how the system
behaves; in one second I can tell if the system is normal. I can tell if I
need to bump some workers up for a certain queue. Basically it saves me from
creating my own 'dashboard'.

