SlideShare a Scribd company logo
1 of 38
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

Viewers also liked

redis 适用场景与实现
redis 适用场景与实现redis 适用场景与实现
redis 适用场景与实现iammutex
 
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 LabsAlvaro Videla
 
Integrating RabbitMQ with PHP
Integrating RabbitMQ with PHPIntegrating RabbitMQ with PHP
Integrating RabbitMQ with PHPAlvaro Videla
 
Scaling applications with RabbitMQ at SunshinePHP
Scaling applications with RabbitMQ   at SunshinePHPScaling applications with RabbitMQ   at SunshinePHP
Scaling applications with RabbitMQ at SunshinePHPAlvaro Videla
 
RabbitMQ fairly-indepth
RabbitMQ fairly-indepthRabbitMQ fairly-indepth
RabbitMQ fairly-indepthWee Keat Chin
 
RabbitMQ Data Ingestion at Craft Conf
RabbitMQ Data Ingestion at Craft ConfRabbitMQ Data Ingestion at Craft Conf
RabbitMQ Data Ingestion at Craft ConfAlvaro Videla
 
深入了解Redis
深入了解Redis深入了解Redis
深入了解Redisiammutex
 
High powered messaging with RabbitMQ
High powered messaging with RabbitMQHigh powered messaging with RabbitMQ
High powered messaging with RabbitMQJames Carr
 
RabbitMQ Data Ingestion
RabbitMQ Data IngestionRabbitMQ Data Ingestion
RabbitMQ Data IngestionAlvaro Videla
 
Redis for the Everyday Developer
Redis for the Everyday DeveloperRedis for the Everyday Developer
Redis for the Everyday DeveloperRoss Tuck
 
Introduction to AMQP Messaging with RabbitMQ
Introduction to AMQP Messaging with RabbitMQIntroduction to AMQP Messaging with RabbitMQ
Introduction to AMQP Messaging with RabbitMQDmitriy Samovskiy
 
Redis in Practice
Redis in PracticeRedis in Practice
Redis in PracticeNoah Davis
 
Everything you always wanted to know about Redis but were afraid to ask
Everything you always wanted to know about Redis but were afraid to askEverything you always wanted to know about Redis but were afraid to ask
Everything you always wanted to know about Redis but were afraid to askCarlos Abalde
 
Dissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal ArchitectureDissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal ArchitectureAlvaro Videla
 

Viewers also liked (19)

Erlang scheduler
Erlang schedulerErlang scheduler
Erlang scheduler
 
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
 
Integrating RabbitMQ with PHP
Integrating RabbitMQ with PHPIntegrating RabbitMQ with PHP
Integrating RabbitMQ with PHP
 
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
 
RabbitMQ Operations
RabbitMQ OperationsRabbitMQ Operations
RabbitMQ Operations
 
High powered messaging with RabbitMQ
High powered messaging with RabbitMQHigh powered messaging with RabbitMQ
High powered messaging with RabbitMQ
 
RabbitMQ Data Ingestion
RabbitMQ Data IngestionRabbitMQ Data Ingestion
RabbitMQ Data Ingestion
 
Redis for the Everyday Developer
Redis for the Everyday DeveloperRedis for the Everyday Developer
Redis for the Everyday Developer
 
Introduction to AMQP Messaging with RabbitMQ
Introduction to AMQP Messaging with RabbitMQIntroduction to AMQP Messaging with RabbitMQ
Introduction to AMQP Messaging with RabbitMQ
 
Redis in Practice
Redis in PracticeRedis in Practice
Redis in Practice
 
Everything you always wanted to know about Redis but were afraid to ask
Everything you always wanted to know about Redis but were afraid to askEverything you always wanted to know about Redis but were afraid to ask
Everything you always wanted to know about Redis but were afraid to ask
 
Dissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal ArchitectureDissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal Architecture
 

Similar to Taste Rabbitmq

Java Logging discussion Log4j,Slf4j
Java Logging discussion Log4j,Slf4jJava Logging discussion Log4j,Slf4j
Java Logging discussion Log4j,Slf4jRajiv Gupta
 
