SlideShare a Scribd company logo
DISTRIBUTED MESSAGE QUEUE
DENGAN PYTHON CELERY DAN
RABBITMQ
Problem
1. Ada tugas yang membutuhkan waktu lama
2. Ada tugas yang bergantung pada pihak ketiga dan harus diulang ketika
gagal (e.g mengirim email verifikasi)
Eksperimen tahap pertama
1. Cron job
2. CLI Script
3. Lakukan dengan array
Hasil Eksperimen Tahap Pertama
1. Background-job susah di monitor
2. Background-job susah di scale
STANDING ON THE
SHOULDERS OF
GIANTS
Memakai message broker dan task queue library yang sudah ada
Eksperimen Tahap Kedua
Message broker
1. RabbitMQ
2. Beanstalk
3. Gearman
4. dll
1. Dokumentasinya bagus
2. Mudah dapat bahan referensi
dari google
3. OSS dan komersial support
distributed message queue dengan python celery dan rabbitmq
Messaging Concept
Producer, Consumer, Broker
Message Queue
P CBROKER
AMQP
Advanced Message Queueing Protocol
distributed message queue dengan python celery dan rabbitmq
Exchange types
distributed message queue dengan python celery dan rabbitmq
distributed message queue dengan python celery dan rabbitmq
Binding,
aturan yang digunakan Exchange untuk menentukan Route
ke Queue.
distributed message queue dengan python celery dan rabbitmq
●
Fast.
Highly available
Simple
Flexible
(consumer)
hello_world.py
from celery import Celery
app = Celery('print-hello-world', backend='rpc',
broker='amqp://')
@app.task
def print_hello(some_words='world'):
return 'hello {0}.'.format(some_words)
Starting Celery in terminal
celery worker -A hello_world
~Play demo video~
Producer
from hello_world import print_hello
add_new_message = print_hello.delay(some_words=’a message’)
Multi Celery Process
celery worker -A hello_world -n <process_name>
~Play demo video~
Second example ├── producer.py
├── proj
   ├── celery.py
   ├── __init__.py
   └── tasks.py
from celery import Celery
app = Celery('proj',
broker='amqp://',
backend='rpc://',
include=['proj.tasks'])
# Optional configuration
app.conf.update(
result_expires=3600,
)
if __name__ == '__main__':
app.start()
Proj/celery.py
from .celery import app
@app.task
def add(x, y):
return x + y
@app.task
def multiply(x, y):
return x * y
Proj/tasks.py
from proj.celery import app
if __name__ == '__main__':
add_result = []
multiply_result = []
for y in range(1, 50):
for x in range(1, 4):
add_result.append(app.send_task('proj.tasks.add', [x, x]))
multiply_result.append(app.send_task('proj.tasks.multiply', [x, x]))
for index, async_result in enumerate(add_result):
print("state" + str(index) + " = " + str(async_result.state))
print("state" + str(index) + " = " + str(async_result.result))
for index, async_result in enumerate(multiply_result):
print("state" + str(index) + " = " + str(async_result.state))
print("state" + str(index) + " = " + str(async_result.result))
producer.py
~Play demo video~

More Related Content

PDF
Computer network (8)
PDF
Yet another json rpc library (mole rpc)
PDF
Using SCTP with Scamper and Netty
PDF
TorqueBox at GNUnify 2012
PPT
Azure ServiceBus Queues and Topics
PDF
Microservices with Micronaut
PPTX
Chap3 clientsrvr
KEY
Betamax
Computer network (8)
Yet another json rpc library (mole rpc)
Using SCTP with Scamper and Netty
TorqueBox at GNUnify 2012
Azure ServiceBus Queues and Topics
Microservices with Micronaut
Chap3 clientsrvr
Betamax

What's hot (18)

