SlideShare a Scribd company logo
1 of 71
Download to read offline
Integrating
                  RabbitMQ with PHP
                                    Álvaro Videla


                          June 2010 - IPC Spring Edition - Berlin


Wednesday, June 2, 2010
About Me

               • Lead Developer at TheNetCircle.com
               • Writing “RabbitMQ in Action” for Manning
               • Twitter: @old_sound
               • Blog: http://obvioushints.blogspot.com/

Wednesday, June 2, 2010
The
                          Interoperability
                              Problem


Wednesday, June 2, 2010
The Problem



          Movie
         Publisher




Wednesday, June 2, 2010
The Problem



          Movie           New
                          Movie
         Publisher




Wednesday, June 2, 2010
The Problem
                                  Java   WebService
                                           XML




          Movie           New
                          Movie
         Publisher




Wednesday, June 2, 2010
The Problem
                                  Java   WebService
                                           XML



                                  C++      Image
                                         Thumbnail
                                         Generator

          Movie           New
                          Movie
         Publisher




Wednesday, June 2, 2010
The Problem
                                  Java   WebService
                                           XML



                                  C++      Image
                                         Thumbnail
                                         Generator

          Movie           New
                          Movie
         Publisher                PHP    PHP Cache
                                         Generator




Wednesday, June 2, 2010
The Problem
                                  Java   WebService
                                           XML



                                  C++      Image
                                         Thumbnail
                                         Generator

          Movie           New
                          Movie
         Publisher                PHP    PHP Cache
                                         Generator



                                  PHP      Static
                                           HTML
                                          Publisher




Wednesday, June 2, 2010
The Problem
                                  Java   WebService
                                           XML



                                  C++      Image
                                         Thumbnail
                                         Generator

          Movie           New
                          Movie
         Publisher                PHP    PHP Cache
                                         Generator



                                  PHP      Static
                                           HTML
                                          Publisher



                                  C++     Trailers
                                         Generator




Wednesday, June 2, 2010
The Problem   SYSTEMS

                             WebService
                               XML



                               Image
                             Thumbnail
                             Generator




                             PHP Cache
                             Generator



                               Static
                               HTML
                              Publisher



                              Trailers
                             Generator




Wednesday, June 2, 2010
The Problem           SYSTEMS

                                     WebService
                                       XML
    Written In Different Languages
                                       Image
                                     Thumbnail
                                     Generator




                                     PHP Cache
                                     Generator



                                       Static
                                       HTML
                                      Publisher



                                      Trailers
                                     Generator




Wednesday, June 2, 2010
The Problem           SYSTEMS

                                     WebService
                                       XML
    Written In Different Languages
                                       Image
     Different Operating Systems     Thumbnail
                                     Generator




                                     PHP Cache
                                     Generator



                                       Static
                                       HTML
                                      Publisher



                                      Trailers
                                     Generator




Wednesday, June 2, 2010
The Problem           SYSTEMS

                                     WebService
                                       XML
    Written In Different Languages
                                       Image
     Different Operating Systems     Thumbnail
                                     Generator



    Written By Different People      PHP Cache
                                     Generator



                                       Static
                                       HTML
                                      Publisher



                                      Trailers
                                     Generator




Wednesday, June 2, 2010
The Problem            SYSTEMS

                                      WebService
                                        XML
    Written In Different Languages
                                        Image
     Different Operating Systems      Thumbnail
                                      Generator



    Written By Different People       PHP Cache
                                      Generator
     They Need To Share Information
                                        Static
                                        HTML
                                       Publisher



                                       Trailers
                                      Generator




Wednesday, June 2, 2010
The Problem            SYSTEMS

                                      WebService
                                        XML
    Written In Different Languages
                                        Image
     Different Operating Systems      Thumbnail
                                      Generator



    Written By Different People       PHP Cache
                                      Generator
     They Need To Share Information
                                        Static
     They Need Real Time Data           HTML
                                       Publisher



                                       Trailers
                                      Generator




Wednesday, June 2, 2010
The Problem            SYSTEMS

                                      WebService
                                        XML
    Written In Different Languages
                                        Image
     Different Operating Systems      Thumbnail
                                      Generator



    Written By Different People       PHP Cache
                                      Generator
     They Need To Share Information
                                        Static
     They Need Real Time Data           HTML
                                       Publisher


     They Need To Scale                Trailers
                                      Generator




