SlideShare a Scribd company logo
1 of 12
Download to read offline
By
Os Shiowattana (@djshiow)
Who am I
● Os Shiowattana (@djshiow)
● Software engineer for ~10 years
● Currently at Origami Logic
○ We’re looking for great developers ;-)
● Python experience: 3 months
○ Teaching is a good way to learn
Outline
● What is Celery?
● What is it for?
● Simple Example
http://www.myhdiet.com/sharons-raw-celery-soup/
What is celery?
● Task queue
○ Distributed
○ Asynchronous
● Create tasks and
add it to the queue
● Workers pick them
up & work on them
How does it work?
Broker
Worker
Worker
Worker
….
Producer
Result
Store
What is it for?
● Long running asynchronous task
● Execute a task “reliably”
○ Asynchronous + Retries
○ e.g. Interactions with external APIs
● Scheduling Periodic tasks
How does Origami Logic use it?
● Fetch marketing metrics from all your social
network daily
○ Periodic
○ Reliable (with retries) / Traceable
○ Distributed (multiple machines) & Scalable
○ Rate limits
Instagram
● Populate follower feed
>7 M followers
Source: http://blogs.vmware.com/vfabric/2013/04/how-instagram-feeds-work-celery-and-rabbitmq.html
Simple Example
● Adding two numbers asynchronously !!
● Setup:
○ Install RabbitMQ
○ Install Celery
From: http://celery.readthedocs.org/en/latest/getting-started/first-steps-with-celery.html
First, define Celery app & tasks
from celery import Celery
#setup app
app = Celery('tasks', backend='amqp' , broker='amqp://guest@localhost//')
#Define task
@app.task
def add(x, y):
return x + y
Then, run celery worker
celery -A tasks worker --loglevel=info
Decorator to create a task class
Lastly, trigger the task
from tasks import add
#run the add task asynchronously 3 seconds later
#passing (4,4) as param
add.apply_async((4, 4) , countdown=3)
[2015-03-15 14:34:10,397: INFO/MainProcess]Received task: tasks.add[b68b0109-7e99-473b-8991-1da8adaa50e8]
eta:[2015-03-15 14:34:13.385448+00:00]
[2015-03-15 14:34:14,836: INFO/MainProcess] Tasktasks.add[b68b0109-7e99-473b-8991-1da8adaa50e8] succeeded in
0.0209855769999s: 8
Reference
● http://www.slideshare.net/idangazit/an-introduction-to-celery
● http://blogs.vmware.com/vfabric/2013/04/how-instagram-feeds-work-
celery-and-rabbitmq.html
● http://celery.readthedocs.org/en/latest/

More Related Content

Viewers also liked

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
 

Viewers also liked (9)

Building Distributed System with Celery on Docker Swarm
Building Distributed System with Celery on Docker SwarmBuilding Distributed System with Celery on Docker Swarm
Building Distributed System with Celery on Docker Swarm
 
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
 
Practical Celery
Practical CeleryPractical Celery
Practical Celery
 
Distributed Task Processing with Celery - PyZH
Distributed Task Processing with Celery - PyZHDistributed Task Processing with Celery - PyZH
Distributed Task Processing with Celery - PyZH
 
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
 
Resftul API Web Development with Django Rest Framework & Celery
Resftul API Web Development with Django Rest Framework & CeleryResftul API Web Development with Django Rest Framework & Celery
Resftul API Web Development with Django Rest Framework & Celery
 
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
 
An Introduction to Celery
An Introduction to CeleryAn Introduction to Celery
An Introduction to Celery
 
Queue Everything and Please Everyone
Queue Everything and Please EveryoneQueue Everything and Please Everyone
Queue Everything and Please Everyone
 

Similar to Celery by dummy

Similar to Celery by dummy (20)

Resume Writing Workshop (Part I)
Resume Writing Workshop (Part I)Resume Writing Workshop (Part I)
Resume Writing Workshop (Part I)
 
Importance of UX Design in PM by Dhantra Studio Founder & CEO
Importance of UX Design in PM by Dhantra Studio Founder & CEOImportance of UX Design in PM by Dhantra Studio Founder & CEO
Importance of UX Design in PM by Dhantra Studio Founder & CEO
 
Importance of UX Design in PM by Dhantra Studio Founder & CEO
Importance of UX Design in PM by Dhantra Studio Founder & CEOImportance of UX Design in PM by Dhantra Studio Founder & CEO
Importance of UX Design in PM by Dhantra Studio Founder & CEO
 
Engineering career is not a single ladder! - Alternative pathway to develope...
Engineering career is not a single ladder!  - Alternative pathway to develope...Engineering career is not a single ladder!  - Alternative pathway to develope...
Engineering career is not a single ladder! - Alternative pathway to develope...
 
Pivotal Tracker - Research Findings
Pivotal Tracker - Research FindingsPivotal Tracker - Research Findings
Pivotal Tracker - Research Findings
 
WTM-2023-Looker Studio.pdf
WTM-2023-Looker Studio.pdfWTM-2023-Looker Studio.pdf
WTM-2023-Looker Studio.pdf
 
