SlideShare a Scribd company logo
“RabbitMQ
     python and ruby staring
       at the looking glass”
               - an asynchronous tale -

 •   http://www.slideshare.net/hungryblank
 •   http://github.com/hungryblank/rabbitmq_rupy_2009

Paolo Negri                        @hungryblank
Resources

• http://www.slideshare.net/hungryblank
• http://github.com/hungryblank/rabbitmq_rupy_2009
About me
Time
       GNU/Linux - Dbs
                          Perl
         “systems”
                                   PHP
                          Python




                         Ruby
AMQP
Advanced Message Queuing Protocol

   • standard for high performance
     enterprise messaging
   • totally open
   • platform agnostic
   • interoperable
AMQP
     Why is it interesting?
“We use asynchronicity heavily in those 
cases where performance is an issue.
This is generally where we send content 
from one peer to another.  We send off 
methods as fast as possible without  
waiting for confirmations”
                  AMQP Specs [0.8 June 2006]
Summary

“AMQP as a case of asynchronous
protocol implementation in python
and ruby”
AMQP - Entities

Producer   msg



Consumer         msg
                       Broker


                       http://www.flickr.com/photos/17258892@N05/2588347668/
AMQP - Entities
Producer   msg

Producer   msg



                       Broker
Producer   msg


Consumer         msg

Consumer         msg




                       http://www.flickr.com/photos/17258892@N05/2588347668/
AMQP
     Implementations

• Producer/Consumer: libs available for
  python and ruby
• Broker no python or ruby
  implementation
• RabbitMQ is an implementation of
  AMQP Broker
• It’s opensource
• Written in Erlang
Erlang?
• general-purpose concurrent programming
  language designed by Ericsson
• first version written by J. Armstrong in 1986
• distributed
• fault tolerant
• soft real time
• high availability
Erlang?
Erlang's main strength is support for
concurrency
“Process communication is done via a
shared-nothing asynchronous message
passing:
every process has a “mailbox”, a queue
of messages sent by other processes,
that are not yet consumed” (Wikipedia)
+ Erlang


It’s messages all the way down
Async Python libs
            txAMQP

• “twisted AMQP”
• based on twisted python
• https://launchpad.net/txamqp
Async Python libs
               amqpev

• based on eventlet
• experimental, not ready for
  production
• http://bitbucket.org/edarc/amqpev
Async Python libs
                pika

• based on asyncio
• young but mantained by member of
  RabbitMQ core team
• http://github.com/tonyg/pika
Async Ruby libs
              amqp

• amqp gem
• based on EventMachine
• mature and widely used
• http://github.com/tmm1/amqp/
Async?

• Twisted Python
• Asyncio (python stdlib)
• eventlet (python)
• EventMachine (ruby)
Reactor Pattern

• Non blocking IO and lightweight
  concurrency
• eliminate the complexities of high-
  performance threaded network
  programming
synchronous          asynchronous
 process      Time   process

   code                 code



 network                                network
 operation              Free
                                        operation

use network          use network
 operation            operation
                                   Callback
   result               result


   Free
                        Free
Not only reactor


Some of the libs provide more i.e. eventlet
provides also coroutines
Python, pick one
              pika
• asyncio is part of python stdlib
• easy syntax
• developer member of RabbitMQ team
• fits on slides :-P
Code! Producer (ruby)
Consumer (ruby)
Behind the scenes

Publisher

  msg       Exchange   Queue   Consumer
What and where

     RabbitMQ
      (Erlang)              Producer
                          (ruby/python)

                 TCP/IP
                            Consumer
Exchange Queue
                          (ruby/python)
Producer (python)
Producer (python)




 TCP/IP connection
Producer (python)



       channel 1

 TCP/IP connection
Producer (python)



       channel 1

 TCP/IPchannel 2
         connection
Producer (python)



       channel 1

 TCP/IPchannel 2
         connection
       channel n
Producer (python)
Producer (python)
Producer (python)
Producer (python)
Producer (python)
Producer (python)
Producer (python)
Producer (python)
Producer (python)
Producer (python)
Producer (python)
Producer (python)
Publisher

  msg       Exchange   Queue   Consumer
Producer (python)
Publisher

  msg       Exchange   Queue     Consumer



             key based routing
Producer (python)
                       binding by key
Publisher

  msg       Exchange   Queue            Consumer



             key based routing
Consumer (python)
Things go wrong




If a consumer has a problem we might lose
          one or more messages
                   http://www.flickr.com/photos/danzen/2288625136/
ACKing consumer.rb
ACKing consumer.rb
ACKing consumer.rb
ACKing consumer.py
ACKing consumer.py
ACKing consumer.py
Achieved: decoupling

