SlideShare a Scribd company logo
Taste
    jeff@techparty.org
What‘s a MQ
What‘s a MQ




     queue
What‘s a MQ

message




          queue
What‘s a MQ

           message



Producer

                     queue
What‘s a MQ
                             Consumer

           message



Producer

                     queue
Why MQ


De-couple

Higher performance

Another IPC
Why rabbitMQ?
Based on Erlang

  Reliable

  Highly available

  Scalable

  portable

Implemented AMQP Standard and More

100% OpenSource
I have a log system
register                Login




logout




                    Log System




                                         DataBase
register                Login
                                         log = getLog(request)
                                         if log.type == ‘login’:
logout                                      # balabala .......
                                         if log.type == ‘register’:
                                            # balabala .......
                                         log.save()
                    Log System




                                             DataBase
register                Login
                                              log = getLog(request)
                                              if log.type == ‘login’:
     logout                                      # balabala .......
                                              if log.type == ‘register’:
                                                 # balabala .......
                                              log.save()
                         Log System




I need ...
1. better performance
2. cleaner code                                   DataBase


3. easier to test
4. ....
Step1. work with Queue
Step1. work with Queue
.......
log = getLog(request)
channel.publish(None,‘log-queue’,None,log)
Step1. work with Queue
.......
log = getLog(request)
channel.publish(None,‘log-queue’,None,log)




                                         def onLog(log):
                                           if log.type == ‘login’:
                                              # balabala
                                           if log.type == ‘logout’:
                                              # balabala
                                           log.save()
Step1. work with Queue
.......
log = getLog(request)
channel.publish(None,‘log-queue’,None,log)




                                         def onLog(log):
                                           if log.type == ‘login’:
                                              # balabala
                                           if log.type == ‘logout’:
                                              # balabala
                                           log.save()
Step1. work with Queue
.......
log = getLog(request)
channel.publish(None,‘log-queue’,None,log)




                                         def onLog(log):
                                           if log.type == ‘login’:
yep. performance better now                   # balabala
but. that                                  if log.type == ‘logout’:
codes still smell bad~~                       # balabala
                                           log.save()
step2. Split Queues



       login




      logout
step2. Split Queues
.......
log = getLog(request)
channel.publish(None,log.type,None,log)



                            login




                           logout
step2. Split Queues
.......                                   def onLog(loginlog):
log = getLog(request)                       # balabala
channel.publish(None,log.type,None,log)     loginlog.save()



                            login




                           logout
step2. Split Queues
.......                                   def onLog(loginlog):
log = getLog(request)                       # balabala
channel.publish(None,log.type,None,log)     loginlog.save()



                            login




                           logout

                                          def onLog(logoutlog):
                                            # balabala
                                            logoutlog.save()
step2. Split Queues
.......                                   def onLog(loginlog):
log = getLog(request)                       # balabala
channel.publish(None,log.type,None,log)     loginlog.save()



                            login




                           logout

                                          def onLog(logoutlog):
                                            # balabala
What’s that guy?
                                            logoutlog.save()
Say hi to Exchange
Direct Exchange
Fanout Exchange
Topic Exchange
step3. Share message


                     c#
        x
       login         c1
P

        x
                     c2
       logout
step3. Share message
.......
log = getLog(request)
channel.exchange_declare(log.type,‘fanout’)
channel.publish(log.type,’’,None,log)

                                              c#
                  x
                 login                        c1
      P

                  x
                                              c2
                 logout
step3. Share message
.......
log = getLog(request)                         def onLog(loginlog):
channel.exchange_declare(log.type,‘fanout’)     # balabala
channel.publish(log.type,’’,None,log)           loginlog.save()

                                                  c#
                  x
                 login                             c1
      P

                  x
                                                   c2
                 logout
step3. Share message
.......
log = getLog(request)                         def onLog(loginlog):
channel.exchange_declare(log.type,‘fanout’)     # balabala
channel.publish(log.type,’’,None,log)           loginlog.save()

                                                  c#
                  x
                 login                             c1
      P

                  x
                                                   c2
                 logout
                                              def onLog(logoutlog):
                                                # balabala
                                                logoutlog.save()
Performance test
     non-persist-mode
     100000 msg

                 en-queue      de-queue
     10,000/s

      7,500/s

      5,000/s

      2,500/s

          0/s
                128   512 1024 3072 10240
Performance tune


Parameters for multiple consumer toning:

  QOS

  consumer count

  autoAck?
clustering to scale
Start rabbit nodes:

rabbit1$ rabbitmq-server

rabbit2$ rabbitmq-server
clustering to scale
create cluster:
rabbit2$ rabbitmqctl stop_app
Stopping node rabbit@rabbit2 ...done.

rabbit2$ rabbitmqctl reset
Resetting node rabbit@rabbit2 ...done.

rabbit2$ rabbitmqctl cluster rabbit@rabbit1
Clustering node rabbit@rabbit2 with [rabbit@rabbit1] ...done.

rabbit2$ rabbitmqctl start_app
Starting node rabbit@rabbit2 ...done.
clustering to scale
Check it out:

