Difference between signals and celery

370 views
Skip to first unread message

Robin Lery

unread,
Nov 29, 2013, 1:52:04 PM11/29/13
to django...@googlegroups.com

This may be a lame question, but I am really confused with these two. I know signals are used to do some task when something has happened. But what about celery? In the documentation it says:

Celery is an asynchronous task queue/job queue based on distributed message passing.

Will someone please explain to me of what celery is? What's the difference between these two and when to use them? Will be much appreciated! Thank you.

Nevio Vesic

unread,
Nov 29, 2013, 2:05:30 PM11/29/13
to django...@googlegroups.com
The easiest answer I could give is that django signals are like hooks. Something you wish to preform AFTER or BEFORE some model action. Like you wish to adjust account balance on model save. Than you would use post_save builtin django signal.

Celery is here to handle task in background. Like you wish to process some sort of upload but you want to queue it up against some broker such as rabbitmq, redis, etc. On this way you can optimize stuff and return back user faster response saying "hey, process is backgrounded. Will notify you once it's completed". Than when task finishes you can call callback and let user know as example. Consider this. You have 100000 users uploading video. That video would go into celery task so that you can scale it up properly and distribute against network + make UX appropriate. 

Hope this makes sense.

All best,
Nevio

Carlos Daniel Ruvalcaba Valenzuela

unread,
Nov 29, 2013, 2:11:14 PM11/29/13
to django...@googlegroups.com
Signals are like events, for example, when the ORM has done an update. Celery is more like a Task queue, you define code to execute certain task, load it on celery task server which is running separately from your django process, then when you need to execute it in the background you tell it, which usually means sending a message through a broker such as redis or rabbitmq to the task server, then it gets executed.

Celery is for background tasks, such as processing images, doing updates without blocking the main function return, etc. Also celery task can run in another machine, while signals are executed locally.

Regards,
Carlos Ruvalcaba


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/62298d12-02ab-4d34-b8f7-2c4c9bace561%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Robin Lery

unread,
Nov 30, 2013, 12:35:42 PM11/30/13
to django...@googlegroups.com
Thank all so much for you replies. Just one more question though. Does this means Celery needs a different server?


Avraham Serour

unread,
Nov 30, 2013, 9:12:07 PM11/30/13
to django...@googlegroups.com
No, you can run celery from the same server, the problem is you won't be able to do that on many cheap shared hostings


Robin Lery

unread,
Dec 1, 2013, 5:25:08 AM12/1/13
to django...@googlegroups.com
oh..ok. Thank you so much! :)



Its really great to learn something new.


fchow

unread,
Dec 1, 2013, 12:32:49 PM12/1/13
to django...@googlegroups.com
Question:  If a view saves a model that has a post-save hook, does the view return after the post-save hook has completed? Or does the view return and the hook runs in the background like a celery task would?  
Reply all
Reply to author
Forward
0 new messages