Skip to content

Commit b5240dd

Browse files
committed
add celery page
1 parent 9e11754 commit b5240dd

File tree

95 files changed

+646
-195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+646
-195
lines changed

all.html

Lines changed: 135 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4680,14 +4680,14 @@ <h2>Why are task queues necessary?</h2>
46804680
</li>
46814681
</ul>
46824682
<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>
46884688
<ul>
46894689
<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
46914691
most commonly used Python library for handling asynchronous tasks and
46924692
scheduling.</p>
46934693
</li>
@@ -4755,11 +4755,6 @@ <h2>Open source examples that use task queues</h2>
47554755
<h2>Task queue resources</h2>
47564756
<ul>
47574757
<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>
47634758
<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>
47644759
shows how to combine the RQ task queue library with Flask to send
47654760
text message notifications every time a condition is met - in this blog
@@ -4781,39 +4776,30 @@ <h2>Task queue resources</h2>
47814776
is a presentation for what task queues are and why they are needed. </p>
47824777
</li>
47834778
<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>
47844785
<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>
47854786
provides a detailed walkthrough of setting up workers to use RQ with
47864787
Redis.</p>
47874788
</li>
47884789
<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>
47934790
<p>Heroku has a clear walkthrough for using
47944791
<a href="https://devcenter.heroku.com/articles/python-rq">RQ for background tasks</a>.</p>
47954792
</li>
47964793
<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>
47994796
</li>
48004797
<li>
48014798
<p><a href="https://denibertovic.com/posts/celery-best-practices/">Celery - Best Practices</a>
48024799
explains things you should not do with Celery and shows some underused
48034800
features for making task queues easier to work with.</p>
48044801
</li>
48054802
<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>
48174803
<p><a href="http://www.caktusgroup.com/blog/2014/09/29/celery-production/">Celery in Production</a>
48184804
on the Caktus Group blog contains good practices from their experience
48194805
using Celery with RabbitMQ, monitoring tools and other aspects not often
@@ -4850,15 +4836,6 @@ <h2>Task queue resources</h2>
48504836
Django web applications using the Redis broker on the back end.</p>
48514837
</li>
48524838
<li>
4853-
<p><a href="http://django.zone/blog/posts/background-jobs-django-and-celery/">Background jobs with Django and Celery</a>
4854-
shows the code and a simple explanation of how to use Celery with
4855-
<a href="/django.html">Django</a>.</p>
4856-
</li>
4857-
<li>
4858-
<p><a href="https://realpython.com/blog/python/asynchronous-tasks-with-django-and-celery/">Asynchronous Tasks With Django and Celery</a>
4859-
shows how to integrate Celery with <a href="/django.html">Django</a> and create Periodic Tasks.</p>
4860-
</li>
4861-
<li>
48624839
<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>
48634840
provides some solid advice on retry delays, the -Ofair flag and global
48644841
task timeouts for Celery.</p>
@@ -4891,6 +4868,127 @@ <h2>Task queue learning checklist</h2>
48914868
slow running code it originally relied upon.</p>
48924869
</li>
48934870
</ol>
4871+
<h1>Celery</h1>
4872+
<p><a href="http://www.celeryproject.org/">Celery</a> is a <a href="/task-queues.html">task queue</a>
4873+
implementation for <a href="/web-development.html">Python web applications</a> used
4874+
to asynchronously execute work outside the HTTP request-response cycle.</p>
4875+
<p><a href="http://www.celeryproject.org/" style="border: none;"><img src="/source/static/img/logos/celery.png" width="100%" alt="Celery task queue project logo." style="border-radius: 5px;" width="100%" class="technical-diagram"></a></p>
4876+
<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
4935+
a short introductory task queue screencast.</p>
4936+
</li>
4937+
<li>
4938+
<p>Heroku wrote about how to
4939+
<a href="https://engineering.heroku.com/blogs/2014-09-15-securing-celery">secure Celery</a>
4940+
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>
48944992
<h1>Microservices</h1>
48954993
<p>Microservices are an application architecture style where independent,
48964994
self-contained programs with a single purpose each can communicate with

0 commit comments

Comments
 (0)