rabbit1$ rabbitmqctl status
Status of node rabbit@rabbit1 ...
[...,
  {nodes,[{disc,[rabbit@rabbit1]},{ram,[rabbit@rabbit2]}]},
  {running_nodes,[rabbit@rabbit2,rabbit@rabbit1]}]
...done.
Highly Available
discuss ......
Thank you


http://jeffkit.info

http://twitter.com/jeff_kit

jeff@techparty.org

More Related Content

PPTX
Beyond java8
PDF
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
PDF
Scala101, first steps with Scala
DOCX
Exercícios Netbeans - Vera Cymbron
PPTX
Ian 20150116 java script oop
PDF
Hierarchical free monads and software design in fp
PDF
新浪微博开放平台Redis实战
PPTX
高性能No sql数据库redis
Beyond java8
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
Scala101, first steps with Scala
Exercícios Netbeans - Vera Cymbron
Ian 20150116 java script oop
Hierarchical free monads and software design in fp
新浪微博开放平台Redis实战
高性能No sql数据库redis

Viewers also liked (19)

PDF
Erlang scheduler
PDF
redis 适用场景与实现
PPTX
Redis介绍
PDF
Introduction to RabbitMQ | Meetup at Pivotal Labs
PDF
RabbitMQ Messaging
PDF
Integrating RabbitMQ with PHP
PDF
Scaling applications with RabbitMQ at SunshinePHP
PDF
RabbitMQ fairly-indepth
PDF
RabbitMQ Data Ingestion at Craft Conf
PDF
PDF
深入了解Redis
PDF
RabbitMQ Operations
PPTX
High powered messaging with RabbitMQ
PDF
RabbitMQ Data Ingestion
PDF
Redis for the Everyday Developer
PDF
Introduction to AMQP Messaging with RabbitMQ
KEY
Redis in Practice
PDF
Everything you always wanted to know about Redis but were afraid to ask
PDF
Dissecting the rabbit: RabbitMQ Internal Architecture
Erlang scheduler
redis 适用场景与实现
Redis介绍
Introduction to RabbitMQ | Meetup at Pivotal Labs
RabbitMQ Messaging
Integrating RabbitMQ with PHP
Scaling applications with RabbitMQ at SunshinePHP
RabbitMQ fairly-indepth
RabbitMQ Data Ingestion at Craft Conf
深入了解Redis
RabbitMQ Operations
High powered messaging with RabbitMQ
RabbitMQ Data Ingestion
Redis for the Everyday Developer
Introduction to AMQP Messaging with RabbitMQ
Redis in Practice
Everything you always wanted to know about Redis but were afraid to ask
Dissecting the rabbit: RabbitMQ Internal Architecture
Ad

Similar to Taste Rabbitmq (13)

PDF
Java Logging discussion Log4j,Slf4j
PDF
Functional python
PDF
World of Logging
PDF
Riak Meetup Stockholm 1/11/2012
PDF
Zope component architechture
PDF
Porting to Python 3
ODP
Logging with Logback in Scala
PDF
Python bootcamp - C4Dlab, University of Nairobi
PPT
Logging with Logback in Scala
PDF
Getting modern with logging via log4perl
KEY
Python 3
PDF
Jvm internals
KEY
Clojure Intro
Java Logging discussion Log4j,Slf4j
Functional python
World of Logging
Riak Meetup Stockholm 1/11/2012
Zope component architechture
Porting to Python 3
Logging with Logback in Scala
Python bootcamp - C4Dlab, University of Nairobi
Logging with Logback in Scala
Getting modern with logging via log4perl
Python 3
Jvm internals
Clojure Intro
Ad

More from jeff kit (11)

PDF
构建稳健的iOS推送服务
KEY
冲浪 Object-c
KEY
给Geek们的音乐课
KEY
漫游iOS开发指南
PDF
Scala jeff
PPT
原创音乐会
PDF
杯具是怎样练成的
PDF
PDF
PDF
Autoforms
PDF
Brief intro of Dropbox
构建稳健的iOS推送服务
冲浪 Object-c
给Geek们的音乐课
漫游iOS开发指南
Scala jeff
原创音乐会
杯具是怎样练成的
Autoforms
Brief intro of Dropbox

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation theory and applications.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
KodekX | Application Modernization Development
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
DOCX
The AUB Centre for AI in Media Proposal.docx
MYSQL Presentation for SQL database connectivity
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Cloud computing and distributed systems.
Encapsulation theory and applications.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Building Integrated photovoltaic BIPV_UPV.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Chapter 3 Spatial Domain Image Processing.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
KodekX | Application Modernization Development
NewMind AI Weekly Chronicles - August'25 Week I
20250228 LYD VKU AI Blended-Learning.pptx
Electronic commerce courselecture one. Pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
NewMind AI Monthly Chronicles - July 2025
Diabetes mellitus diagnosis method based random forest with bat algorithm
The AUB Centre for AI in Media Proposal.docx

Taste Rabbitmq

Editor's Notes