Ask HN: What's a good, open source, distributed, worker queue?
This will be running on a small cluster of machines. These machines will already be running CouchDB, and so I have map/reduce setup to process the data as it comes into the database. This queue is to schedule other tasks, such as crawling the web, going to third party APIs and pulling down some data, etc.
I'd like the queue to be transactional so that if a worker dies before finishing the task, the task remains on the queue and another worker will pick it up. It is ok with me if I have to be responsible to make sure the tasks are idempotent.
I'd like the queue to be replicated in the cluster so that if one node happens to go down, we don't lose a chunk of the tasks from the queue. I'd rather the occasional task be done twice than any task ever be forgotten.
Each node and each process will be both adding things to the queue and taking things off to process.
If these things come setup to assume a specific language for the worker processes, then javascript or python are the preferred ones.
Would prefer it to be relatively lightweight, and require nearly zero administration.
Part of the reason I'm asking is that I think I might be using the wrong terminology to try and find this. I found DISCO (http://discoproject.org/). I could make DISCO do what I want probably, but I have Map and Reduce covered in couchDB already. I need "go ftp this zip file, uncompress it, and then run it thru this python script" kinds of tasks to be scheduled.
Thanks in advance for advice!
25 comments
[ 5.5 ms ] story [ 70.3 ms ] threadIt's stable, fast and has API libraries for most languages which can create clients and workers. You may have to do some configuration/customisation to get it to do exactly what you're after but it's a great place to start.
http://gearman.org/
It does handle load balancing in a nice way.
1) You can use a local SQLite file. Fast and fine for jobs you don't mind losing once if your entire box goes down. (Cache busting comes to mind)
2) You can use MySQL. If a job server dies, you can restart it and point it at the same MySQL instance. If a job server dies and the entire MACHINE is down, you can spin up another gearmand instance on another machine and point it at the right place.
If you are submitting "foregrounded" tasks, meaning your client requires a response, Gearman's way of handling failure is pretty simple. When gearmand (the server) dies, the client will see you lost a socket connection. It is then up to the client to determine what to do in that failure scenario. It sounds like in your case, you just want to resubmit it. This should be pretty easy to do.
As an FYI, I'm currently the maintainer of the python-gearman 2.x series API. We (derwiki and I) have been using Gearman in production for the past few months now and it's worked out pretty well for us. Implementation's a snap and running the daemon's pretty trivial.
I've not used it so I'm not entirely sure it'll cover your needs, but I keep hearing good things about it.
Looking into it now. Seems it gives me choices for the backend including RabbitMQ and Redis.
edit: This is in Ruby though.
I've now got multiple choices that seem like they can do the job and just need to decide which one is the best fit.
Thanks
We use DJ for jobs that MUST succeed (e.g. autopost) whereas we use Resque for more frequent but less essential jobs.
If you need support for "job prerequisites", (one job to not start before other jobs have finished successfully), we'll be adding that to our fork from collectiveidea soon. The DJ codebase is pretty nice to look at, too. Note also that there are capistrano dj deployment recipes in the git source.
It's priced so cheaply as to be essentially free, though you'll need to give it a credit card so that it can bill you eleven cents a month or whatever.
http://aws.amazon.com/sqs/
I've been using it for a few years now with good success.
I think another potential downside is that the messages get purged after 14 days.
It is distributed, battle tested and has a small simple API. You can build some good distributed data structures(like queues for example) on top of it with minimal work.
For python examples - http://www.cloudera.com/blog/2009/05/building-a-distributed-...
and http://github.com/twitter/twitcher
- Persistent queues
- Clustering - Topic based queues for an extremely flexible syndication model
- Transactional (acknowledged) queues
- Lots of adapters in different languages
- Fast, handles thousands of messages/sec
It's written in erlang so if you're already running CouchDB then you can maximise any language specific knowledge.
Replicated queues are tricky to set up with any queuing system, but if you're looking to a) not lose any messages and b) have high availability then the simplest thing is just to run 2 independent but identically configured queues in parallel which are configured to be persistent and configure the workers to pull jobs of each queue in turn. If one of them goes down you can restart it and recover the lost jobs whilst the other queue continues.
Alternatively you can write to both queues and deduplicate the messages when you pull them off. Beetle ( http://xing.github.com/beetle/ ) takes this approach and uses Redis to manage the deduplication.
Check out the http://q4m.31tools.com/, http://www.slideshare.net/kazuho/q4m-a-highperformance-messa...
It is written in scala for use at Twitter. It is super simple to getting running and is so far robust. We are using it to pass JSON messages around our system for background processing tasks.