How to เสร็จเร็ว (Use Agile for your project with team)
How to เสร็จเร็ว (Use Agile for your project with team)How to เสร็จเร็ว (Use Agile for your project with team)
How to เสร็จเร็ว (Use Agile for your project with team)
 
Data Driven Business Lab Feb2019
Data Driven Business Lab Feb2019Data Driven Business Lab Feb2019
Data Driven Business Lab Feb2019
 
Curtain call of zooey - what i've learned in yahoo
Curtain call of zooey - what i've learned in yahooCurtain call of zooey - what i've learned in yahoo
Curtain call of zooey - what i've learned in yahoo
 
Your first 5 PHP design patterns - ThatConference 2012
Your first 5 PHP design patterns - ThatConference 2012Your first 5 PHP design patterns - ThatConference 2012
Your first 5 PHP design patterns - ThatConference 2012
 
Growing up new PostgreSQL developers (pgcon.org 2018)
Growing up new PostgreSQL developers (pgcon.org 2018)Growing up new PostgreSQL developers (pgcon.org 2018)
Growing up new PostgreSQL developers (pgcon.org 2018)
 
build@mercari-week7-mark-talk
build@mercari-week7-mark-talkbuild@mercari-week7-mark-talk
build@mercari-week7-mark-talk
 
From ic to tech lead
From ic to tech leadFrom ic to tech lead
From ic to tech lead
 
Professional development
Professional developmentProfessional development
Professional development
 
Coding dojo
Coding dojoCoding dojo
Coding dojo
 
New Technology and Structures for Engaging Classrooms
New Technology and Structures for Engaging ClassroomsNew Technology and Structures for Engaging Classrooms
New Technology and Structures for Engaging Classrooms
 
Introduction to Scrum
Introduction to ScrumIntroduction to Scrum
Introduction to Scrum
 
APIdays Paris 2019 - Delta Air Lines Dojo Journey by Miguel Quintero, Sr., De...
APIdays Paris 2019 - Delta Air Lines Dojo Journey by Miguel Quintero, Sr., De...APIdays Paris 2019 - Delta Air Lines Dojo Journey by Miguel Quintero, Sr., De...
APIdays Paris 2019 - Delta Air Lines Dojo Journey by Miguel Quintero, Sr., De...
 
Django Bath and Bristol Users Group
Django Bath and Bristol Users GroupDjango Bath and Bristol Users Group
Django Bath and Bristol Users Group
 
In the Know: Planning Knowledge Projects by Kevin McGowan
In the Know: Planning Knowledge Projects by Kevin McGowanIn the Know: Planning Knowledge Projects by Kevin McGowan
In the Know: Planning Knowledge Projects by Kevin McGowan
 

Recently uploaded

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Recently uploaded (20)

%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 

Celery by dummy

  • 2. Who am I ● Os Shiowattana (@djshiow) ● Software engineer for ~10 years ● Currently at Origami Logic ○ We’re looking for great developers ;-) ● Python experience: 3 months ○ Teaching is a good way to learn
  • 3. Outline ● What is Celery? ● What is it for? ● Simple Example http://www.myhdiet.com/sharons-raw-celery-soup/
  • 4. What is celery? ● Task queue ○ Distributed ○ Asynchronous ● Create tasks and add it to the queue ● Workers pick them up & work on them
  • 5. How does it work? Broker Worker Worker Worker …. Producer Result Store
  • 6. What is it for? ● Long running asynchronous task ● Execute a task “reliably” ○ Asynchronous + Retries ○ e.g. Interactions with external APIs ● Scheduling Periodic tasks
  • 7. How does Origami Logic use it? ● Fetch marketing metrics from all your social network daily ○ Periodic ○ Reliable (with retries) / Traceable ○ Distributed (multiple machines) & Scalable ○ Rate limits
  • 8. Instagram ● Populate follower feed >7 M followers Source: http://blogs.vmware.com/vfabric/2013/04/how-instagram-feeds-work-celery-and-rabbitmq.html
  • 9. Simple Example ● Adding two numbers asynchronously !! ● Setup: ○ Install RabbitMQ ○ Install Celery From: http://celery.readthedocs.org/en/latest/getting-started/first-steps-with-celery.html
  • 10. First, define Celery app & tasks from celery import Celery #setup app app = Celery('tasks', backend='amqp' , broker='amqp://guest@localhost//') #Define task @app.task def add(x, y): return x + y Then, run celery worker celery -A tasks worker --loglevel=info Decorator to create a task class
  • 11. Lastly, trigger the task from tasks import add #run the add task asynchronously 3 seconds later #passing (4,4) as param add.apply_async((4, 4) , countdown=3) [2015-03-15 14:34:10,397: INFO/MainProcess]Received task: tasks.add[b68b0109-7e99-473b-8991-1da8adaa50e8] eta:[2015-03-15 14:34:13.385448+00:00] [2015-03-15 14:34:14,836: INFO/MainProcess] Tasktasks.add[b68b0109-7e99-473b-8991-1da8adaa50e8] succeeded in 0.0209855769999s: 8