Celery - Distributed Task Queue
github.com
github.com
Are there options for this? Akin to an sqlite for tasks, in python?
Despite all that, I usually just find myself running celery. I'll usually have a redis instance going anyways that I can use as a sub-optimal queue, and if it's a small enough site, I'll run a single worker instance on the same machine as the host.
The problem now becomes transferring data to that worker, which is where celery comes into play.
Python threads cannot be used for CPU heavy loads because they all run on a single core.[0][1]
[0]: CPython threads are kernel threads but effectively act like user threads. All threads run within a single VM and thus restricted to a single core.
[1]: Jython does not have the same limitation.
Multiprocessing makes it pretty straight-forward to manage inter-process communication with queues, but you'd have to write all the other stuff task queues handle for you, such as error management.
[1] http://uwsgi-docs.readthedocs.org/en/latest/Queue.html [2] http://uwsgi-docs.readthedocs.org/en/latest/Mules.html
This can be a far better alternative to externally run cron scripts for long-running applications (e.g. web applications), as it is platform neutral and can directly access your application’s variables and functions.
The only downside is that, like Celery, RQ forks for every task. This can feel a bit heavy for some of our simpler tasks, although it hasn't proven to be an issue yet.
You can use redis as a backend for celery (which you should be using already for caching, probably), and AFAIK you can use a database as a backend too (although I haven't tried it).
That means that celery is exactly one dependency.
You need some kind of persistent store so that it can recover the task queue from hardware failure. But it can probably use the backend you already have.
What I want is the ability add a task with a priority and metadata, and be able to pop those tasks in O(1) time.
Celery has a lot more control and features that you probably don't need.
There is definitely an overhead to get it going. Using redis as your messaging backend reduces this cost somewhat.. rabbitmq is overkill for most of the cases we've used celery.
Have a look at rq if you're looking for something more lightweight: https://github.com/nvie/rq
Anyone know the real reasons behind that statement?
Of course, this doesn't matter if you're running a small site with low traffic. I wouldn't get too caught up in worrying about broker selection unless you're cranking out a lot of jobs, or have special needs.
Perhaps they should break the brokers down into those two groups.
I seem to recall Redis having a pubsub style interface, which makes it much more push but still is a bit cloudy in my mind.
Thanks for the reply!
I haven't used Gearman personally, but if I had a polyglot project, I'd give it a serious look.