Wednesday, June 2, 2010
Is There a Solution?



Wednesday, June 2, 2010
AMQP
                             and
                          RabbitMQ


Wednesday, June 2, 2010
AMQP
                   • Advanced Message Queuing Protocol
                   • Suits Interoperability
                   • Completely Open Protocol
                   • Binary Protocol
                   • AMQP Model
                   • AMQP Wire Format
Wednesday, June 2, 2010
AMQP Model

                   • Exchanges
                   • Message Queues
                   • Bindings
                   • Rules for binding them

Wednesday, June 2, 2010
AMQP Wire Protocol


                   • Functional Layer
                   • Transport Layer


Wednesday, June 2, 2010
Message Flow




             http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.0/html/Messaging_Tutorial/chap-Messaging_Tutorial-Initial_Concepts.html




Wednesday, June 2, 2010
Exchange Types

                   • Fanout
                   • Direct
                   • Topic


Wednesday, June 2, 2010
Default Exchanges

                   • amqp.fanout
                   • amqp.direct
                   • amqp.topic


Wednesday, June 2, 2010
http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.0/html/Messaging_Tutorial/sect-Messaging_Tutorial-Initial_Concepts-
                                                                      Fanout_Exchange.html




Wednesday, June 2, 2010
http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.0/html/Messaging_Tutorial/sect-Messaging_Tutorial-Initial_Concepts-
                                                                       Direct_Exchange.html




Wednesday, June 2, 2010
http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.0/html/Messaging_Tutorial/sect-Messaging_Tutorial-Initial_Concepts-
                                                                       Topic_Exchange.html




Wednesday, June 2, 2010
Sample usage




Wednesday, June 2, 2010
Sample Usage II




Wednesday, June 2, 2010
Other Advantages
                   • Fire and Forget
                   • Stop/Start consumers safely (no need for
                          last processed id)
                   • No need for Cronjobs locks
                   • Load Distribution
                   • Transactions
Wednesday, June 2, 2010
RabbitMQ



Wednesday, June 2, 2010
RabbitMQ

                   • Enterprise Messaging System
                   • Open Source MPL
                   • Written in Erlang/OTP
                   • Commercial Support

Wednesday, June 2, 2010
Features

                   • Reliable and High Scalable
                   • Easy To install
                   • Easy To Cluster
                   • Runs on: Windows, Solaris, Linux, OSX
                   • AMQP 0.8

Wednesday, June 2, 2010
Client Libraries

                   • Java
                   • .NET/C#
                   • Erlang
                   • Ruby, Python, PHP, Perl, AS3, Lisp, Scala

Wednesday, June 2, 2010
Docs/Support

                   •      http://www.rabbitmq.com/documentation.html

                   •      http://dev.rabbitmq.com/wiki/

                   •      #rabbitmq at irc.freenode.net

                   •      http://www.rabbitmq.com/email-archive.html




Wednesday, June 2, 2010
Our Setup:
                          Publishers - 28 PHP Frontend Machines




                                    2 PHP Machines
                               running 24 consumers each

Wednesday, June 2, 2010
Our Setup

                   • Deployed in mid 2009
                   • Reduced site SPOF
                   • 500.000+ messages routed a day (and
                          increasing)
                   • Very easy to install/deploy

Wednesday, June 2, 2010
Easy To Install?



Wednesday, June 2, 2010
Easy To Install?




                           http://gist.github.com/334219
Wednesday, June 2, 2010
PHP Integration

                   • http://code.google.com/p/php-amqplib/
                   • http://code.google.com/p/php-amqp/
                   • http://code.google.com/p/php-rabbit/


Wednesday, June 2, 2010
Show me the code!



Wednesday, June 2, 2010
RabbitMQ “Hello World!”




Wednesday, June 2, 2010
AMQP Producer




Wednesday, June 2, 2010
AMQP Producer




Wednesday, June 2, 2010
AMQP Producer




Wednesday, June 2, 2010
AMQP Producer




Wednesday, June 2, 2010
AMQP Producer




Wednesday, June 2, 2010
AMQP Consumer




Wednesday, June 2, 2010
AMQP Consumer




Wednesday, June 2, 2010
AMQP Consumer




Wednesday, June 2, 2010
AMQP Consumer




Wednesday, June 2, 2010
AMQP Consumer




Wednesday, June 2, 2010
AMQP Consumer




Wednesday, June 2, 2010
AMQP Consumer




Wednesday, June 2, 2010
RabbitMQ RPC Example




Wednesday, June 2, 2010
RPC Client




Wednesday, June 2, 2010
RPC Client




Wednesday, June 2, 2010
RPC Client




Wednesday, June 2, 2010
RPC Client




Wednesday, June 2, 2010
RPC Client




Wednesday, June 2, 2010
RPC Server




Wednesday, June 2, 2010
RPC Server




Wednesday, June 2, 2010
RPC Server




Wednesday, June 2, 2010
RPC Server




Wednesday, June 2, 2010
RPC Server




Wednesday, June 2, 2010
RPC Server




Wednesday, June 2, 2010
RPC Server




Wednesday, June 2, 2010
Resources:

                   •      http://www.rabbitmq.com/

                   •      https://www.amqp.org/confluence/display/AMQP/About+AMQP

                   •      http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.0/html/
                          Messaging_Tutorial/index.html

                   •      http://wso2.org/library/articles/using-axis2-c-amqp-transport-part-i

                   •      http://www.skaag.net/2010/03/12/rabbitmq-for-beginners/

                   •      http://github.com/bkw/php-amqp




Wednesday, June 2, 2010
Questions?



Wednesday, June 2, 2010
Thanks!
                                     Alvaro Videla
                             http://twitter.com/old_sound
                          http://www.slideshare.net/old_sound




Wednesday, June 2, 2010

More Related Content

Viewers also liked

Компания мечты своими руками, Уфа,
Компания мечты своими руками, Уфа, Компания мечты своими руками, Уфа,
Компания мечты своими руками, Уфа,
Alexander Byndyu
 
Карьера в IT, 27-02-2013
Карьера в IT, 27-02-2013Карьера в IT, 27-02-2013
Карьера в IT, 27-02-2013
Alexander Byndyu
 
高性能No sql数据库redis
高性能No sql数据库redis高性能No sql数据库redis
高性能No sql数据库redis
paitoubing
 
非同期データ更新のためにメッセージキューを導入した(い)話
非同期データ更新のためにメッセージキューを導入した(い)話非同期データ更新のためにメッセージキューを導入した(い)話
非同期データ更新のためにメッセージキューを導入した(い)話
Takaaki Hirano
 

Viewers also liked (20)

Компания мечты своими руками, Уфа,
Компания мечты своими руками, Уфа, Компания мечты своими руками, Уфа,
Компания мечты своими руками, Уфа,
 
Карьера в IT, 27-02-2013
Карьера в IT, 27-02-2013Карьера в IT, 27-02-2013
Карьера в IT, 27-02-2013
 
Антон Довгоброд: Highload и очереди задач на примере PHP + Gearman + Yii2
Антон Довгоброд: Highload и очереди задач на примере PHP + Gearman + Yii2Антон Довгоброд: Highload и очереди задач на примере PHP + Gearman + Yii2
Антон Довгоброд: Highload и очереди задач на примере PHP + Gearman + Yii2
 
新浪微博开放平台Redis实战
新浪微博开放平台Redis实战新浪微博开放平台Redis实战
新浪微博开放平台Redis实战
 
Taste Rabbitmq
Taste RabbitmqTaste Rabbitmq
Taste Rabbitmq
 
What RabbitMQ Can Do For You (Nomad PHP May 2014)
What RabbitMQ Can Do For You (Nomad PHP May 2014)What RabbitMQ Can Do For You (Nomad PHP May 2014)
What RabbitMQ Can Do For You (Nomad PHP May 2014)
 
高性能No sql数据库redis
高性能No sql数据库redis高性能No sql数据库redis
高性能No sql数据库redis
 
redis 适用场景与实现
redis 适用场景与实现redis 适用场景与实现
redis 适用场景与实现
 
Redis介绍
Redis介绍Redis介绍
Redis介绍
 
Introduction to RabbitMQ | Meetup at Pivotal Labs
Introduction to RabbitMQ | Meetup at Pivotal LabsIntroduction to RabbitMQ | Meetup at Pivotal Labs
Introduction to RabbitMQ | Meetup at Pivotal Labs
 
RabbitMQ Messaging
RabbitMQ MessagingRabbitMQ Messaging
RabbitMQ Messaging
 
