You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4680,14 +4680,14 @@ <h2>Why are task queues necessary?</h2>
4680
4680
</li>
4681
4681
</ul>
4682
4682
<h2>Task queue projects</h2>
4683
-
<p>The defacto standard Python task queue is Celery. The other task queue
4684
-
projects that arise tend to come from the perspective that Celery is overly
4685
-
complicated for simple use cases. My recommendation is to put the effort into
4686
-
Celery's reasonable learning curve as it is worth the time it takes to
4687
-
understand how to use the project.</p>
4683
+
<p>The defacto standard Python task queue is <a href="/celery.html">Celery</a>. The other
4684
+
task queue projects that arise tend to come from the perspective that
4685
+
Celery is overly complicated for simple use cases. My recommendation is to
4686
+
put the effort into Celery's reasonable learning curve as it is worth the
4687
+
time it takes to understand how to use the project.</p>
4688
4688
<ul>
4689
4689
<li>
4690
-
<p>The <a href="http://www.celeryproject.org/">Celery</a> distributed task queue is the
4690
+
<p>The <a href="/celery.html">Celery</a> distributed task queue is the
4691
4691
most commonly used Python library for handling asynchronous tasks and
4692
4692
scheduling.</p>
4693
4693
</li>
@@ -4755,11 +4755,6 @@ <h2>Open source examples that use task queues</h2>
4755
4755
<h2>Task queue resources</h2>
4756
4756
<ul>
4757
4757
<li>
4758
-
<p><a href="http://www.caktusgroup.com/blog/2014/06/23/scheduling-tasks-celery/">Getting Started Scheduling Tasks with Celery</a>
4759
-
is a detailed walkthrough for setting up Celery with Django (although
4760
-
Celery can also be used without a problem with other frameworks).</p>
4761
-
</li>
4762
-
<li>
4763
4758
<p><a href="https://www.twilio.com/blog/2015/11/international-space-station-notifications-with-python-redis-queue-and-twilio-copilot.html">International Space Station notifications with Python and Redis Queue (RQ)</a>
4764
4759
shows how to combine the RQ task queue library with Flask to send
4765
4760
text message notifications every time a condition is met - in this blog
is a presentation for what task queues are and why they are needed. </p>
4782
4777
</li>
4783
4778
<li>
4779
+
<p><a href="http://blog.thecodepath.com/2012/11/15/asynchronous-processing-in-web-applications-part-1-a-database-is-not-a-queue/">Asynchronous Processing in Web Applications Part One</a>
4780
+
and <a href="http://blog.thecodepath.com/2013/01/06/asynchronous-processing-in-web-applications-part-2-developers-need-to-understand-message-queues/">Part Two</a>
4781
+
are great reads for understanding the difference between a task queue and
4782
+
why you shouldn't use your database as one.</p>
4783
+
</li>
4784
+
<li>
4784
4785
<p>Flask by Example <a href="https://realpython.com/blog/python/flask-by-example-implementing-a-redis-task-queue/">Implementing a Redis Task Queue</a>
4785
4786
provides a detailed walkthrough of setting up workers to use RQ with
4786
4787
Redis.</p>
4787
4788
</li>
4788
4789
<li>
4789
-
<p><a href="https://www.digitalocean.com/community/articles/how-to-use-celery-with-rabbitmq-to-queue-tasks-on-an-ubuntu-vps">How to use Celery with RabbitMQ</a>
4790
-
is a detailed walkthrough for using these tools on an Ubuntu VPS.</p>
4791
-
</li>
4792
-
<li>
4793
4790
<p>Heroku has a clear walkthrough for using
4794
4791
<a href="https://devcenter.heroku.com/articles/python-rq">RQ for background tasks</a>.</p>
4795
4792
</li>
4796
4793
<li>
4797
-
<p><a href="http://www.linuxforu.com/2013/12/introducing-celery-pythondjango/">Introducing Celery for Python+Django</a>
4798
-
provides an introduction to the Celery task queue.</p>
4794
+
<p><a href="https://www.digitalocean.com/community/articles/how-to-use-celery-with-rabbitmq-to-queue-tasks-on-an-ubuntu-vps">How to use Celery with RabbitMQ</a>
4795
+
is a detailed walkthrough for using these tools on an Ubuntu VPS.</p>
4799
4796
</li>
4800
4797
<li>
4801
4798
<p><a href="https://denibertovic.com/posts/celery-best-practices/">Celery - Best Practices</a>
4802
4799
explains things you should not do with Celery and shows some underused
4803
4800
features for making task queues easier to work with.</p>
4804
4801
</li>
4805
4802
<li>
4806
-
<p>The "Django in Production" series by
4807
-
<a href="https://twitter.com/robgolding63">Rob Golding</a> contains a post
4808
-
specifically on <a href="http://www.robgolding.com/blog/2011/11/27/django-in-production-part-2---background-tasks/">Background Tasks</a>.</p>
4809
-
</li>
4810
-
<li>
4811
-
<p><a href="http://blog.thecodepath.com/2012/11/15/asynchronous-processing-in-web-applications-part-1-a-database-is-not-a-queue/">Asynchronous Processing in Web Applications Part One</a>
4812
-
and <a href="http://blog.thecodepath.com/2013/01/06/asynchronous-processing-in-web-applications-part-2-developers-need-to-understand-message-queues/">Part Two</a>
4813
-
are great reads for understanding the difference between a task queue and
4814
-
why you shouldn't use your database as one.</p>
4815
-
</li>
4816
-
<li>
4817
4803
<p><a href="http://www.caktusgroup.com/blog/2014/09/29/celery-production/">Celery in Production</a>
4818
4804
on the Caktus Group blog contains good practices from their experience
4819
4805
using Celery with RabbitMQ, monitoring tools and other aspects not often
<div class="well see-also">Celery is an implementation of the <a href="/task-queues.html">task queue</a> concept. Learn more in the <a href="/web-development.html">web development</a> chapter or view the <a href="/table-of-contents.html">table of contents</a> for all topics.</div>
4877
+
4878
+
<h2>Why is Celery useful?</h2>
4879
+
<p><a href="/task-queues.html">Task queues</a> and the Celery implementation in particular
4880
+
are one of the trickier parts of a Python web application stack to
4881
+
understand. </p>
4882
+
<p>If you are a junior developer it can be unclear why moving work
4883
+
outside the HTTP request-response cycle is important. In short, you want your <a href="/wsgi-servers.html">WSGI server</a> to respond to incoming requests as quickly
4884
+
as possible because each request ties up a worker process until the response
4885
+
is finished. Moving work off those workers by spinning up asynchronous jobs
4886
+
as tasks in a queue is a straightforward way to improve WSGI server response
4887
+
times.</p>
4888
+
<h2>What's the difference between Celeryd and Celerybeat?</h2>
4889
+
<p>Celery can be used to run batch jobs in the background on a
4890
+
regular schedule. A key concept in Celery is the difference between the
4891
+
Celery daemon (celeryd), which executes tasks, Celerybeat, which is a
4892
+
scheduler. Think of Celeryd as a tunnel-vision set of one or more workers
4893
+
that handle whatever tasks you put in front of them. Each worker will
4894
+
perform a task and when the task is completed will pick up the next one.
4895
+
The cycle will repeat continously, only waiting idly when there are no more
4896
+
tasks to put in front of them.</p>
4897
+
<p>Celerybeat on the other hand is like a boss who keeps track of when tasks
4898
+
should be executed. Your application can tell Celerybeat to execute a task
4899
+
at time intervals, such as every 5 seconds or once a week. Celerybeat can
4900
+
also be instructed to run tasks on a specific date or time, such as 5:03pm
4901
+
every Sunday. When the interval or specific time is hit, Celerybeat will
4902
+
hand the job over to Celeryd to execute on the next available worker.</p>
4903
+
<h3>Celery tutorials</h3>
4904
+
<p>Celery is a powerful tool that can be difficult to wrap your mind around
4905
+
at first. Be sure to read up on <a href="/task-queues.html">task queue</a> concepts
4906
+
then dive into these specific Celery tutorials.</p>
4907
+
<ul>
4908
+
<li>
4909
+
<p><a href="http://www.caktusgroup.com/blog/2014/06/23/scheduling-tasks-celery/">Getting Started Scheduling Tasks with Celery</a>
4910
+
is a detailed walkthrough for setting up Celery with Django (although
4911
+
Celery can also be used without a problem with other frameworks).</p>
4912
+
</li>
4913
+
<li>
4914
+
<p><a href="http://www.linuxforu.com/2013/12/introducing-celery-pythondjango/">Introducing Celery for Python+Django</a>
4915
+
provides an introduction to the Celery task queue with Django as the
4916
+
intended framework for building a web application.</p>
4917
+
</li>
4918
+
<li>
4919
+
<p><a href="https://www.digitalocean.com/community/articles/how-to-use-celery-with-rabbitmq-to-queue-tasks-on-an-ubuntu-vps">How to use Celery with RabbitMQ</a>
4920
+
is a detailed walkthrough for using these tools on an Ubuntu VPS.</p>
4921
+
</li>
4922
+
<li>
4923
+
<p><a href="https://denibertovic.com/posts/celery-best-practices/">Celery - Best Practices</a>
4924
+
explains things you should not do with Celery and shows some underused
4925
+
features for making task queues easier to work with.</p>
4926
+
</li>
4927
+
<li>
4928
+
<p><a href="http://blog.thecodepath.com/2012/11/15/asynchronous-processing-in-web-applications-part-1-a-database-is-not-a-queue/">Asynchronous Processing in Web Applications Part One</a>
4929
+
and <a href="http://blog.thecodepath.com/2013/01/06/asynchronous-processing-in-web-applications-part-2-developers-need-to-understand-message-queues/">Part Two</a>
4930
+
are great reads for understanding the difference between a task queue and
4931
+
why you shouldn't use your database as one.</p>
4932
+
</li>
4933
+
<li>
4934
+
<p><a href="https://www.youtube.com/watch?v=68QWZU_gCDA">A 4 Minute Intro to Celery</a> is
when tasks are otherwise sent over unencrypted networks.</p>
4941
+
</li>
4942
+
<li>
4943
+
<p>Miguel Grinberg wrote a nice post on using the
4944
+
<a href="http://blog.miguelgrinberg.com/post/using-celery-with-flask">task queue Celery with Flask</a>.
4945
+
He gives an overview of Celery followed by specific code to set up the task
4946
+
queue and integrate it with Flask.</p>
4947
+
</li>
4948
+
<li>
4949
+
<p><a href="https://wiredcraft.com/blog/3-gotchas-for-celery/">3 Gotchas for Working with Celery</a>
4950
+
are things to keep in mind when you're new to the Celery task queue
4951
+
implementation.</p>
4952
+
</li>
4953
+
<li>
4954
+
<p><a href="https://godjango.com/63-deferred-tasks-and-scheduled-jobs-with-celery-31-django-17-and-redis/">Deferred Tasks and Scheduled Jobs with Celery 3.1, Django 1.7 and Redis</a>
4955
+
is a video along with code that shows how to set up Celery with Redis as the
4956
+
broker in a Django application.</p>
4957
+
</li>
4958
+
<li>
4959
+
<p><a href="http://michal.karzynski.pl/blog/2014/05/18/setting-up-an-asynchronous-task-queue-for-django-using-celery-redis/">Setting up an asynchronous task queue for Django using Celery and Redis</a>
4960
+
is a straightforward tutorial for setting up the Celery task queue for
4961
+
Django web applications using the Redis broker on the back end.</p>
4962
+
</li>
4963
+
<li>
4964
+
<p><a href="https://realpython.com/blog/python/asynchronous-tasks-with-django-and-celery/">Asynchronous Tasks With Django and Celery</a>
4965
+
shows how to integrate Celery with <a href="/django.html">Django</a> and create Periodic Tasks.</p>
4966
+
</li>
4967
+
</ul>
4968
+
<h3>Celery deployment resources</h3>
4969
+
<ul>
4970
+
<li>
4971
+
<p>The "Django in Production" series by
4972
+
<a href="https://twitter.com/robgolding63">Rob Golding</a> contains a post
4973
+
specifically on <a href="http://www.robgolding.com/blog/2011/11/27/django-in-production-part-2---background-tasks/">Background Tasks</a>.</p>
4974
+
</li>
4975
+
<li>
4976
+
<p><a href="https://pythad.github.io/articles/2016-12/how-to-run-celery-as-a-daemon-in-production">How to run celery as a daemon?</a>
4977
+
is a short post with the minimal code for running the Celery daemon and
4978
+
Celerybeat as system services on Linux.</p>
4979
+
</li>
4980
+
<li>
4981
+
<p><a href="http://www.caktusgroup.com/blog/2014/09/29/celery-production/">Celery in Production</a>
4982
+
on the Caktus Group blog contains good practices from their experience
4983
+
using Celery with RabbitMQ, monitoring tools and other aspects not often
4984
+
discussed in existing documentation.</p>
4985
+
</li>
4986
+
<li>
4987
+
<p><a href="https://library.launchkit.io/three-quick-tips-from-two-years-with-celery-c05ff9d7f9eb">Three quick tips from two years with Celery</a>
4988
+
provides some solid advice on retry delays, the -Ofair flag and global
4989
+
task timeouts for Celery.</p>
4990
+
</li>
4991
+
</ul>
4894
4992
<h1>Microservices</h1>
4895
4993
<p>Microservices are an application architecture style where independent,
4896
4994
self-contained programs with a single purpose each can communicate with
0 commit comments