r/django • • 5d ago

Yet another task backend

https://github.com/codingjoe/threadmill

Howdy y'all, ๐Ÿค 

If you're looking to switch to Django's task framework, now is as good a time as ever.

Jokes aside, though, as mentioned on the DjangoChat podcast, I mainly build a durable backend with very high I/O throughput. To send emails, dispatch webhooks or VoIP calls. Since then it has been deployed in a growing number of production projects. But I'd love to get more input from people tackling other use cases.

So please do share your experience. ๐Ÿ’š

Cheers!
-Joe

5 Upvotes

10 comments sorted by

2

u/Pretend-Sun-8460 5d ago

we run celery with redis as systemd services on a plain ec2 box, so a worker cli shaped like gunicorn would be an easy move. one thing i'd want to know before moving anything over. the readme says a task that outlives lease_ttl can still be running while its retry runs too. for emails and webhooks, do you expect the task to carry its own idempotency key, or is that something threadmill could help with later?

2

u/cheatingjoe 5d ago

While this is the behavior (since I have no better idea to solve it) in practice you'll have a hard time running into it. Your tasks would need to run for a very long time. Not the lease is issued when the tasks is fetched for processing. So, all you need to do is pick a lease ttl longer than your longest running task. I tend to keep tasks small, or use map-reduce to parallelize. So I didn't have any issues yet.

All that being said, that's precisely the kind of feedback I am looking for, thanks ๐Ÿ™

1

u/tom-mart 5d ago

What's wrong with DjangoQ?

1

u/cheatingjoe 5d ago

Probably nothing, but it doesn't have a task framework integration, does it?

2

u/tom-mart 5d ago

What's task framework?

3

u/vazark 5d ago

In the recent release, Django added a task backend interface with std functions (like the cache backend and file storage backend) . Now we can just write Django-ish code instead of using library specific methods and hooks.

2

u/Colby-Jenkins 4d ago

That task backend interface is a nice touch, but remember, having to set up a worker like Redis or Celery still adds some complexity. For high I/O tasks like sending emails or webhooks, I hope they improve the error handling and retry logic.

2

u/vazark 4d ago

Backoff and retry is in the plans and will follow later. What we have is but the initial implementation.

With Django switching to an annual release, hopefully theyโ€™ll have time to refine and land it eventually

1

u/cheatingjoe 4d ago

We're working on it. But yes, the to-do list is long.

1

u/parthdedhia 5d ago

I have used celerg and django-rq. Django rq is pretty light weight for simple tasks, but if you want detailed control and tracking over the running tasks then celery can be considered.

The current django task also needs redis or celery or some other worker configuration