叢林裡的小芹菜
Celery in the Django


By Walter Liu
About me
 Learn  Python since 2004
 Was a Chief Technical Director in Softstar.
 Now an Architect in Trend Micro
 Light Celery user for several months.
Celery is    X
    Distributed
  Asynchronous
   Task Queue
Have you met?
 Deliver thousands to millions e-mails to
  your members?
 Many computation heavy queries at the
  same time that blocks your web site or
  DB?
 Query slow or too many connection to
  external API? (like Twitter/Facebook)
 Long run tasks that occupied your web
  server resources?
Celery in the Django
Why Celery?
 POC    without Celery
     Add a “@celery.task” and the tasks
      become distributed tasks.
 Multi-queue,   routing, all configurable.
 Many utility functionality to help task
  execution
     Group/Chord/Chain/Callback
     Retry/timeout
     Etc…..
from celery import Celery

@celery.task(
    max_retries = 3,
    default_retry_delay=2 * 60, # retry in 2 minutes.
    rate_limit = 20,
    time_limit = 10, # hard time limit
    soft_time_limit = 5,
    ignore_result = True,
    acks_late = True, # make sure this task will be done.
    )
def send_twitter_status(oauth, tweet):
    try:
         twitter = Twitter(oauth)
         twitter.update_status(tweet)
    except (Twitter.FailWhaleError, Twitter.LoginError), exc:
         raise send_twitter_status.retry(exc=exc)
Understand the personality of
your celery
 What   happen if the program throw an
  exception?
 What happen if the program hard/soft
  time limit?
 What happen if the hard/soft time limit
  reached in your group/chord function?
 Many others.
Our pitfall/trouble cases
   Many, too many small tasks
       For example 1 billion per day.
   Large task argument (workaround => store task at
    cache)
       Send file directly
   Better not wait another task in a task.
   Using Redis as AMQP and no HA.
   Hard time limit reached in Chord function.
   Multi-process and multi-thread problem in Windows
   Logging.
   Queue management
Some internet complain about
Celery
 Only Python
 API change and break his program
     2.5.x => 3.0.x
 Pylint
Some similar things
 Gearman
 Huey
 Advanced   Python Scheduler
Recruiting – we’re using
 Front-end:   not very limited.
 Backend
     Python
     Django
     MongoDB
     Redis/Memcache
     Celery

More Related Content

PDF
A pitfall when writing an asynchronous web application with Spring and Tomcat
PPT
No Va Taig April 7 2010
PDF
Troubleshooting containerized applications
PDF
Writing a Search Engine. How hard could it be?
PDF
Reactive Programming in .Net - actorbased computing with Akka.Net
PPTX
Spring method-level-secuirty
PDF
Afterlife Tales: Troubleshooting containerized applications
PDF
Helm your way with Kubernetes
A pitfall when writing an asynchronous web application with Spring and Tomcat
No Va Taig April 7 2010
Troubleshooting containerized applications
Writing a Search Engine. How hard could it be?
Reactive Programming in .Net - actorbased computing with Akka.Net
Spring method-level-secuirty
Afterlife Tales: Troubleshooting containerized applications
Helm your way with Kubernetes

Viewers also liked (16)

PDF
Understanding Non Blocking I/O with Python
PDF
Celery by dummy
PDF
Scaling up task processing with Celery
ODP
Introduction to Python Celery
KEY
Django Celery
PDF
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
PDF
Resftul API Web Development with Django Rest Framework & Celery
PDF
Distributed Task Processing with Celery - PyZH
PDF
Life in a Queue - Using Message Queue with django
PDF
Practical Celery
PDF
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
PDF
Advanced task management with Celery
PDF
Building Distributed System with Celery on Docker Swarm
PDF
An Introduction to Celery
ODP
Europython 2011 - Playing tasks with Django & Celery
PDF
Queue Everything and Please Everyone
Understanding Non Blocking I/O with Python
Celery by dummy
Scaling up task processing with Celery
Introduction to Python Celery
Django Celery
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
Resftul API Web Development with Django Rest Framework & Celery
Distributed Task Processing with Celery - PyZH
Life in a Queue - Using Message Queue with django
Practical Celery
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
Advanced task management with Celery
Building Distributed System with Celery on Docker Swarm
An Introduction to Celery
Europython 2011 - Playing tasks with Django & Celery
Queue Everything and Please Everyone
Ad

Similar to Celery in the Django (20)

PDF
PDF
Celery
PPTX
Asynchronous Task Queues with Celery
PDF
Celery with python
PDF
PyCon India 2012: Celery Talk
PDF
Deixa para depois, Procrastinando com Celery em Python
PPT
Introduction to Django-Celery and Supervisor
PDF
Celery: The Distributed Task Queue
PDF
MinbilDinbil Django Speed Tricks
KEY
Celery
PPTX
python_development.pptx
PDF
Django Celery - A distributed task queue
PDF
Advanced workflows
PDF
Asynchronous job queues with python-rq
PDF
Celery introduction
PDF
[Quase] Tudo que você precisa saber sobre tarefas assíncronas
PDF
Introduction to Celery
PDF
Data processing with celery and rabbit mq
PDF
Django productivity tips and tricks
PDF
Celery - A Distributed Task Queue
Celery
Asynchronous Task Queues with Celery
Celery with python
PyCon India 2012: Celery Talk
Deixa para depois, Procrastinando com Celery em Python
Introduction to Django-Celery and Supervisor
Celery: The Distributed Task Queue
MinbilDinbil Django Speed Tricks
Celery
python_development.pptx
Django Celery - A distributed task queue
Advanced workflows
Asynchronous job queues with python-rq
Celery introduction
[Quase] Tudo que você precisa saber sobre tarefas assíncronas
Introduction to Celery
Data processing with celery and rabbit mq
Django productivity tips and tricks
Celery - A Distributed Task Queue
Ad

More from Walter Liu (18)

PDF
Generative AI 在手機遊戲發行上的應用介紹.pdf
PDF
Infrastructure as code using Kubernetes
PDF
手機遊戲數位行銷工具淺談
PDF
關於第三方追蹤廣告再行銷的那些事兒
PDF
Kubernetes Workshop
PDF
Using Kubernetes to deploy Django in GCP
PDF
Game DDOS Prevention
PPTX
Airflow - a data flow engine
PPT
Super Fast Gevent Introduction
PPTX
HTTP/2 to web dev
PPTX
HTTP/2 Introduction
PDF
Consul - service discovery and others
PPTX
Docker introduction
PPTX
WRS GIT Branching Model - draft
PPTX
Salty OPS – Saltstack Introduction
PDF
Django deployment and rpm+yum
PDF
Game Localization in Python
PPTX
Service production from d3 pitfall viewpoint
Generative AI 在手機遊戲發行上的應用介紹.pdf
Infrastructure as code using Kubernetes
手機遊戲數位行銷工具淺談
關於第三方追蹤廣告再行銷的那些事兒
Kubernetes Workshop
Using Kubernetes to deploy Django in GCP
Game DDOS Prevention
Airflow - a data flow engine
Super Fast Gevent Introduction
HTTP/2 to web dev
HTTP/2 Introduction
Consul - service discovery and others
Docker introduction
WRS GIT Branching Model - draft
Salty OPS – Saltstack Introduction
Django deployment and rpm+yum
Game Localization in Python
Service production from d3 pitfall viewpoint

Recently uploaded (20)

PDF
Advancements in abstractive text summarization: a deep learning approach
PDF
Addressing the challenges of harmonizing law and artificial intelligence tech...
PPTX
Slides World Game (s) Great Redesign Eco Economic Epochs.pptx
PDF
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
PDF
Peak of Data & AI Encore: Scalable Design & Infrastructure
PDF
GDG Cloud Southlake #45: Patrick Debois: The Impact of GenAI on Development a...
PPTX
How to use fields_get method in Odoo 18
PDF
Child-friendly e-learning for artificial intelligence education in Indonesia:...
PDF
Optimizing bioinformatics applications: a novel approach with human protein d...
PDF
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
PDF
Domain-specific knowledge and context in large language models: challenges, c...
PDF
Examining Bias in AI Generated News Content.pdf
PDF
Technical Debt in the AI Coding Era - By Antonio Bianco
PDF
Ebook - The Future of AI A Comprehensive Guide.pdf
PDF
Uncertainty-aware contextual multi-armed bandits for recommendations in e-com...
PDF
Altius execution marketplace concept.pdf
PDF
ELLIE29.pdfWETWETAWTAWETAETAETERTRTERTER
PDF
【AI論文解説】高速・高品質な生成を実現するFlow Map Models(Part 1~3)
PDF
The Digital Engine Room: Unlocking APAC’s Economic and Digital Potential thro...
PDF
Slides World Game (s) Great Redesign Eco Economic Epochs.pdf
Advancements in abstractive text summarization: a deep learning approach
Addressing the challenges of harmonizing law and artificial intelligence tech...
Slides World Game (s) Great Redesign Eco Economic Epochs.pptx
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
Peak of Data & AI Encore: Scalable Design & Infrastructure
GDG Cloud Southlake #45: Patrick Debois: The Impact of GenAI on Development a...
How to use fields_get method in Odoo 18
Child-friendly e-learning for artificial intelligence education in Indonesia:...
Optimizing bioinformatics applications: a novel approach with human protein d...
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
Domain-specific knowledge and context in large language models: challenges, c...
Examining Bias in AI Generated News Content.pdf
Technical Debt in the AI Coding Era - By Antonio Bianco
Ebook - The Future of AI A Comprehensive Guide.pdf
Uncertainty-aware contextual multi-armed bandits for recommendations in e-com...
Altius execution marketplace concept.pdf
ELLIE29.pdfWETWETAWTAWETAETAETERTRTERTER
【AI論文解説】高速・高品質な生成を実現するFlow Map Models(Part 1~3)
The Digital Engine Room: Unlocking APAC’s Economic and Digital Potential thro...
Slides World Game (s) Great Redesign Eco Economic Epochs.pdf

Celery in the Django

  • 1. 叢林裡的小芹菜 Celery in the Django By Walter Liu
  • 2. About me  Learn Python since 2004  Was a Chief Technical Director in Softstar.  Now an Architect in Trend Micro  Light Celery user for several months.
  • 3. Celery is X Distributed Asynchronous Task Queue
  • 4. Have you met?  Deliver thousands to millions e-mails to your members?  Many computation heavy queries at the same time that blocks your web site or DB?  Query slow or too many connection to external API? (like Twitter/Facebook)  Long run tasks that occupied your web server resources?
  • 6. Why Celery?  POC without Celery  Add a “@celery.task” and the tasks become distributed tasks.  Multi-queue, routing, all configurable.  Many utility functionality to help task execution  Group/Chord/Chain/Callback  Retry/timeout  Etc…..
  • 7. from celery import Celery @celery.task( max_retries = 3, default_retry_delay=2 * 60, # retry in 2 minutes. rate_limit = 20, time_limit = 10, # hard time limit soft_time_limit = 5, ignore_result = True, acks_late = True, # make sure this task will be done. ) def send_twitter_status(oauth, tweet): try: twitter = Twitter(oauth) twitter.update_status(tweet) except (Twitter.FailWhaleError, Twitter.LoginError), exc: raise send_twitter_status.retry(exc=exc)
  • 8. Understand the personality of your celery  What happen if the program throw an exception?  What happen if the program hard/soft time limit?  What happen if the hard/soft time limit reached in your group/chord function?  Many others.
  • 9. Our pitfall/trouble cases  Many, too many small tasks  For example 1 billion per day.  Large task argument (workaround => store task at cache)  Send file directly  Better not wait another task in a task.  Using Redis as AMQP and no HA.  Hard time limit reached in Chord function.  Multi-process and multi-thread problem in Windows  Logging.  Queue management
  • 10. Some internet complain about Celery  Only Python  API change and break his program  2.5.x => 3.0.x  Pylint
  • 11. Some similar things  Gearman  Huey  Advanced Python Scheduler
  • 12. Recruiting – we’re using  Front-end: not very limited.  Backend  Python  Django  MongoDB  Redis/Memcache  Celery

Editor's Notes

  • #2: Description很多人都是因為追著蟒蛇誤入叢林,叢林是危機重重的,如何在危險的叢林裏野地求生,找尋自己的一條生路呢?在此介紹你【芹菜】,芹菜是一個好菜,它健康,它機能性強,除了幫助你在叢林裏生存,自從我吃了它,我每次考試都考100分。
  • #10: We have a system that need to process 1 billion tasks per day.