SlideShare a Scribd company logo
Building Distributed System
with Celery on Docker Swarm
Wei Lin
PyCon JP 2016
2016/09/22
2
About Me
• Wei Lin
@Wei_1144
Wei1234c@gmail.com
https://github.com/Wei1234c
• Mostly worked in the fields of:
– marketing
– strategy-planning
– project-management
• Materials of this talk:
https://github.com/Wei1234c/PyCon-JP-2016-talk
3
Parallel computing
https://resin.io/blog/what-would-you-do-with-a-120-raspberry-pi-cluster/
4
Distributed System
5
Distributed system
6
Distributed system (II)
7
Neural network
h1 hh2 h3
8
Communicate via Celery
Celery
10
Celery flowchart
Send message to a specific queue
12
Send message
http://docs.celeryproject.org/en/latest/userguide/calling.html
kick.apply_async([‘neuron_x’])
kick.apply_async([‘neuron_x’], routing_key = ‘neuron_h1’)
13
Configuration file
14
Task Message Example
http://docs.celeryproject.org/en/latest/internals/protocol.html
15
Routing Tasks
http://docs.celeryproject.org/en/latest/userguide/routing.html
Assign an unique worker
for a specific queue
17
Starting the Workerhttp://docs.celeryproject.org/en/latest/userguide/workers.html
https://github.com/celery/celery/issues/3065
$ celery -A IoT worker -n neuron_h1 
-Q neuron_h1 --concurrency=1
Docker
19
Host and containers
https://denibertovic.com/talks/supercharge-development-env-using-docker/#/10
20
Run worker container
21
Deploy containers
22
Celery worker containers
as neurons
h
h1 h2 h3
kick.apply_async( routing_key = ‘neuron_h1’)
getData.apply_async(routing_key = ‘neuron_h1’) .get()
23
“Celery + Docker-Swarm”
So ?
I think…
24
Docker file/image/container
https://denibertovic.com/talks/supercharge-development-env-using-docker/#/11
25
Think OO
• “From” to Inherit
• Dockerfile to Encapsulate
• Docker Image as Class
• Docker Container as Object
26
Docker Swarm & Celery
doSomething.apply_async (routing_key = ‘host_NY’)
Tokyo Taipei New York
getData.apply_async(routing_key = ‘host_NY’) .get()
27
Distributed System
28
OOAD
Station C Station B Station A
29
Bound services
30
Parallel computing
https://resin.io/blog/what-would-you-do-with-a-120-raspberry-pi-cluster/
31
parallel computing
⊆⊆⊆⊆⊆⊆⊆⊆ distributed computing
32
How to do Parallel Computing
1. Run and deploy Docker containers across Docker
Swarm cluster, with a Celery worker process running
in each container.
2. When initiate worker processes, don’t assign “Queue”
parameter, so ALL the workers will listen to the default
queue in broker.
3. Sending bunch of messages to broker without setting
routing_key parameter, the messages will be routed to
the default queue.
4. In a parallel fashion, all workers will pick up messages
from the default queue and do the tasks.
33
Deploy parallel computing
• Deploy containers over Docker Swarm
– deploy containers
• docker-compose up –d
• docker-compose scale celery= n (for example)
• Send task messages to worker containers
results = [ doSomething.apply_async([data]) for data in dataset ]
• But, Docker Swarm needs
root password-less SSH
34
SETI@home
35
One for all, All for one
https://github.com/Wei1234c/OneForAll_AllForOne/blob/master/celery_projects/OneForAll_AllForOne.md
• run a Docker image to join distributed
parallel computing cluster, that’s all.
docker run –d wei1234c/musketeer (for example)
36
Summary
• Easy to use
– doSomething.apply_async ([xxx], routing_key = ‘host_NY’)
– getData.apply_async(routing_key = ‘host_NY’) .get()
• Adventages of a distributed system
– Decoupling, DI/IC (dependency injection / inversion of control )
– Distributed = Shared
– Load-Balancing
• Caution:
– See ref: Distributed systems theory for the distributed systems engineer
• Take a look of Canvas in Celery
– Chain
– Group
37
Source Code
• Celery on Docker Swarm
– using “Word Count” as an example of parallel computing.
– https://github.com/Wei1234c/CeleryOnDockerSwarm/tree/master
/celery_projects
• IoT as Brain
– simulate an artificial neural-network of 6 neurons.
– https://github.com/Wei1234c/IOTasBrain/tree/master/celery_proj
ects
• One for all, all for one
– follow the SETI@home paradigm.
– on each machine, running a single Docker container to join the
cluster.
– https://github.com/Wei1234c/OneForAll_AllForOne/tree/master/c
elery_projects
38
References
References :
• Distributed systems theory for the distributed systems engineer
– http://the-paper-trail.org/blog/distributed-systems-theory-for-the-distributed-systems-
engineer/
• Celery user guide
– http://docs.celeryproject.org/en/latest/userguide/
• Docker document
– https://docs.docker.com/
• MQTT Message Type and Flows
– http://blog.maxkit.com.tw/2014/02/mqttmessage-type-and-flows.html
• Celery on Docker Swarm
– https://github.com/Wei1234c/PyCon-JP-2016-
talk/blob/master/Celery%20on%20Docker%20Swarm%20-
%20PyCon%20JP%202016.md
• IoT as Brain
– https://github.com/Wei1234c/PyCon-JP-2016-
talk/blob/master/IoT%20as%20Brain%20-%20PyCon%20JP%202016.md

