SlideShare une entreprise Scribd logo
1  sur  117
Télécharger pour lire hors ligne
Scaling Web Apps
                               With RabbitMQ
                                   Álvaro Videla | Liip AG


                                  HighLoad ++ 2011


Thursday, September 29, 2011
Who?


Thursday, September 29, 2011
About Me

                    •      Software Development at Liip AG

                    •      Writing “RabbitMQ in Action” for Manning

                    •      Blog: http://videlalvaro.github.com/

                    •      Twitter: @old_sound




Thursday, September 29, 2011
Why Do I need
                                RabbitMQ?


Thursday, September 29, 2011
The User



Thursday, September 29, 2011
I don’t want to wait
                               till your app resizes
                                     my image!


Thursday, September 29, 2011
The Product Owner



Thursday, September 29, 2011
Can we also notify the
                    user friends when she
                    uploads a new image?


Thursday, September 29, 2011
Can we also notify the
                    user friends when she
                    uploads a new image?
      I forgot to mention we need it for tomorrow…

Thursday, September 29, 2011
The Sysadmin



Thursday, September 29, 2011
Dumb! You’re delivering
                    full size images!
                 The bandwidth bill has
                         tripled!

Thursday, September 29, 2011
Dumb! You’re delivering
                    full size images!
                 The bandwidth bill has
                         tripled!
                               We need this fixed for yesterday!
Thursday, September 29, 2011
The Developer in the
                           other team


Thursday, September 29, 2011
I need to call your PHP
                   stuff but from Python


Thursday, September 29, 2011
I need to call your PHP
                   stuff but from Python

                               And also Java starting next week
Thursday, September 29, 2011
You



Thursday, September 29, 2011
FML!

Thursday, September 29, 2011
Is there a solution?



Thursday, September 29, 2011
RabbitMQ & AMQP



Thursday, September 29, 2011
AMQP



Thursday, September 29, 2011
AMQP
                    • Advanced Message Queuing Protocol
                    • Suits Interoperability
                    • Completely Open Protocol
                    • Binary Protocol
                    • AMQP Model
                    • AMQP Wire Format
Thursday, September 29, 2011
AMQP Model

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

Thursday, September 29, 2011
AMQP Wire Protocol


                    • Functional Layer
                    • Transport Layer


Thursday, September 29, 2011
Message Flow




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



Thursday, September 29, 2011
Exchange Types

                    • Fanout
                    • Direct
                    • Topic


Thursday, September 29, 2011
http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.0/html/Messaging_Tutorial/sect-Messaging_Tutorial-Initial_Concepts-
                                                                      Fanout_Exchange.html




Thursday, September 29, 2011
http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.0/html/Messaging_Tutorial/sect-Messaging_Tutorial-Initial_Concepts-
                                                                       Direct_Exchange.html




Thursday, September 29, 2011
http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.0/html/Messaging_Tutorial/sect-Messaging_Tutorial-Initial_Concepts-
                                                                       Topic_Exchange.html




Thursday, September 29, 2011
Usage Scenarios




Thursday, September 29, 2011
Usage Scenarios

                    • Batch Processing




Thursday, September 29, 2011
Usage Scenarios

                    • Batch Processing
                    • Image Uploading




Thursday, September 29, 2011
Usage Scenarios

                    • Batch Processing
                    • Image Uploading
                    • Distributed Logging



Thursday, September 29, 2011
Scenario


                               Batch Processing



Thursday, September 29, 2011
Requirements




Thursday, September 29, 2011
Requirements

                    • Generate XML




Thursday, September 29, 2011
Requirements

                    • Generate XML
                    • Distribution Over a Cluster



Thursday, September 29, 2011
Requirements

                    • Generate XML
                    • Distribution Over a Cluster
                    • Elasticity - Add/Remove new workers


Thursday, September 29, 2011
Requirements

                    • Generate XML
                    • Distribution Over a Cluster
                    • Elasticity - Add/Remove new workers
                    • No Code Changes

Thursday, September 29, 2011
Design




Thursday, September 29, 2011
Publisher Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);

                 $msg = new AMQPMessage($video_info,
                            array('content_type' => 'text/plain',
                                   'delivery_mode' => 2));

                 $channel->basic_publish($msg, 'video-desc-ex');

                 $channel->close();
                 $conn->close();




Thursday, September 29, 2011
Publisher Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);

                 $msg = new AMQPMessage($video_info,
                            array('content_type' => 'text/plain',
                                   'delivery_mode' => 2));

                 $channel->basic_publish($msg, 'video-desc-ex');

                 $channel->close();
                 $conn->close();




Thursday, September 29, 2011
Publisher Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);

                 $msg = new AMQPMessage($video_info,
                            array('content_type' => 'text/plain',
                                   'delivery_mode' => 2));

                 $channel->basic_publish($msg, 'video-desc-ex');

                 $channel->close();
                 $conn->close();




Thursday, September 29, 2011
Publisher Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);

                 $msg = new AMQPMessage($video_info,
                            array('content_type' => 'text/plain',
                                   'delivery_mode' => 2));

                 $channel->basic_publish($msg, 'video-desc-ex');

                 $channel->close();
                 $conn->close();




Thursday, September 29, 2011
Publisher Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);

                 $msg = new AMQPMessage($video_info,
                            array('content_type' => 'text/plain',
                                   'delivery_mode' => 2));

                 $channel->basic_publish($msg, 'video-desc-ex');

                 $channel->close();
                 $conn->close();




Thursday, September 29, 2011
Publisher Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);

                 $msg = new AMQPMessage($video_info,
                            array('content_type' => 'text/plain',
                                   'delivery_mode' => 2));

                 $channel->basic_publish($msg, 'video-desc-ex');

                 $channel->close();
                 $conn->close();




Thursday, September 29, 2011
Consumer Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);
                 $channel->queue_declare('video-desc-queue', false, true,
                              false, false);
                 $channel->queue_bind('video-desc-queue', 'video-desc-ex');

                 $channel->basic_consume('video-desc-queue', $consumer_tag,
                              false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                     $channel->wait();
                 }



Thursday, September 29, 2011
Consumer Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);
                 $channel->queue_declare('video-desc-queue', false, true,
                              false, false);
                 $channel->queue_bind('video-desc-queue', 'video-desc-ex');

                 $channel->basic_consume('video-desc-queue', $consumer_tag,
                              false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                     $channel->wait();
                 }



Thursday, September 29, 2011
Consumer Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);
                 $channel->queue_declare('video-desc-queue', false, true,
                              false, false);
                 $channel->queue_bind('video-desc-queue', 'video-desc-ex');

                 $channel->basic_consume('video-desc-queue', $consumer_tag,
                              false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                     $channel->wait();
                 }



Thursday, September 29, 2011
Consumer Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);
                 $channel->queue_declare('video-desc-queue', false, true,
                              false, false);
                 $channel->queue_bind('video-desc-queue', 'video-desc-ex');

                 $channel->basic_consume('video-desc-queue', $consumer_tag,
                              false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                     $channel->wait();
                 }



Thursday, September 29, 2011
Consumer Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);
                 $channel->queue_declare('video-desc-queue', false, true,
                              false, false);
                 $channel->queue_bind('video-desc-queue', 'video-desc-ex');

                 $channel->basic_consume('video-desc-queue', $consumer_tag,
                              false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                     $channel->wait();
                 }



Thursday, September 29, 2011
Consumer Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);
                 $channel->queue_declare('video-desc-queue', false, true,
                              false, false);
                 $channel->queue_bind('video-desc-queue', 'video-desc-ex');

                 $channel->basic_consume('video-desc-queue', $consumer_tag,
                              false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                     $channel->wait();
                 }



Thursday, September 29, 2011
Consumer Code
                 $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
                 $channel = $conn->channel();

                 $channel->exchange_declare('video-desc-ex', 'direct', false,
                              true, false);
                 $channel->queue_declare('video-desc-queue', false, true,
                              false, false);
                 $channel->queue_bind('video-desc-queue', 'video-desc-ex');

                 $channel->basic_consume('video-desc-queue', $consumer_tag,
                              false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                     $channel->wait();
                 }



Thursday, September 29, 2011
Scenario


                               Upload Pictures



Thursday, September 29, 2011
Requirements




Thursday, September 29, 2011
Requirements
                    • Upload Picture




Thursday, September 29, 2011
Requirements
                    • Upload Picture
                    • Reward User




Thursday, September 29, 2011
Requirements
                    • Upload Picture
                    • Reward User
                    • Notify User Friends



Thursday, September 29, 2011
Requirements
                    • Upload Picture
                    • Reward User
                    • Notify User Friends
                    • Resize Picture


Thursday, September 29, 2011
Requirements
                    • Upload Picture
                    • Reward User
                    • Notify User Friends
                    • Resize Picture
                    • No Code Changes

Thursday, September 29, 2011
Design




Thursday, September 29, 2011
Design




Thursday, September 29, 2011
Design




Thursday, September 29, 2011
Publisher Code
                 $channel->exchange_declare('upload-pictures', 'fanout', false,
                 true, false);

                 $metadata = json_encode(array(
                   'image_id' => $image_id,
                   'user_id' => $user_id,
                   ‘image_path' => $image_path));

                 $msg = new AMQPMessage($metadata, array('content_type' =>
                 'application/json',   'delivery_mode' => 2));

                 $channel->basic_publish($msg, 'upload-pictures');




Thursday, September 29, 2011
Publisher Code
                 $channel->exchange_declare('upload-pictures', 'fanout', false,
                 true, false);

                 $metadata = json_encode(array(
                   'image_id' => $image_id,
                   'user_id' => $user_id,
                   ‘image_path' => $image_path));

                 $msg = new AMQPMessage($metadata, array('content_type' =>
                 'application/json',   'delivery_mode' => 2));

                 $channel->basic_publish($msg, 'upload-pictures');




Thursday, September 29, 2011
Publisher Code
                 $channel->exchange_declare('upload-pictures', 'fanout', false,
                 true, false);

                 $metadata = json_encode(array(
                   'image_id' => $image_id,
                   'user_id' => $user_id,
                   ‘image_path' => $image_path));

                 $msg = new AMQPMessage($metadata, array('content_type' =>
                 'application/json',   'delivery_mode' => 2));

                 $channel->basic_publish($msg, 'upload-pictures');




Thursday, September 29, 2011
Publisher Code
                 $channel->exchange_declare('upload-pictures', 'fanout', false,
                 true, false);

                 $metadata = json_encode(array(
                   'image_id' => $image_id,
                   'user_id' => $user_id,
                   ‘image_path' => $image_path));

                 $msg = new AMQPMessage($metadata, array('content_type' =>
                 'application/json',   'delivery_mode' => 2));

                 $channel->basic_publish($msg, 'upload-pictures');




Thursday, September 29, 2011
Publisher Code
                 $channel->exchange_declare('upload-pictures', 'fanout', false,
                 true, false);

                 $metadata = json_encode(array(
                   'image_id' => $image_id,
                   'user_id' => $user_id,
                   ‘image_path' => $image_path));

                 $msg = new AMQPMessage($metadata, array('content_type' =>
                 'application/json',   'delivery_mode' => 2));

                 $channel->basic_publish($msg, 'upload-pictures');




Thursday, September 29, 2011
Consumer Code
                 $channel->exchange_declare('upload-pictures', 'fanout',
                             false, true, false);

                 $channel->queue_declare('resize-picture', false, true,
                             false, false);

                 $channel->queue_bind('resize-picture', 'upload-pictures');

                 $channel->basic_consume('resize-picture', $consumer_tag,
                             false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                   $channel->wait();
                 }




Thursday, September 29, 2011
Consumer Code
                 $channel->exchange_declare('upload-pictures', 'fanout',
                             false, true, false);

                 $channel->queue_declare('resize-picture', false, true,
                             false, false);

                 $channel->queue_bind('resize-picture', 'upload-pictures');

                 $channel->basic_consume('resize-picture', $consumer_tag,
                             false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                   $channel->wait();
                 }




Thursday, September 29, 2011
Consumer Code
                 $channel->exchange_declare('upload-pictures', 'fanout',
                             false, true, false);

                 $channel->queue_declare('resize-picture', false, true,
                             false, false);

                 $channel->queue_bind('resize-picture', 'upload-pictures');

                 $channel->basic_consume('resize-picture', $consumer_tag,
                             false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                   $channel->wait();
                 }




Thursday, September 29, 2011
Consumer Code
                 $channel->exchange_declare('upload-pictures', 'fanout',
                             false, true, false);

                 $channel->queue_declare('resize-picture', false, true,
                             false, false);

                 $channel->queue_bind('resize-picture', 'upload-pictures');

                 $channel->basic_consume('resize-picture', $consumer_tag,
                             false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                   $channel->wait();
                 }




Thursday, September 29, 2011
Consumer Code
                 $channel->exchange_declare('upload-pictures', 'fanout',
                             false, true, false);

                 $channel->queue_declare('resize-picture', false, true,
                             false, false);

                 $channel->queue_bind('resize-picture', 'upload-pictures');

                 $channel->basic_consume('resize-picture', $consumer_tag,
                             false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                   $channel->wait();
                 }




Thursday, September 29, 2011
Consumer Code
                 $channel->exchange_declare('upload-pictures', 'fanout',
                             false, true, false);

                 $channel->queue_declare('resize-picture', false, true,
                             false, false);

                 $channel->queue_bind('resize-picture', 'upload-pictures');

                 $channel->basic_consume('resize-picture', $consumer_tag,
                             false, false, false, false, $consumer);

                 while(count($channel->callbacks)) {
                   $channel->wait();
                 }




Thursday, September 29, 2011
Consumer Code
                 $consumer = function($msg){

                      $meta = json_decode($msg->body, true);
                 	
                      resize_picture($meta['image_id'], $meta['image_path']);
                 	
                      $msg->delivery_info['channel']->
                        basic_ack($msg->delivery_info['delivery_tag']);
                 };




Thursday, September 29, 2011
Consumer Code
                 $consumer = function($msg){

                      $meta = json_decode($msg->body, true);
                 	
                      resize_picture($meta['image_id'], $meta['image_path']);
                 	
                      $msg->delivery_info['channel']->
                        basic_ack($msg->delivery_info['delivery_tag']);
                 };




Thursday, September 29, 2011
Consumer Code
                 $consumer = function($msg){

                      $meta = json_decode($msg->body, true);
                 	
                      resize_picture($meta['image_id'], $meta['image_path']);
                 	
                      $msg->delivery_info['channel']->
                        basic_ack($msg->delivery_info['delivery_tag']);
                 };




Thursday, September 29, 2011
Consumer Code
                 $consumer = function($msg){

                      $meta = json_decode($msg->body, true);
                 	
                      resize_picture($meta['image_id'], $meta['image_path']);
                 	
                      $msg->delivery_info['channel']->
                        basic_ack($msg->delivery_info['delivery_tag']);
                 };




Thursday, September 29, 2011
Consumer Code
                 $consumer = function($msg){

                      $meta = json_decode($msg->body, true);
                 	
                      resize_picture($meta['image_id'], $meta['image_path']);
                 	
                      $msg->delivery_info['channel']->
                        basic_ack($msg->delivery_info['delivery_tag']);
                 };




Thursday, September 29, 2011
Scenario


                           Distributed Logging



Thursday, September 29, 2011
Requirements




Thursday, September 29, 2011
Requirements
                    • Several Web Servers




Thursday, September 29, 2011
Requirements
                    • Several Web Servers
                    • Logic Separated by Module/Action




Thursday, September 29, 2011
Requirements
                    • Several Web Servers
                    • Logic Separated by Module/Action
                    • Several Log Levels:



Thursday, September 29, 2011
Requirements
                    • Several Web Servers
                    • Logic Separated by Module/Action
                    • Several Log Levels:
                     • Info, Warning, Error


Thursday, September 29, 2011
Requirements
                    • Several Web Servers
                    • Logic Separated by Module/Action
                    • Several Log Levels:
                     • Info, Warning, Error
                    • Add/Remove log listeners at will

Thursday, September 29, 2011
Design




Thursday, September 29, 2011
Design




Thursday, September 29, 2011
Design




Thursday, September 29, 2011
Design




Thursday, September 29, 2011
Design




Thursday, September 29, 2011
Publisher Code
                 $channel->exchange_declare('logs', 'topic', false,
                               true, false);

                 $msg = new AMQPMessage('some log message',
                               array('content_type' => 'text/plain'));

                 $channel->basic_publish($msg, 'logs',
                               'server1.user.profile.info');




Thursday, September 29, 2011
Publisher Code
                 $channel->exchange_declare('logs', 'topic', false,
                               true, false);

                 $msg = new AMQPMessage('some log message',
                               array('content_type' => 'text/plain'));

                 $channel->basic_publish($msg, 'logs',
                               server1.user.profile.info');




Thursday, September 29, 2011
Publisher Code
                 $channel->exchange_declare('logs', 'topic', false,
                               true, false);

                 $msg = new AMQPMessage('some log message',
                               array('content_type' => 'text/plain'));

                 $channel->basic_publish($msg, 'logs',
                               server1.user.profile.info');




Thursday, September 29, 2011
Publisher Code
                 $channel->exchange_declare('logs', 'topic', false,
                               true, false);

                 $msg = new AMQPMessage('some log message',
                               array('content_type' => 'text/plain'));

                 $channel->basic_publish($msg, 'logs',
                               server1.user.profile.info');




Thursday, September 29, 2011
Consumer Code

                                Get messages sent by host:

                                        server1




Thursday, September 29, 2011
Consumer Code

                 $channel->exchange_declare('logs', 'topic', false,
                               true, false);

                 $channel->queue_declare('server1-logs', false, true,
                               false, false);

                 $channel->queue_bind('server1-logs', 'logs', 'server1.#');




Thursday, September 29, 2011
Consumer Code

                 $channel->exchange_declare('logs', 'topic', false,
                               true, false);

                 $channel->queue_declare('server1-logs', false, true,
                               false, false);

                 $channel->queue_bind('server1-logs', 'logs', 'server1.#');




Thursday, September 29, 2011
Consumer Code

                 $channel->exchange_declare('logs', 'topic', false,
                               true, false);

                 $channel->queue_declare('server1-logs', false, true,
                               false, false);

                 $channel->queue_bind('server1-logs', 'logs', 'server1.#');




Thursday, September 29, 2011
Consumer Code

                 $channel->exchange_declare('logs', 'topic', false,
                               true, false);

                 $channel->queue_declare('server1-logs', false, true,
                               false, false);

                 $channel->queue_bind('server1-logs', 'logs', 'server1.#');




Thursday, September 29, 2011
Consumer Code


                                Get all error messages




Thursday, September 29, 2011
Consumer Code

                 $channel->exchange_declare('logs', 'topic', false,
                               true, false);

                 $channel->queue_declare('error-logs', false, true,
                               false, false);

                 $channel->queue_bind('error-logs', 'logs', '#.error');




Thursday, September 29, 2011
Consumer Code

                 $channel->exchange_declare('logs', 'topic', false,
                               true, false);

                 $channel->queue_declare('error-logs', false, true,
                               false, false);

                 $channel->queue_bind('error-logs', 'logs', '#.error');




Thursday, September 29, 2011
Consumer Code

                 $channel->exchange_declare('logs', 'topic', false,
                               true, false);

                 $channel->queue_declare('error-logs', false, true,
                               false, false);

                 $channel->queue_bind('error-logs', 'logs', '#.error');




Thursday, September 29, 2011
Consumer Code

                 $channel->exchange_declare('logs', 'topic', false,
                               true, false);

                 $channel->queue_declare('error-logs', false, true,
                               false, false);

                 $channel->queue_bind('error-logs', 'logs', '#.error');




Thursday, September 29, 2011
Why RabbitMQ?



Thursday, September 29, 2011
RabbitMQ

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

Thursday, September 29, 2011
Features

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

Thursday, September 29, 2011
Client Libraries

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



Thursday, September 29, 2011
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




Thursday, September 29, 2011
One Setup for HA




Thursday, September 29, 2011
Conclusion




Thursday, September 29, 2011
Conclusion

                    • Flexibility




Thursday, September 29, 2011
Conclusion

                    • Flexibility
                    • Scalability



Thursday, September 29, 2011
Conclusion

                    • Flexibility
                    • Scalability
                    • Interoperability


Thursday, September 29, 2011
Conclusion

                    • Flexibility
                    • Scalability
                    • Interoperability
                    • Reduce Ops

Thursday, September 29, 2011
Questions?



Thursday, September 29, 2011
Thanks!



Thursday, September 29, 2011

Contenu connexe

Similaire à Scaling websites with RabbitMQ A(rlvaro Videla)

TAG Recruiting Atlanta - 3 Phases of Mobile Recruiting Strategy
TAG Recruiting Atlanta - 3 Phases of Mobile Recruiting StrategyTAG Recruiting Atlanta - 3 Phases of Mobile Recruiting Strategy
TAG Recruiting Atlanta - 3 Phases of Mobile Recruiting Strategy
Kane Cochran
 
Html5 episode 2
Html5 episode 2Html5 episode 2
Html5 episode 2
Eric Smith
 
Continuous Deployment at Disqus (Pylons Minicon)
Continuous Deployment at Disqus (Pylons Minicon)Continuous Deployment at Disqus (Pylons Minicon)
Continuous Deployment at Disqus (Pylons Minicon)
zeeg
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JS
Caridy Patino
 
NodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time WebNodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time Web
Jakub Nesetril
 

Similaire à Scaling websites with RabbitMQ A(rlvaro Videla) (20)

clrh56
clrh56clrh56
clrh56
 
Teletrain liever geen mensen om service te geven
Teletrain liever geen mensen om service te gevenTeletrain liever geen mensen om service te geven
Teletrain liever geen mensen om service te geven
 
TAG Recruiting Atlanta - 3 Phases of Mobile Recruiting Strategy
TAG Recruiting Atlanta - 3 Phases of Mobile Recruiting StrategyTAG Recruiting Atlanta - 3 Phases of Mobile Recruiting Strategy
TAG Recruiting Atlanta - 3 Phases of Mobile Recruiting Strategy
 
Distribute the workload, PHPTek, Amsterdam, 2011
Distribute the workload, PHPTek, Amsterdam, 2011Distribute the workload, PHPTek, Amsterdam, 2011
Distribute the workload, PHPTek, Amsterdam, 2011
 
Html5 episode 2
Html5 episode 2Html5 episode 2
Html5 episode 2
 
Titanium setup
Titanium setupTitanium setup
Titanium setup
 
Distribute the workload, PHP Barcelona 2011
Distribute the workload, PHP Barcelona 2011Distribute the workload, PHP Barcelona 2011
Distribute the workload, PHP Barcelona 2011
 
開発者のためのiPhone⇔Androidアプリ移植のポイント
開発者のためのiPhone⇔Androidアプリ移植のポイント開発者のためのiPhone⇔Androidアプリ移植のポイント
開発者のためのiPhone⇔Androidアプリ移植のポイント
 
Continuous Deployment at Disqus (Pylons Minicon)
Continuous Deployment at Disqus (Pylons Minicon)Continuous Deployment at Disqus (Pylons Minicon)
Continuous Deployment at Disqus (Pylons Minicon)
 
How to Install, Use, and Customize Drush
How to Install, Use, and Customize DrushHow to Install, Use, and Customize Drush
How to Install, Use, and Customize Drush
 
Node Stream
Node StreamNode Stream
Node Stream
 
Smartphones: The 21st Century Teacher Toolbox
Smartphones: The 21st Century Teacher ToolboxSmartphones: The 21st Century Teacher Toolbox
Smartphones: The 21st Century Teacher Toolbox
 
Acceptance & Integration Testing With Behat (PBC11)
Acceptance & Integration Testing With Behat (PBC11)Acceptance & Integration Testing With Behat (PBC11)
Acceptance & Integration Testing With Behat (PBC11)
 
Non-Relational Databases & Key/Value Stores
Non-Relational Databases & Key/Value StoresNon-Relational Databases & Key/Value Stores
Non-Relational Databases & Key/Value Stores
 
Caridy patino - node-js
Caridy patino - node-jsCaridy patino - node-js
Caridy patino - node-js
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JS
 
NodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time WebNodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time Web
 
Глеб Калинин. Инструменты прототипирования
Глеб Калинин. Инструменты прототипированияГлеб Калинин. Инструменты прототипирования
Глеб Калинин. Инструменты прототипирования
 
web标准化交流会上海站bobby分享
web标准化交流会上海站bobby分享web标准化交流会上海站bobby分享
web标准化交流会上海站bobby分享
 
web标准化交流会bobby分享
web标准化交流会bobby分享web标准化交流会bobby分享
web标准化交流会bobby分享
 

Plus de Ontico

Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Ontico
 

Plus de Ontico (20)

One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
 
Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Масштабируя DNS / Артем Гавриченков (Qrator Labs)Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Масштабируя DNS / Артем Гавриченков (Qrator Labs)
 
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
 
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
 
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
 
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
 
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
 
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
 
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
 
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
 
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
 
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
 
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
 
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
 
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
 
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
 
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
 
100500 способов кэширования в Oracle Database или как достичь максимальной ск...
100500 способов кэширования в Oracle Database или как достичь максимальной ск...100500 способов кэширования в Oracle Database или как достичь максимальной ск...
100500 способов кэширования в Oracle Database или как достичь максимальной ск...
 
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
 
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

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...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Scaling websites with RabbitMQ A(rlvaro Videla)

  • 1. Scaling Web Apps With RabbitMQ Álvaro Videla | Liip AG HighLoad ++ 2011 Thursday, September 29, 2011
  • 3. About Me • Software Development at Liip AG • Writing “RabbitMQ in Action” for Manning • Blog: http://videlalvaro.github.com/ • Twitter: @old_sound Thursday, September 29, 2011
  • 4. Why Do I need RabbitMQ? Thursday, September 29, 2011
  • 6. I don’t want to wait till your app resizes my image! Thursday, September 29, 2011
  • 7. The Product Owner Thursday, September 29, 2011
  • 8. Can we also notify the user friends when she uploads a new image? Thursday, September 29, 2011
  • 9. Can we also notify the user friends when she uploads a new image? I forgot to mention we need it for tomorrow… Thursday, September 29, 2011
  • 11. Dumb! You’re delivering full size images! The bandwidth bill has tripled! Thursday, September 29, 2011
  • 12. Dumb! You’re delivering full size images! The bandwidth bill has tripled! We need this fixed for yesterday! Thursday, September 29, 2011
  • 13. The Developer in the other team Thursday, September 29, 2011
  • 14. I need to call your PHP stuff but from Python Thursday, September 29, 2011
  • 15. I need to call your PHP stuff but from Python And also Java starting next week Thursday, September 29, 2011
  • 18. Is there a solution? Thursday, September 29, 2011
  • 19. RabbitMQ & AMQP Thursday, September 29, 2011
  • 21. AMQP • Advanced Message Queuing Protocol • Suits Interoperability • Completely Open Protocol • Binary Protocol • AMQP Model • AMQP Wire Format Thursday, September 29, 2011
  • 22. AMQP Model • Exchanges • Message Queues • Bindings • Rules for binding them Thursday, September 29, 2011
  • 23. AMQP Wire Protocol • Functional Layer • Transport Layer Thursday, September 29, 2011
  • 24. Message Flow http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.0/html/Messaging_Tutorial/chap-Messaging_Tutorial-Initial_Concepts.html Thursday, September 29, 2011
  • 25. Exchange Types • Fanout • Direct • Topic Thursday, September 29, 2011
  • 30. Usage Scenarios • Batch Processing Thursday, September 29, 2011
  • 31. Usage Scenarios • Batch Processing • Image Uploading Thursday, September 29, 2011
  • 32. Usage Scenarios • Batch Processing • Image Uploading • Distributed Logging Thursday, September 29, 2011
  • 33. Scenario Batch Processing Thursday, September 29, 2011
  • 35. Requirements • Generate XML Thursday, September 29, 2011
  • 36. Requirements • Generate XML • Distribution Over a Cluster Thursday, September 29, 2011
  • 37. Requirements • Generate XML • Distribution Over a Cluster • Elasticity - Add/Remove new workers Thursday, September 29, 2011
  • 38. Requirements • Generate XML • Distribution Over a Cluster • Elasticity - Add/Remove new workers • No Code Changes Thursday, September 29, 2011
  • 40. Publisher Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $msg = new AMQPMessage($video_info, array('content_type' => 'text/plain', 'delivery_mode' => 2)); $channel->basic_publish($msg, 'video-desc-ex'); $channel->close(); $conn->close(); Thursday, September 29, 2011
  • 41. Publisher Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $msg = new AMQPMessage($video_info, array('content_type' => 'text/plain', 'delivery_mode' => 2)); $channel->basic_publish($msg, 'video-desc-ex'); $channel->close(); $conn->close(); Thursday, September 29, 2011
  • 42. Publisher Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $msg = new AMQPMessage($video_info, array('content_type' => 'text/plain', 'delivery_mode' => 2)); $channel->basic_publish($msg, 'video-desc-ex'); $channel->close(); $conn->close(); Thursday, September 29, 2011
  • 43. Publisher Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $msg = new AMQPMessage($video_info, array('content_type' => 'text/plain', 'delivery_mode' => 2)); $channel->basic_publish($msg, 'video-desc-ex'); $channel->close(); $conn->close(); Thursday, September 29, 2011
  • 44. Publisher Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $msg = new AMQPMessage($video_info, array('content_type' => 'text/plain', 'delivery_mode' => 2)); $channel->basic_publish($msg, 'video-desc-ex'); $channel->close(); $conn->close(); Thursday, September 29, 2011
  • 45. Publisher Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $msg = new AMQPMessage($video_info, array('content_type' => 'text/plain', 'delivery_mode' => 2)); $channel->basic_publish($msg, 'video-desc-ex'); $channel->close(); $conn->close(); Thursday, September 29, 2011
  • 46. Consumer Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $channel->queue_declare('video-desc-queue', false, true, false, false); $channel->queue_bind('video-desc-queue', 'video-desc-ex'); $channel->basic_consume('video-desc-queue', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 47. Consumer Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $channel->queue_declare('video-desc-queue', false, true, false, false); $channel->queue_bind('video-desc-queue', 'video-desc-ex'); $channel->basic_consume('video-desc-queue', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 48. Consumer Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $channel->queue_declare('video-desc-queue', false, true, false, false); $channel->queue_bind('video-desc-queue', 'video-desc-ex'); $channel->basic_consume('video-desc-queue', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 49. Consumer Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $channel->queue_declare('video-desc-queue', false, true, false, false); $channel->queue_bind('video-desc-queue', 'video-desc-ex'); $channel->basic_consume('video-desc-queue', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 50. Consumer Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $channel->queue_declare('video-desc-queue', false, true, false, false); $channel->queue_bind('video-desc-queue', 'video-desc-ex'); $channel->basic_consume('video-desc-queue', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 51. Consumer Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $channel->queue_declare('video-desc-queue', false, true, false, false); $channel->queue_bind('video-desc-queue', 'video-desc-ex'); $channel->basic_consume('video-desc-queue', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 52. Consumer Code $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); $channel = $conn->channel(); $channel->exchange_declare('video-desc-ex', 'direct', false, true, false); $channel->queue_declare('video-desc-queue', false, true, false, false); $channel->queue_bind('video-desc-queue', 'video-desc-ex'); $channel->basic_consume('video-desc-queue', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 53. Scenario Upload Pictures Thursday, September 29, 2011
  • 55. Requirements • Upload Picture Thursday, September 29, 2011
  • 56. Requirements • Upload Picture • Reward User Thursday, September 29, 2011
  • 57. Requirements • Upload Picture • Reward User • Notify User Friends Thursday, September 29, 2011
  • 58. Requirements • Upload Picture • Reward User • Notify User Friends • Resize Picture Thursday, September 29, 2011
  • 59. Requirements • Upload Picture • Reward User • Notify User Friends • Resize Picture • No Code Changes Thursday, September 29, 2011
  • 63. Publisher Code $channel->exchange_declare('upload-pictures', 'fanout', false, true, false); $metadata = json_encode(array( 'image_id' => $image_id, 'user_id' => $user_id, ‘image_path' => $image_path)); $msg = new AMQPMessage($metadata, array('content_type' => 'application/json', 'delivery_mode' => 2)); $channel->basic_publish($msg, 'upload-pictures'); Thursday, September 29, 2011
  • 64. Publisher Code $channel->exchange_declare('upload-pictures', 'fanout', false, true, false); $metadata = json_encode(array( 'image_id' => $image_id, 'user_id' => $user_id, ‘image_path' => $image_path)); $msg = new AMQPMessage($metadata, array('content_type' => 'application/json', 'delivery_mode' => 2)); $channel->basic_publish($msg, 'upload-pictures'); Thursday, September 29, 2011
  • 65. Publisher Code $channel->exchange_declare('upload-pictures', 'fanout', false, true, false); $metadata = json_encode(array( 'image_id' => $image_id, 'user_id' => $user_id, ‘image_path' => $image_path)); $msg = new AMQPMessage($metadata, array('content_type' => 'application/json', 'delivery_mode' => 2)); $channel->basic_publish($msg, 'upload-pictures'); Thursday, September 29, 2011
  • 66. Publisher Code $channel->exchange_declare('upload-pictures', 'fanout', false, true, false); $metadata = json_encode(array( 'image_id' => $image_id, 'user_id' => $user_id, ‘image_path' => $image_path)); $msg = new AMQPMessage($metadata, array('content_type' => 'application/json', 'delivery_mode' => 2)); $channel->basic_publish($msg, 'upload-pictures'); Thursday, September 29, 2011
  • 67. Publisher Code $channel->exchange_declare('upload-pictures', 'fanout', false, true, false); $metadata = json_encode(array( 'image_id' => $image_id, 'user_id' => $user_id, ‘image_path' => $image_path)); $msg = new AMQPMessage($metadata, array('content_type' => 'application/json', 'delivery_mode' => 2)); $channel->basic_publish($msg, 'upload-pictures'); Thursday, September 29, 2011
  • 68. Consumer Code $channel->exchange_declare('upload-pictures', 'fanout', false, true, false); $channel->queue_declare('resize-picture', false, true, false, false); $channel->queue_bind('resize-picture', 'upload-pictures'); $channel->basic_consume('resize-picture', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 69. Consumer Code $channel->exchange_declare('upload-pictures', 'fanout', false, true, false); $channel->queue_declare('resize-picture', false, true, false, false); $channel->queue_bind('resize-picture', 'upload-pictures'); $channel->basic_consume('resize-picture', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 70. Consumer Code $channel->exchange_declare('upload-pictures', 'fanout', false, true, false); $channel->queue_declare('resize-picture', false, true, false, false); $channel->queue_bind('resize-picture', 'upload-pictures'); $channel->basic_consume('resize-picture', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 71. Consumer Code $channel->exchange_declare('upload-pictures', 'fanout', false, true, false); $channel->queue_declare('resize-picture', false, true, false, false); $channel->queue_bind('resize-picture', 'upload-pictures'); $channel->basic_consume('resize-picture', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 72. Consumer Code $channel->exchange_declare('upload-pictures', 'fanout', false, true, false); $channel->queue_declare('resize-picture', false, true, false, false); $channel->queue_bind('resize-picture', 'upload-pictures'); $channel->basic_consume('resize-picture', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 73. Consumer Code $channel->exchange_declare('upload-pictures', 'fanout', false, true, false); $channel->queue_declare('resize-picture', false, true, false, false); $channel->queue_bind('resize-picture', 'upload-pictures'); $channel->basic_consume('resize-picture', $consumer_tag, false, false, false, false, $consumer); while(count($channel->callbacks)) { $channel->wait(); } Thursday, September 29, 2011
  • 74. Consumer Code $consumer = function($msg){ $meta = json_decode($msg->body, true); resize_picture($meta['image_id'], $meta['image_path']); $msg->delivery_info['channel']-> basic_ack($msg->delivery_info['delivery_tag']); }; Thursday, September 29, 2011
  • 75. Consumer Code $consumer = function($msg){ $meta = json_decode($msg->body, true); resize_picture($meta['image_id'], $meta['image_path']); $msg->delivery_info['channel']-> basic_ack($msg->delivery_info['delivery_tag']); }; Thursday, September 29, 2011
  • 76. Consumer Code $consumer = function($msg){ $meta = json_decode($msg->body, true); resize_picture($meta['image_id'], $meta['image_path']); $msg->delivery_info['channel']-> basic_ack($msg->delivery_info['delivery_tag']); }; Thursday, September 29, 2011
  • 77. Consumer Code $consumer = function($msg){ $meta = json_decode($msg->body, true); resize_picture($meta['image_id'], $meta['image_path']); $msg->delivery_info['channel']-> basic_ack($msg->delivery_info['delivery_tag']); }; Thursday, September 29, 2011
  • 78. Consumer Code $consumer = function($msg){ $meta = json_decode($msg->body, true); resize_picture($meta['image_id'], $meta['image_path']); $msg->delivery_info['channel']-> basic_ack($msg->delivery_info['delivery_tag']); }; Thursday, September 29, 2011
  • 79. Scenario Distributed Logging Thursday, September 29, 2011
  • 81. Requirements • Several Web Servers Thursday, September 29, 2011
  • 82. Requirements • Several Web Servers • Logic Separated by Module/Action Thursday, September 29, 2011
  • 83. Requirements • Several Web Servers • Logic Separated by Module/Action • Several Log Levels: Thursday, September 29, 2011
  • 84. Requirements • Several Web Servers • Logic Separated by Module/Action • Several Log Levels: • Info, Warning, Error Thursday, September 29, 2011
  • 85. Requirements • Several Web Servers • Logic Separated by Module/Action • Several Log Levels: • Info, Warning, Error • Add/Remove log listeners at will Thursday, September 29, 2011
  • 91. Publisher Code $channel->exchange_declare('logs', 'topic', false, true, false); $msg = new AMQPMessage('some log message', array('content_type' => 'text/plain')); $channel->basic_publish($msg, 'logs', 'server1.user.profile.info'); Thursday, September 29, 2011
  • 92. Publisher Code $channel->exchange_declare('logs', 'topic', false, true, false); $msg = new AMQPMessage('some log message', array('content_type' => 'text/plain')); $channel->basic_publish($msg, 'logs', server1.user.profile.info'); Thursday, September 29, 2011
  • 93. Publisher Code $channel->exchange_declare('logs', 'topic', false, true, false); $msg = new AMQPMessage('some log message', array('content_type' => 'text/plain')); $channel->basic_publish($msg, 'logs', server1.user.profile.info'); Thursday, September 29, 2011
  • 94. Publisher Code $channel->exchange_declare('logs', 'topic', false, true, false); $msg = new AMQPMessage('some log message', array('content_type' => 'text/plain')); $channel->basic_publish($msg, 'logs', server1.user.profile.info'); Thursday, September 29, 2011
  • 95. Consumer Code Get messages sent by host: server1 Thursday, September 29, 2011
  • 96. Consumer Code $channel->exchange_declare('logs', 'topic', false, true, false); $channel->queue_declare('server1-logs', false, true, false, false); $channel->queue_bind('server1-logs', 'logs', 'server1.#'); Thursday, September 29, 2011
  • 97. Consumer Code $channel->exchange_declare('logs', 'topic', false, true, false); $channel->queue_declare('server1-logs', false, true, false, false); $channel->queue_bind('server1-logs', 'logs', 'server1.#'); Thursday, September 29, 2011
  • 98. Consumer Code $channel->exchange_declare('logs', 'topic', false, true, false); $channel->queue_declare('server1-logs', false, true, false, false); $channel->queue_bind('server1-logs', 'logs', 'server1.#'); Thursday, September 29, 2011
  • 99. Consumer Code $channel->exchange_declare('logs', 'topic', false, true, false); $channel->queue_declare('server1-logs', false, true, false, false); $channel->queue_bind('server1-logs', 'logs', 'server1.#'); Thursday, September 29, 2011
  • 100. Consumer Code Get all error messages Thursday, September 29, 2011
  • 101. Consumer Code $channel->exchange_declare('logs', 'topic', false, true, false); $channel->queue_declare('error-logs', false, true, false, false); $channel->queue_bind('error-logs', 'logs', '#.error'); Thursday, September 29, 2011
  • 102. Consumer Code $channel->exchange_declare('logs', 'topic', false, true, false); $channel->queue_declare('error-logs', false, true, false, false); $channel->queue_bind('error-logs', 'logs', '#.error'); Thursday, September 29, 2011
  • 103. Consumer Code $channel->exchange_declare('logs', 'topic', false, true, false); $channel->queue_declare('error-logs', false, true, false, false); $channel->queue_bind('error-logs', 'logs', '#.error'); Thursday, September 29, 2011
  • 104. Consumer Code $channel->exchange_declare('logs', 'topic', false, true, false); $channel->queue_declare('error-logs', false, true, false, false); $channel->queue_bind('error-logs', 'logs', '#.error'); Thursday, September 29, 2011
  • 106. RabbitMQ • Enterprise Messaging System • Open Source MPL • Written in Erlang/OTP • Commercial Support Thursday, September 29, 2011
  • 107. Features • Reliable and High Scalable • Easy To install • Easy To Cluster • Runs on: Windows, Solaris, Linux, OSX • AMQP 0.8 - 0.9.1 Thursday, September 29, 2011
  • 108. Client Libraries • Java • .NET/C# • Erlang • Ruby, Python, PHP, Perl, AS3, Lisp, Scala, Clojure, Haskell Thursday, September 29, 2011
  • 109. 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 Thursday, September 29, 2011
  • 110. One Setup for HA Thursday, September 29, 2011
  • 112. Conclusion • Flexibility Thursday, September 29, 2011
  • 113. Conclusion • Flexibility • Scalability Thursday, September 29, 2011
  • 114. Conclusion • Flexibility • Scalability • Interoperability Thursday, September 29, 2011
  • 115. Conclusion • Flexibility • Scalability • Interoperability • Reduce Ops Thursday, September 29, 2011