Publisher

  msg       Exchange   Queue   Consumer
Achieved: easy work
   load distribution
                               Consumer
Publisher

 msg A      Exchange   Queue   Consumer



                               Consumer
Achieved: easy work
   load distribution
                               Consumer
Publisher

            Exchange   Queue   Consumer
             msg A

                               Consumer
Achieved: easy work
   load distribution
                                     Consumer
Publisher

            Exchange   Queue msg A   Consumer



                                     Consumer
Achieved: easy work
   load distribution
                               msg A Consumer
Publisher

            Exchange   Queue         Consumer



                                     Consumer
prefetch?




http://www.flickr.com/photos/balakov/327431271
prefetch?


                      tcp ip
                      buffer

http://www.flickr.com/photos/balakov/327431271
prefetch - ruby
prefetch - ruby
prefetch - python
prefetch - python
More routing models

     multicasting
with fanout exchange
Fanout producer.rb
Fanout producer.rb
Fanout consumer.rb
Fanout consumer.rb
Fanout consumer.rb
Fanout consumer.rb
Fanout

                      Queue1   Cons1
Producer

msg A      Exchange   Queue2   Cons2


                      Queue3   Cons3
Fanout

                      Queue1   Cons1
Producer
           Exchange   Queue2   Cons2
            msg A

                      Queue3   Cons3
Fanout

                      msg A Queue1   Cons1
Producer
           Exchange   msg A Queue2   Cons2


                      msg A Queue3   Cons3
Fanout producer.py
Fanout producer.py
Fanout producer.py
Fanout consumer.py
Exchanges

• Direct - based on binding routing key
• Fanout - always to all bound queues
• Topic - pattern matching on routing key
Clustering
         RabbitMQ - node A   RabbitMQ - node B

TCP/IP                                           TCP/IP



         RabbitMQ - node C

TCP/IP
Plugins

• introduced with v 1.7.0
• Add functionalities to the broker
• makes a interesting first erlang project
Ecosystem


• 65 RabbitMQ / AMQP projects on github
• + more on bitbucket, and others
Sync?

• easier to add to web apps
• suitable for non performance critical
  messaging
• useful to build cli tools
Sync?

• celldee / bunny - Ruby (github)
• famoseagle / carrot - Ruby (github)
• py-amqplib - Python (http://barryp.org/software/py-amqplib/)
• ...
Distributed systems

• ezmobious / nanite - Ruby (github)
• ask / carrot - Python (github)
• ask / celery - Python (github)
• auser / poolparty - Erlang (github)
Real time web


• RabbitHub PubSubHubBub
• dansimpson / amqp-js (github)
Thank you!



    ?

More Related Content

PDF
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
PDF
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
PDF
PDF
Scaling applications with RabbitMQ at SunshinePHP
PDF
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
PPTX
High powered messaging with RabbitMQ
PDF
Dissecting the rabbit: RabbitMQ Internal Architecture
PDF
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Scaling applications with RabbitMQ at SunshinePHP
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
High powered messaging with RabbitMQ
Dissecting the rabbit: RabbitMQ Internal Architecture
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)

What's hot (20)

PPTX
Scaling application with RabbitMQ
PPTX
Spring RabbitMQ
PDF
RabbitMQ Data Ingestion
PDF
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
PDF
Messaging Standards and Systems - AMQP & RabbitMQ
PPTX
The RabbitMQ Message Broker
PDF
Messaging with RabbitMQ and AMQP
PDF
Introduction to AMQP Messaging with RabbitMQ
PDF
The Future of Messaging: RabbitMQ and AMQP
PDF
RabbitMQ Operations
PPTX
Spring RabbitMQ
PPTX
RabbitMQ Model and Some Example Applications
PDF
RabbitMQ fairly-indepth
PDF
Integrating PostgreSql with RabbitMQ
PDF
Distributed messaging with AMQP
PDF
Troubleshooting RabbitMQ and services that use it
PDF
XMPP & AMQP
PDF
Improvements in RabbitMQ
PDF
AMQP with RabbitMQ
PDF
Full Stack Bus with Javascript, RabbitMQ and Postal.js
Scaling application with RabbitMQ
Spring RabbitMQ
RabbitMQ Data Ingestion
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Messaging Standards and Systems - AMQP & RabbitMQ
The RabbitMQ Message Broker
Messaging with RabbitMQ and AMQP
Introduction to AMQP Messaging with RabbitMQ
The Future of Messaging: RabbitMQ and AMQP
RabbitMQ Operations
Spring RabbitMQ
RabbitMQ Model and Some Example Applications
RabbitMQ fairly-indepth
Integrating PostgreSql with RabbitMQ
Distributed messaging with AMQP
Troubleshooting RabbitMQ and services that use it
XMPP & AMQP
Improvements in RabbitMQ
AMQP with RabbitMQ
Full Stack Bus with Javascript, RabbitMQ and Postal.js
Ad