WSO2 Message Broker - Product Overview
WSO2 Message Broker - Product OverviewWSO2 Message Broker - Product Overview
WSO2 Message Broker - Product Overview
 
Theres a rabbit on my symfony
Theres a rabbit on my symfonyTheres a rabbit on my symfony
Theres a rabbit on my symfony
 
Scaling applications with RabbitMQ at SunshinePHP
Scaling applications with RabbitMQ   at SunshinePHPScaling applications with RabbitMQ   at SunshinePHP
Scaling applications with RabbitMQ at SunshinePHP
 
RabbitMQ fairly-indepth
RabbitMQ fairly-indepthRabbitMQ fairly-indepth
RabbitMQ fairly-indepth
 
RabbitMQ Data Ingestion at Craft Conf
RabbitMQ Data Ingestion at Craft ConfRabbitMQ Data Ingestion at Craft Conf
RabbitMQ Data Ingestion at Craft Conf
 
RabbitMQ
RabbitMQRabbitMQ
RabbitMQ
 
非同期データ更新のためにメッセージキューを導入した(い)話
非同期データ更新のためにメッセージキューを導入した(い)話非同期データ更新のためにメッセージキューを導入した(い)話
非同期データ更新のためにメッセージキューを導入した(い)話
 
深入了解Redis
深入了解Redis深入了解Redis
深入了解Redis
 
The RabbitMQ Message Broker
The RabbitMQ Message BrokerThe RabbitMQ Message Broker
The RabbitMQ Message Broker
 

More from Alvaro Videla

Rabbitmq Boot System
Rabbitmq Boot SystemRabbitmq Boot System
Rabbitmq Boot System
Alvaro Videla
 

More from Alvaro Videla (19)

Improvements in RabbitMQ
Improvements in RabbitMQImprovements in RabbitMQ
Improvements in RabbitMQ
 
Data Migration at Scale with RabbitMQ and Spring Integration
Data Migration at Scale with RabbitMQ and Spring IntegrationData Migration at Scale with RabbitMQ and Spring Integration
Data Migration at Scale with RabbitMQ and Spring Integration
 
Unit Test + Functional Programming = Love
Unit Test + Functional Programming = LoveUnit Test + Functional Programming = Love
Unit Test + Functional Programming = Love
 
RabbitMQ Data Ingestion
RabbitMQ Data IngestionRabbitMQ Data Ingestion
RabbitMQ Data Ingestion
 
Dissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal ArchitectureDissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal Architecture
 
Writing testable code
Writing testable codeWriting testable code
Writing testable code
 
RabbitMQ Hands On
RabbitMQ Hands OnRabbitMQ Hands On
RabbitMQ Hands On
 
Rabbitmq Boot System
Rabbitmq Boot SystemRabbitmq Boot System
Rabbitmq Boot System
 
Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry Bootcamp
 
Cloud Messaging With Cloud Foundry
Cloud Messaging With Cloud FoundryCloud Messaging With Cloud Foundry
Cloud Messaging With Cloud Foundry
 
Taming the rabbit
Taming the rabbitTaming the rabbit
Taming the rabbit
 
Vertx
VertxVertx
Vertx
 
Código Fácil De Testear
Código Fácil De TestearCódigo Fácil De Testear
Código Fácil De Testear
 
Desacoplando aplicaciones
Desacoplando aplicacionesDesacoplando aplicaciones
Desacoplando aplicaciones
 
Messaging patterns
Messaging patternsMessaging patterns
Messaging patterns
 
Scaling Web Apps With RabbitMQ - Erlang Factory Lite
Scaling Web Apps With RabbitMQ - Erlang Factory LiteScaling Web Apps With RabbitMQ - Erlang Factory Lite
Scaling Web Apps With RabbitMQ - Erlang Factory Lite
 
Scaling webappswithrabbitmq
Scaling webappswithrabbitmqScaling webappswithrabbitmq
Scaling webappswithrabbitmq
 
Integrating Erlang with PHP
Integrating Erlang with PHPIntegrating Erlang with PHP
Integrating Erlang with PHP
 
Debugging and Profiling Symfony Apps
Debugging and Profiling Symfony AppsDebugging and Profiling Symfony Apps
Debugging and Profiling Symfony Apps
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 

Integrating RabbitMQ with PHP