Riak Meetup Stockholm 1/11/2012
Riak Meetup Stockholm 1/11/2012Riak Meetup Stockholm 1/11/2012
Riak Meetup Stockholm 1/11/2012Bip Thelin
 
Zope component architechture
Zope component architechtureZope component architechture
Zope component architechtureAnatoly Bubenkov
 
Logging with Logback in Scala
Logging with Logback in ScalaLogging with Logback in Scala
Logging with Logback in ScalaKnoldus Inc.
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobikrmboya
 
Logging with Logback in Scala
Logging with Logback in ScalaLogging with Logback in Scala
Logging with Logback in ScalaKnoldus Inc.
 
Getting modern with logging via log4perl
Getting modern with logging via log4perlGetting modern with logging via log4perl
Getting modern with logging via log4perlDean Hamstead
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Introthnetos
 

Similar to Taste Rabbitmq (13)

Java Logging discussion Log4j,Slf4j
Java Logging discussion Log4j,Slf4jJava Logging discussion Log4j,Slf4j
Java Logging discussion Log4j,Slf4j
 
Functional python
Functional pythonFunctional python
Functional python
 
World of Logging
World of LoggingWorld of Logging
World of Logging
 
Riak Meetup Stockholm 1/11/2012
Riak Meetup Stockholm 1/11/2012Riak Meetup Stockholm 1/11/2012
Riak Meetup Stockholm 1/11/2012
 
Zope component architechture
Zope component architechtureZope component architechture
Zope component architechture
 
Porting to Python 3
Porting to Python 3Porting to Python 3
Porting to Python 3
 
Logging with Logback in Scala
Logging with Logback in ScalaLogging with Logback in Scala
Logging with Logback in Scala
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobi
 
Logging with Logback in Scala
Logging with Logback in ScalaLogging with Logback in Scala
Logging with Logback in Scala
 
Getting modern with logging via log4perl
Getting modern with logging via log4perlGetting modern with logging via log4perl
Getting modern with logging via log4perl
 
Python 3
Python 3Python 3
Python 3
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Intro
 

More from jeff kit

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

More from jeff kit (11)

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

Recently uploaded

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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 WorkerThousandEyes
 
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...Drew Madelung
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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 MenDelhi Call girls
 
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...Miguel Araújo
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
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 SolutionsEnterprise Knowledge
 
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.pdfEnterprise Knowledge
 
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...apidays
 
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.pptxHampshireHUG
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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 Servicegiselly40
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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 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...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
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...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
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
 
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
 
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...
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Taste Rabbitmq

  • 1. Taste jeff@techparty.org
  • 5. What‘s a MQ message Producer queue
  • 6. What‘s a MQ Consumer message Producer queue
  • 8. Why rabbitMQ? Based on Erlang Reliable Highly available Scalable portable Implemented AMQP Standard and More 100% OpenSource
  • 9. I have a log system
  • 10. register Login logout Log System DataBase
  • 11. register Login log = getLog(request) if log.type == ‘login’: logout # balabala ....... if log.type == ‘register’: # balabala ....... log.save() Log System DataBase
  • 12. 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. ....
  • 14. Step1. work with Queue ....... log = getLog(request) channel.publish(None,‘log-queue’,None,log)
  • 15. 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()
  • 16. 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()
  • 17. 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()
  • 18. step2. Split Queues login logout
  • 19. step2. Split Queues ....... log = getLog(request) channel.publish(None,log.type,None,log) login logout
  • 20. step2. Split Queues ....... def onLog(loginlog): log = getLog(request) # balabala channel.publish(None,log.type,None,log) loginlog.save() login logout
  • 21. 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()
  • 22. 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()
  • 23. Say hi to Exchange
  • 27. step3. Share message c# x login c1 P x c2 logout
  • 28. 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
  • 29. 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
  • 30. 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()
  • 31. 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
  • 32. Performance tune Parameters for multiple consumer toning: QOS consumer count autoAck?
  • 33. clustering to scale Start rabbit nodes: rabbit1$ rabbitmq-server rabbit2$ rabbitmq-server
  • 34. 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.
  • 35. 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.

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n