PDF
GopherFest 2017 - Adding Context to NATS
PDF
The Ring programming language version 1.7 book - Part 15 of 196
PDF
The Ring programming language version 1.6 book - Part 14 of 189
DOCX
Creating qmgr and allowing remote authorization
PPTX
Messaging System with Spring Boot dan RabbitMQ
PDF
JBPM5 Community Trainning Baby Steps Examples
PPTX
Don't dump thread dumps
KEY
Distributed app development with nodejs and zeromq
PDF
ZeroMQ with NodeJS
PPTX
Groovy example in mule
PPTX
Simple groovy example in mule
PPTX
Groovy in Mule
PPT
Reactive programming with examples
PPT
Leveraging zeromq for node.js
PPTX
Thread safety
PPTX
Who Broke My Crypto
PDF
Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
PPTX
Building your First gRPC Service
GopherFest 2017 - Adding Context to NATS
The Ring programming language version 1.7 book - Part 15 of 196
The Ring programming language version 1.6 book - Part 14 of 189
Creating qmgr and allowing remote authorization
Messaging System with Spring Boot dan RabbitMQ
JBPM5 Community Trainning Baby Steps Examples
Don't dump thread dumps
Distributed app development with nodejs and zeromq
ZeroMQ with NodeJS
Groovy example in mule
Simple groovy example in mule
Groovy in Mule
Reactive programming with examples
Leveraging zeromq for node.js
Thread safety
Who Broke My Crypto
Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
Building your First gRPC Service
Ad

Similar to distributed message queue dengan python celery dan rabbitmq (20)

PPTX
Massaging the Pony: Message Queues and You
PDF
Chat app case study - xmpp vs SIP
PPTX
Message Queues & Offline Processing with PHP
PPT
Learn RabbitMQ with Python in 90mins
PPTX
Evolution of Big Data Messaging
PDF
Life in a Queue - Using Message Queue with django
PDF
HHM-3540: The IBM MQ Light API: From Developer Laptop to Enterprise Data Cen...
PDF
Preview of Apache Pulsar 2.5.0
PDF
Message Redelivery: An Unexpected Journey - Pulsar Summit SF 2022
PPTX
Spring batch showCase
PPTX
Message Broker System and RabbitMQ
PDF
Productivity Acceleration Tools for SOA Testers
PDF
The 1990s Called. They Want Their Code Back.
KEY
Keynote Puppet Camp San Francisco 2010
PPT
Azure Cloud Patterns
PDF
Celery: The Distributed Task Queue
PPTX
Micro-metrics to forecast performance tsunamis
PPT
Open Source XMPP for Cloud Services
PDF
Event driven-arch
ODP
Inter-Process/Task Communication With Message Queues
Massaging the Pony: Message Queues and You
Chat app case study - xmpp vs SIP
Message Queues & Offline Processing with PHP
Learn RabbitMQ with Python in 90mins
Evolution of Big Data Messaging
Life in a Queue - Using Message Queue with django
HHM-3540: The IBM MQ Light API: From Developer Laptop to Enterprise Data Cen...
Preview of Apache Pulsar 2.5.0
Message Redelivery: An Unexpected Journey - Pulsar Summit SF 2022
Spring batch showCase
Message Broker System and RabbitMQ
Productivity Acceleration Tools for SOA Testers
The 1990s Called. They Want Their Code Back.
Keynote Puppet Camp San Francisco 2010
Azure Cloud Patterns
Celery: The Distributed Task Queue
Micro-metrics to forecast performance tsunamis
Open Source XMPP for Cloud Services
Event driven-arch
Inter-Process/Task Communication With Message Queues
Ad

Recently uploaded (20)

PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Patient Appointment Booking in Odoo with online payment
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PDF
Cost to Outsource Software Development in 2025
PDF
iTop VPN Crack Latest Version Full Key 2025
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Autodesk AutoCAD Crack Free Download 2025
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Complete Guide to Website Development in Malaysia for SMEs
PPTX
assetexplorer- product-overview - presentation
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Why Generative AI is the Future of Content, Code & Creativity?
Operating system designcfffgfgggggggvggggggggg
Patient Appointment Booking in Odoo with online payment
CHAPTER 2 - PM Management and IT Context
Oracle Fusion HCM Cloud Demo for Beginners
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
Cost to Outsource Software Development in 2025
iTop VPN Crack Latest Version Full Key 2025
Reimagine Home Health with the Power of Agentic AI​
Autodesk AutoCAD Crack Free Download 2025
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
wealthsignaloriginal-com-DS-text-... (1).pdf
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Complete Guide to Website Development in Malaysia for SMEs
assetexplorer- product-overview - presentation
Digital Systems & Binary Numbers (comprehensive )
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx

distributed message queue dengan python celery dan rabbitmq