Viewers also liked (9)

KEY
Real time system_performance_mon
PDF
Rabbit mq簡介(上)
PPTX
Being Ready for Apache Kafka - Apache: Big Data Europe 2015
PDF
唯品会大数据实践 Sacc pub
PPTX
Apache kafka
PDF
Apache Kafka lessons learned @PAYBACK
PDF
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
PPTX
Introduction to Apache Kafka
PDF
Developing Real-Time Data Pipelines with Apache Kafka
Real time system_performance_mon
Rabbit mq簡介(上)
Being Ready for Apache Kafka - Apache: Big Data Europe 2015
唯品会大数据实践 Sacc pub
Apache kafka
Apache Kafka lessons learned @PAYBACK
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction to Apache Kafka
Developing Real-Time Data Pipelines with Apache Kafka
Ad

Similar to RabbitMQ with python and ruby RuPy 2009 (20)

PDF
Lindsay distributed geventzmq
PDF
Evented applications with RabbitMQ and CakePHP
PDF
Messaging with amqp and rabbitmq
PPT
Rabbit MQ introduction
PDF
Plone, rabbit mq and messaging that just works
PPTX
Message Broker System and RabbitMQ
KEY
High scale flavour
PDF
Messaging in the Cloud - AMQP, RabbitMQ and Spring
KEY
Message queueing
PDF
Life in a Queue - Using Message Queue with django
KEY
Message Queueing - by an MQ noob
ODP
Inter-Process/Task Communication With Message Queues
PDF
Rabbit mq messaginginthecloud_v_mworld_2010_ms
PDF
Rabbit mq messaginginthecloud_v_mworld_2010_ms
PDF
Erlang factory slides
PDF
Erlang factory slides
PDF
Messaging Standards and Systems - AMQP & RabbitMQ
ODP
The Art of Message Queues - TEKX
PDF
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Lindsay distributed geventzmq
Evented applications with RabbitMQ and CakePHP
Messaging with amqp and rabbitmq
Rabbit MQ introduction
Plone, rabbit mq and messaging that just works
Message Broker System and RabbitMQ
High scale flavour
Messaging in the Cloud - AMQP, RabbitMQ and Spring
Message queueing
Life in a Queue - Using Message Queue with django
Message Queueing - by an MQ noob
Inter-Process/Task Communication With Message Queues
Rabbit mq messaginginthecloud_v_mworld_2010_ms
Rabbit mq messaginginthecloud_v_mworld_2010_ms
Erlang factory slides
Erlang factory slides
Messaging Standards and Systems - AMQP & RabbitMQ
The Art of Message Queues - TEKX
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati

More from Paolo Negri (10)

PDF
Turning the web stack upside down rethinking how data flows through systems
PDF
AWS Lambda in infrastructure
PDF
Erlang introduction geek2geek Berlin
PDF
Erlang as a cloud citizen, a fractal approach to throughput
PDF
Getting real with erlang
PDF
Erlang factory 2011 london
PDF
Erlang factory SF 2011 "Erlang and the big switch in social games"
PDF
Scaling Social Games
PDF
Mongrel2, a short introduction
PDF
SimpleDb, an introduction
Turning the web stack upside down rethinking how data flows through systems
AWS Lambda in infrastructure
Erlang introduction geek2geek Berlin
Erlang as a cloud citizen, a fractal approach to throughput
Getting real with erlang
Erlang factory 2011 london
Erlang factory SF 2011 "Erlang and the big switch in social games"
Scaling Social Games
Mongrel2, a short introduction
SimpleDb, an introduction

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
A Presentation on Artificial Intelligence
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
KodekX | Application Modernization Development
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Network Security Unit 5.pdf for BCA BBA.
The AUB Centre for AI in Media Proposal.docx
A Presentation on Artificial Intelligence
Chapter 3 Spatial Domain Image Processing.pdf
Machine learning based COVID-19 study performance prediction
KodekX | Application Modernization Development
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Big Data Technologies - Introduction.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Reach Out and Touch Someone: Haptics and Empathic Computing
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Mobile App Security Testing_ A Comprehensive Guide.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
20250228 LYD VKU AI Blended-Learning.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

RabbitMQ with python and ruby RuPy 2009