Hacker News new | past | comments | ask | show | jobs | submit login
Resque with Redis To Go (redistogo.com)
27 points by waratuman on July 28, 2010 | hide | past | favorite | 19 comments



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


1. Yes

2. Just use the "rake resque:work" task and I recommend using something like upstart that works awesome, but I have also done it with monit and both work great


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.


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


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.


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.


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


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


That should be Redis.connect(:url => 'redis://localhost:6379/1')


I had no idea! And I've been parsing them myself all this time.


Does that work with passwords?


Yes, works as expected.


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


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.


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

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


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


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.


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


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'.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: