SlideShare une entreprise Scribd logo
1  sur  12
Django Celery
How to handle asynchronous tasks in Django
What is Celery?
Don’t Block the User
Speed
Scale
Use Cases

• Logging
• Regular twitter updates
• Sending 10k (or more!) emails
Choosing a Message Queue

• MongoDB
              Celery Documentation
• CouchDB      and most installations
• Beanstalk   use RabbitMQ - and so
                    should you.
• Redis
• RabbitMQ
Queues vs. Hosts
Tools and Command


• sudo rabbitmqctl set_permissions user_name “.*” “.*” “.*”
• ./manage.py celeryd -c6
• ./manage.py camqadm
• sudo rabbitmqctl list_queues
Setting up a Daemon on
           Ubuntu
• Copy celeryd from https://github.com/ask/
 celery/tree/master/contrib/debian/init.d/ to /
 etc/init.d/

• Copy gist from https://gist.github.com/702593
 to /etc/default/celeryd

• Update runlevels: sudo update-rc.d celeryd
 defaults

• Start celeryd: sudo service celeryd start
Yipit Django Team


• http://tech.yipit.com/
• Adam Nelson - @varud
• Zach Smith - @zmsmith
• Nitya Oberoi - @nityaoberoi

Contenu connexe

Tendances

Perfomance tuning on Go 2.0
Perfomance tuning on Go 2.0Perfomance tuning on Go 2.0
Perfomance tuning on Go 2.0
Yogi Kulkarni
 
Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013
Jan Gehring
 
Crash reports pycodeconf
Crash reports pycodeconfCrash reports pycodeconf
Crash reports pycodeconf
lauraxthomson
 

Tendances (20)

Make It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Control
 
OpenWhisk Go Runtime
OpenWhisk Go RuntimeOpenWhisk Go Runtime
OpenWhisk Go Runtime
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
 
Perfomance tuning on Go 2.0
Perfomance tuning on Go 2.0Perfomance tuning on Go 2.0
Perfomance tuning on Go 2.0
 
Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013
 
What we do with Go
What we do with GoWhat we do with Go
What we do with Go
 
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
 
eigr.io – a Serverless Runtime on the BEAM (ACM SIGPLAN, ICFP 2021 Erlang Wor...
eigr.io – a Serverless Runtime on the BEAM (ACM SIGPLAN, ICFP 2021 Erlang Wor...eigr.io – a Serverless Runtime on the BEAM (ACM SIGPLAN, ICFP 2021 Erlang Wor...
eigr.io – a Serverless Runtime on the BEAM (ACM SIGPLAN, ICFP 2021 Erlang Wor...
 
Puppet Camp Chicago 2014: Running Multiple Puppet Masters (Beginner)
Puppet Camp Chicago 2014: Running Multiple Puppet Masters (Beginner) Puppet Camp Chicago 2014: Running Multiple Puppet Masters (Beginner)
Puppet Camp Chicago 2014: Running Multiple Puppet Masters (Beginner)
 
"Using Automation Tools To Deploy And Operate Applications In Real World Scen...
"Using Automation Tools To Deploy And Operate Applications In Real World Scen..."Using Automation Tools To Deploy And Operate Applications In Real World Scen...
"Using Automation Tools To Deploy And Operate Applications In Real World Scen...
 
Continuous Integration on Steroids
Continuous Integration on SteroidsContinuous Integration on Steroids
Continuous Integration on Steroids
 
Crash reports pycodeconf
Crash reports pycodeconfCrash reports pycodeconf
Crash reports pycodeconf
 
[231] the simplicity of cluster apps with circuit
[231] the simplicity of cluster apps with circuit[231] the simplicity of cluster apps with circuit
[231] the simplicity of cluster apps with circuit
 
TDC2017 | São Paulo - Trilha Containers How we figured out we had a SRE team ...
TDC2017 | São Paulo - Trilha Containers How we figured out we had a SRE team ...TDC2017 | São Paulo - Trilha Containers How we figured out we had a SRE team ...
TDC2017 | São Paulo - Trilha Containers How we figured out we had a SRE team ...
 
Concurrency in ruby
Concurrency in rubyConcurrency in ruby
Concurrency in ruby
 
Ceylon From Here to Infinity: The Big Picture and What's Coming
Ceylon From Here to Infinity: The Big Picture and What's Coming Ceylon From Here to Infinity: The Big Picture and What's Coming
Ceylon From Here to Infinity: The Big Picture and What's Coming
 
Performance Benchmarking: Tips, Tricks, and Lessons Learned
Performance Benchmarking: Tips, Tricks, and Lessons LearnedPerformance Benchmarking: Tips, Tricks, and Lessons Learned
Performance Benchmarking: Tips, Tricks, and Lessons Learned
 
Next generation pipelines
Next generation pipelinesNext generation pipelines
Next generation pipelines
 
Golang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war storyGolang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war story
 
ContainerCon sysdig Slides
ContainerCon sysdig Slides ContainerCon sysdig Slides
ContainerCon sysdig Slides
 

En vedette

Europython 2011 - Playing tasks with Django & Celery
Europython 2011 - Playing tasks with Django & CeleryEuropython 2011 - Playing tasks with Django & Celery
Europython 2011 - Playing tasks with Django & Celery
Mauro Rocco
 

En vedette (17)

Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
 
Celery in the Django
Celery in the DjangoCelery in the Django
Celery in the Django
 
Europython 2011 - Playing tasks with Django & Celery
Europython 2011 - Playing tasks with Django & CeleryEuropython 2011 - Playing tasks with Django & Celery
Europython 2011 - Playing tasks with Django & Celery
 
MinbilDinbil Django Speed Tricks
MinbilDinbil Django Speed TricksMinbilDinbil Django Speed Tricks
MinbilDinbil Django Speed Tricks
 
Django Celery - A distributed task queue
Django Celery - A distributed task queueDjango Celery - A distributed task queue
Django Celery - A distributed task queue
 
Large Scale Processing with Django
Large Scale Processing with DjangoLarge Scale Processing with Django
Large Scale Processing with Django
 
Celery with python
Celery with pythonCelery with python
Celery with python
 
PyCon India 2012: Celery Talk
PyCon India 2012: Celery TalkPyCon India 2012: Celery Talk
PyCon India 2012: Celery Talk
 
Data processing with celery and rabbit mq
Data processing with celery and rabbit mqData processing with celery and rabbit mq
Data processing with celery and rabbit mq
 
Life in a Queue - Using Message Queue with django
Life in a Queue - Using Message Queue with djangoLife in a Queue - Using Message Queue with django
Life in a Queue - Using Message Queue with django
 
Practical Celery
Practical CeleryPractical Celery
Practical Celery
 
Django Celery
Django Celery Django Celery
Django Celery
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task Queue
 
Advanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Advanced Aspects of the Django Ecosystem: Haystack, Celery & FabricAdvanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Advanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
 
An Introduction to Celery
An Introduction to CeleryAn Introduction to Celery
An Introduction to Celery
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
 
5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance
 

Similaire à Celery

Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1
Susant Sahani
 
Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011
Rich Bowen
 

Similaire à Celery (20)

Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
 
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
 
Benchmarking Solr Performance at Scale
Benchmarking Solr Performance at ScaleBenchmarking Solr Performance at Scale
Benchmarking Solr Performance at Scale
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1
 
Autoscaled Distributed Automation using AWS at Selenium London MeetUp
Autoscaled Distributed Automation using AWS at Selenium London MeetUpAutoscaled Distributed Automation using AWS at Selenium London MeetUp
Autoscaled Distributed Automation using AWS at Selenium London MeetUp
 
Deploying to Ubuntu on Linode
Deploying to Ubuntu on LinodeDeploying to Ubuntu on Linode
Deploying to Ubuntu on Linode
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Hack & Fix, Hands on ColdFusion Security Training
Hack & Fix, Hands on ColdFusion Security TrainingHack & Fix, Hands on ColdFusion Security Training
Hack & Fix, Hands on ColdFusion Security Training
 
Best And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM ConnectionsBest And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM Connections
 
Tuning Linux for MongoDB
Tuning Linux for MongoDBTuning Linux for MongoDB
Tuning Linux for MongoDB
 
Autoscaled Distributed Automation Expedia Know How
Autoscaled Distributed Automation Expedia Know HowAutoscaled Distributed Automation Expedia Know How
Autoscaled Distributed Automation Expedia Know How
 
Server-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick TourServer-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick Tour
 
systemd @ Facebook -- a year later
systemd @ Facebook -- a year latersystemd @ Facebook -- a year later
systemd @ Facebook -- a year later
 
Deployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS LinuxDeployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS Linux
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011
 
Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!
Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!
Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!
 
Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 

Plus de Yipit (9)

Outsourcing startup operations 3 10-13
Outsourcing startup operations 3 10-13Outsourcing startup operations 3 10-13
Outsourcing startup operations 3 10-13
 
SMX East: Doing Offers Right
SMX East: Doing Offers RightSMX East: Doing Offers Right
SMX East: Doing Offers Right
 
Trillion Dollar Industry | Deals 3D
Trillion Dollar Industry | Deals 3DTrillion Dollar Industry | Deals 3D
Trillion Dollar Industry | Deals 3D
 
Outsourcing Class
Outsourcing ClassOutsourcing Class
Outsourcing Class
 
Newspaper Daily Deal Performance - March 2010
Newspaper Daily Deal Performance - March 2010Newspaper Daily Deal Performance - March 2010
Newspaper Daily Deal Performance - March 2010
 
Group Buying By The Numbers
Group Buying By The NumbersGroup Buying By The Numbers
Group Buying By The Numbers
 
Daily Deals: Where Ads Become Content
Daily Deals: Where Ads Become ContentDaily Deals: Where Ads Become Content
Daily Deals: Where Ads Become Content
 
Daily Deal Stack
Daily Deal StackDaily Deal Stack
Daily Deal Stack
 
Yipit Webinar 8-19-10
Yipit Webinar 8-19-10Yipit Webinar 8-19-10
Yipit Webinar 8-19-10
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Celery

  • 1. Django Celery How to handle asynchronous tasks in Django
  • 6. Use Cases • Logging • Regular twitter updates • Sending 10k (or more!) emails
  • 7.
  • 8. Choosing a Message Queue • MongoDB Celery Documentation • CouchDB and most installations • Beanstalk use RabbitMQ - and so should you. • Redis • RabbitMQ
  • 10. Tools and Command • sudo rabbitmqctl set_permissions user_name “.*” “.*” “.*” • ./manage.py celeryd -c6 • ./manage.py camqadm • sudo rabbitmqctl list_queues
  • 11. Setting up a Daemon on Ubuntu • Copy celeryd from https://github.com/ask/ celery/tree/master/contrib/debian/init.d/ to / etc/init.d/ • Copy gist from https://gist.github.com/702593 to /etc/default/celeryd • Update runlevels: sudo update-rc.d celeryd defaults • Start celeryd: sudo service celeryd start
  • 12. Yipit Django Team • http://tech.yipit.com/ • Adam Nelson - @varud • Zach Smith - @zmsmith • Nitya Oberoi - @nityaoberoi

Notes de l'éditeur

  1. Presenters:\n\nAdam Nelson - Prior to Yipit, Adam was SVP of Technology at PerformLine, an online advertising compliance company. He was responsible for the development and architecture of the company’s flagship Campaign Verification platform. Previously, he was CTO of ForSaleByOwner.com, which was acquired by Tribune Interactive in 2006. He received a B.S. in Physics from the State University of New York at Albany and an A.M. in International Relations from the University of Chicago.\n\nZach Smith- Prior to Yipit, Zach was the Lead Product Architect at PerformLine. Zach graduated from Washington University in St. Louis with a degree in Economics and Marketing and studied Computer Science at Columbia University.\n
  2. Celery is a python library for queueing and running jobs asynchronously, usually using the Advanced Message Queuing Protocol. django-celery (djcelery) is a django library that sits on top of celery.\nCelery “tasks” can be queued whenever the application doesn’t need to know the outcome of a request in real time.\nExamples include click logging, sending email from a site, computing slow queries offline\n
  3. The most important reason to use Celery is to offload tasks that would otherwise block other processes - most importantly convenience to the end user. For example, when reviewing deals on Yipit, celery is responsible for indexing so that the user can continue using the website.\n
  4. Celery jobs don't finish any sooner than normal Python operations, but from the user’s point of view it can make things seem very fast. Processing is done offline from the user process. \n
  5. Because celery job are split into individual tasks, it is easy to run jobs in separate processes for horizontal scalability\n
  6. Actions where the user doesn’t need to know the outcome\n Repetitive jobs \n Jobs that can be run in parallel \n
  7. Most Python methods will use standard synchronous processing and connect to the database directly. Slow or big jobs can be pushed to RabbitMQ to be done later by Celery workers offline.\n Brokers and workers can be on the same machine, there is little advantage to splitting them up since the broker service (RabbitMQ) uses very few resources.\n Multiple worker servers are only necessary if your tasks are taking too long and you’ve fully loaded the first worker server.\n Multiple broker servers are only necessary if unplanned downtime is unacceptable.\n
  8. I’m not the biggest fan of RabbitMQ because of its poor documentation but it works very well and the main Celery developer (Solem) uses it and it is the most mature configuration. The performance and reliability has been fantastic so far. RabbitMQ is the easiest and likely the best option unless you have deep experience with one of the alternative broker backends.\n\nAs with everything else, use homebrew to install RabbitMQ on your Mac.\n
  9. The RabbitMQ documentation isn’t very clear on how virtual hosts and queues work.\n Virtual Hosts are only useful for security isolation (i.e. different credentials for different hosts). There is no performance or administrative benefit to using multiple virtual hosts.\n Queues are very useful if you want one worker dedicated to one queue of jobs instead of another. This way, if one queue has jobs that should have priority, a dedicated Celery worker can be assigned to that queue alone.\n
  10. rabbitmqctl set_permissions - Grants all permissions to user_name\nceleryd - deamon for running jobs, concurrency\ncamqadm - Relatively new interactive shell for querying rabbit broker\nrabbitmqctl list_queues - Shows number of items in each queue\n
  11. Having a celeryd daemon running is much better than relying on a ./manage.py implementation from the command line. This way the service starts when the machine starts up and shuts down gracefully when the machine is rebooted. Remember to restart the celery service if any of the Python files are updated - otherwise you’re running the old code.\n
  12. Thanks Everybody!\n