5 ms·
Resque with Redis To Go
- aaronblohowiak 16y agoUse the best tool for the job. For queueing, that's probably 0mq or ActiveMQ or RabbitMQ, depending on your needs.
- waratuman 16y agoThese 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 16y agoThey are message queues. What makes introspection a critical requirement?
- waratuman 16y agoFor 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'.
- klochner 16y agoGreat 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.
- rramsden 16y agoIf you're looking for something a little simpler to process jobs using mongodb check out mongo_queue http://github.com/skiz/mongo_queue http://github.com/skiz/mongo_queue
- callmeed 16y agoLooks 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
- malomalo 16y ago1. 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
- kgo 16y ago1. 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.
- delano 16y agoGreat 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 16y agoRedis also manages URLs directly: Redis.connect('redis://localhost:6379/1') works as expected.
- waratuman 16y agoI had no idea! And I've been parsing them myself all this time.
- malomalo 16y agoDoes that work with passwords?
- soveran 16y agoYes, works as expected.
- darkhelmetlive 16y agoThat should be Redis.connect(:url => 'redis://localhost:6379/1')
- soveran 16y agoRedis understands URLs, so you can send it directly via connect: Resque.redis = Redis.connect(ENV["REDISTOGO_URL"])
- jdeeden 16y agoYou 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.