Live data from Hacker News

Celery in production: Three more years of fixing bugs

ayushshanker.com

21–30 of 63 posts

Re: Celery in production: Three more years of fixing bugs

#21
post #3

I ran Celery in many projects in production over the past 10 years; I would not recommend it. It is mostly a constant fight even though it is the first thing most people grab when they have a Django stack.

I totally agree, I would not recommend using Celery. The last time I used Celery was in 2019 and it was a mess. The memory leak issue is still open https://github.com/celery/celery/issues/4843 to this day.

Re: Celery in production: Three more years of fixing bugs

#22
I've been using Celery on a small scale for years now and generally haven't had any serious issues except 1: reliably cancelling scheduled (future) tasks. Even using persistent revokes has been unreliable in my experience: https://docs.celeryproject.org/en/latest/userguide/workers.h...

Fwiw though, the alternatives (huey, dramatiq, rq) don't even seem to offer this feature.

Re: Celery in production: Three more years of fixing bugs

#23
post #13

RQ [0] (Python-based with Redis backend) is another option; works great. [0] https://python-rq.org/

I love RQ. Nothing but good experiences using it several times over the past ~6 years.

However if you are doin mission critical work in your queue that cannot be replayed Celery is still the best python flavored option IMO

Re: Celery in production: Three more years of fixing bugs

#24
post #13

RQ [0] (Python-based with Redis backend) is another option; works great. [0] https://python-rq.org/

I've had mixed experiences with RQ. It works great most of the time, but I've observed that you can get into weird states if you OOM your system or otherwise throw curveballs at it. Overall I think Python makes it easy enough to handroll a queue management system that I would generally recommend that over RQ.

Re: Celery in production: Three more years of fixing bugs

#25
I’ve been using Celery and it has been working okay for our needs but it is not very friendly to make changes depending on how you write tasks. I feel okay when a task is a wrapper around some other functions that you can just run and test with any tools you’d like but we have some tasks that go all in by binding all kids of data and functionality to the task that isn’t guaranteed to be there if you just launch a task with .delay or similar so you can’t just spin up a REPL or debugger and call the function and have it work.

Re: Celery in production: Three more years of fixing bugs

#27

Can any explain why we need task queue? It is unique to Python because of it lack of real threading?

Even if there were real threading, it has features that make it convenient for scheduling tasks, chaining them in different ways and so on. You could write your own thing of course. But also it operates over different processes and those processes don't even necessarily have to be on the same machine.

Re: Celery in production: Three more years of fixing bugs

#28
i am using it for four months. its configuration is really complicated and many default values do not make sense. for instance when you are using solo there should be a default hard task timeout smaller than effective heartbeat value otherwise it will fail and retry the same task forever.

Re: Celery in production: Three more years of fixing bugs

#29

Can any explain why we need task queue? It is unique to Python because of it lack of real threading?

Task queue pattern is not unique to python.

Consider where you see physical queues of people in real world: e.g. people lining up to be served at supermarket, to board aircraft, to enter a concert. The purpose of the queue is an orderly way to manage situations where there is more demand for a service than can be immediately processed. If the system tries to serve all the demand simultaneously, perhaps that leads to chaos and no one getting served.

Similar situations happen in computer systems, in some of those cases queues can be used to manage load.

E.g. When you make a purchase to order something online, there is a good chance there is a task queue or something very similar as part of the machinery helping that to happen. When you click "purchase" your order or request is persisted in some queue or DB, before any attempt is made to fulfill it. The UI can give you immediate feedback telling you that your order was received, here's your order ID, sit back and relax, we'll send you an update. When some machine (or person) is available with free capacity, and no higher priority orders to process, they will grab your order and start processing it.

Some worker queue implementations offer additional benefits in terms of increasing robustness of system. e.g. if worker node A begins processing task T, then worker node A explodes before T is complete, the task T may be returned to the queue after some timeout, and surviving worker B may be able to grab T and process it successfully. This can be very valuable in situations where you want to guarantee that task T is done correctly and not half-done or forgotten -- e.g. processing and provisioning customer orders. This gets considerably more challenging to implement correctly if task T involves performing side effects and modifying the state of the real world (transferring money, dispatching vehicles) and the failure occurs after some but not all of the side effects have already happened.

Queues introduce new failure modes: if something stops workers from processing tasks, and queue gets longer and longer, how do you find out and fix it? Queue needs to be stored somewhere, there is some max capacity, what happens when that is exceeded -- does the queue give up and drop all the tasks on the floor, or explode, or so on.

Post reply on HN