More Related Content

PDF
Building Distributed System with Celery on Docker Swarm
KEY
Django Celery
PDF
Celery with python
PDF
Advanced task management with Celery
PDF
Data processing with celery and rabbit mq
PDF
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...
PDF
Automation with Ansible and Containers
PDF
MySQL in your laptop
Building Distributed System with Celery on Docker Swarm
Django Celery
Celery with python
Advanced task management with Celery
Data processing with celery and rabbit mq
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...
Automation with Ansible and Containers
MySQL in your laptop

What's hot (20)

PDF
Script it
PDF
Apache Cassandra and Go
ODP
Introduction to Python Celery
PDF
Advanced VCL: how to use restart
PDF
Getting started with Ansible
PDF
DATABASE AUTOMATION with Thousands of database, monitoring and backup
PPTX
Learn you some Ansible for great good!
KEY
PyCon US 2012 - State of WSGI 2
PDF
Take control of your Jenkins jobs via job DSL.
PDF
Puppet Camp Charlotte 2015: Exporting Resources: There and Back Again
PPTX
Ansible fest Presentation slides
PDF
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
PPTX
Automate DBA Tasks With Ansible
PDF
“warpdrive”, making Python web application deployment magically easy.
PDF
[2C1] 아파치 피그를 위한 테즈 연산 엔진 개발하기 최종
PDF
Celery introduction
PPT
Ansible presentation
PDF
Zookeeper In Action
ODP
Puppet and Apache CloudStack
PDF
Using Ansible for Deploying to Cloud Environments
Script it
Apache Cassandra and Go
Introduction to Python Celery
Advanced VCL: how to use restart
Getting started with Ansible
DATABASE AUTOMATION with Thousands of database, monitoring and backup
Learn you some Ansible for great good!
PyCon US 2012 - State of WSGI 2
Take control of your Jenkins jobs via job DSL.
Puppet Camp Charlotte 2015: Exporting Resources: There and Back Again
Ansible fest Presentation slides
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
Automate DBA Tasks With Ansible
“warpdrive”, making Python web application deployment magically easy.
[2C1] 아파치 피그를 위한 테즈 연산 엔진 개발하기 최종
Celery introduction
Ansible presentation
Zookeeper In Action
Puppet and Apache CloudStack
Using Ansible for Deploying to Cloud Environments
Ad

Viewers also liked (12)

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

Similar to Building Distributed System with Celery on Docker Swarm - PyCon JP 2016 (20)

PPTX
Webinar: Development Swarm Cluster with Docker Compose V3
PDF
Development Swarm Cluster
PDF
Shifter: Containers in HPC Environments
PPTX
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
PDF
Docker 1.9 Workshop
PPTX
Docker
PPTX
Docker 101 - Nov 2016
PDF
Lean Drupal Repositories with Composer and Drush
PPTX
Intro docker and demo monitor on docker
KEY
Drupal PT Meetup Lisbon (December 2011)
PPTX
Docker 1.9 Feature Overview
PPTX
Docker DANS workshop
 
PDF
Docker 102 - Immutable Infrastructure
PDF
Practical Docker for OpenStack - NYC / PHL OpenStack meetup (4-23-2014)
PPTX
Docker San Francisco Meetup April 2015 - The Docker Orchestration Ecosystem o...
PPTX
Reactive summit 2020 microsoft orleans the easy way
PDF
30 Minutes to the Analytics Platform with Infrastructure as Code
PDF
What's New in Docker 1.12?
PPTX
Devoxx 2016 - Docker Nuts and Bolts
PDF
CCCEU15 run cloudstack in docker
Webinar: Development Swarm Cluster with Docker Compose V3
Development Swarm Cluster
Shifter: Containers in HPC Environments
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Docker 1.9 Workshop
Docker
Docker 101 - Nov 2016
Lean Drupal Repositories with Composer and Drush
Intro docker and demo monitor on docker
Drupal PT Meetup Lisbon (December 2011)
Docker 1.9 Feature Overview
Docker DANS workshop
 
Docker 102 - Immutable Infrastructure
Practical Docker for OpenStack - NYC / PHL OpenStack meetup (4-23-2014)
Docker San Francisco Meetup April 2015 - The Docker Orchestration Ecosystem o...
Reactive summit 2020 microsoft orleans the easy way
30 Minutes to the Analytics Platform with Infrastructure as Code
What's New in Docker 1.12?
Devoxx 2016 - Docker Nuts and Bolts
CCCEU15 run cloudstack in docker

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Big Data Technologies - Introduction.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
KodekX | Application Modernization Development
PDF
Empathic Computing: Creating Shared Understanding
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
The Rise and Fall of 3GPP – Time for a Sabbatical?
“AI and Expert System Decision Support & Business Intelligence Systems”
Big Data Technologies - Introduction.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Unlocking AI with Model Context Protocol (MCP)
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
Reach Out and Touch Someone: Haptics and Empathic Computing
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
KodekX | Application Modernization Development
Empathic Computing: Creating Shared Understanding
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Encapsulation_ Review paper, used for researhc scholars
Building Integrated photovoltaic BIPV_UPV.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Advanced methodologies resolving dimensionality complications for autism neur...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...

Building Distributed System with Celery on Docker Swarm - PyCon JP 2016