Taste Rabbitmq

14,771 views
14,821 views

Published on

rabbitMQ测评之修正版

Published in: Technology, Business
1 Comment
23 Likes
Statistics
Notes
No Downloads
Views
Total views
14,771
On SlideShare
0
From Embeds
0
Number of Embeds
9,409
Actions
Shares
0
Downloads
254
Comments
1
Likes
23
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Taste Rabbitmq

    1. 1. Taste jeff@techparty.org
    2. 2. What‘s a MQ
    3. 3. What‘s a MQ queue
    4. 4. What‘s a MQmessage queue
    5. 5. What‘s a MQ messageProducer queue
    6. 6. What‘s a MQ Consumer messageProducer queue
    7. 7. Why MQDe-coupleHigher performanceAnother IPC
    8. 8. Why rabbitMQ?Based on Erlang Reliable Highly available Scalable portableImplemented AMQP Standard and More100% OpenSource
    9. 9. I have a log system
    10. 10. register Loginlogout Log System DataBase
    11. 11. register Login log = getLog(request) if log.type == ‘login’:logout # balabala ....... if log.type == ‘register’: # balabala ....... log.save() Log System DataBase
    12. 12. register Login log = getLog(request) if log.type == ‘login’: logout # balabala ....... if log.type == ‘register’: # balabala ....... log.save() Log SystemI need ...1. better performance2. cleaner code DataBase3. easier to test4. ....
    13. 13. Step1. work with Queue
    14. 14. Step1. work with Queue.......log = getLog(request)channel.publish(None,‘log-queue’,None,log)
    15. 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. 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. 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 # balabalabut. that if log.type == ‘logout’:codes still smell bad~~ # balabala log.save()
    18. 18. step2. Split Queues login logout
    19. 19. step2. Split Queues.......log = getLog(request)channel.publish(None,log.type,None,log) login logout
    20. 20. step2. Split Queues....... def onLog(loginlog):log = getLog(request) # balabalachannel.publish(None,log.type,None,log) loginlog.save() login logout
    21. 21. step2. Split Queues....... def onLog(loginlog):log = getLog(request) # balabalachannel.publish(None,log.type,None,log) loginlog.save() login logout def onLog(logoutlog): # balabala logoutlog.save()
    22. 22. step2. Split Queues....... def onLog(loginlog):log = getLog(request) # balabalachannel.publish(None,log.type,None,log) loginlog.save() login logout def onLog(logoutlog): # balabalaWhat’s that guy? logoutlog.save()
    23. 23. Say hi to Exchange
    24. 24. Direct Exchange
    25. 25. Fanout Exchange
    26. 26. Topic Exchange
    27. 27. step3. Share message c# x login c1P x c2 logout
    28. 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. 29. step3. Share message.......log = getLog(request) def onLog(loginlog):channel.exchange_declare(log.type,‘fanout’) # balabalachannel.publish(log.type,’’,None,log) loginlog.save() c# x login c1 P x c2 logout
    30. 30. step3. Share message.......log = getLog(request) def onLog(loginlog):channel.exchange_declare(log.type,‘fanout’) # balabalachannel.publish(log.type,’’,None,log) loginlog.save() c# x login c1 P x c2 logout def onLog(logoutlog): # balabala logoutlog.save()
    31. 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. 32. Performance tuneParameters for multiple consumer toning: QOS consumer count autoAck?
    33. 33. clustering to scaleStart rabbit nodes:rabbit1$ rabbitmq-serverrabbit2$ rabbitmq-server
    34. 34. clustering to scalecreate cluster:rabbit2$ rabbitmqctl stop_appStopping node rabbit@rabbit2 ...done.rabbit2$ rabbitmqctl resetResetting node rabbit@rabbit2 ...done.rabbit2$ rabbitmqctl cluster rabbit@rabbit1Clustering node rabbit@rabbit2 with [rabbit@rabbit1] ...done.rabbit2$ rabbitmqctl start_appStarting node rabbit@rabbit2 ...done.
    35. 35. clustering to scaleCheck it out:rabbit1$ rabbitmqctl statusStatus of node rabbit@rabbit1 ...[..., {nodes,[{disc,[rabbit@rabbit1]},{ram,[rabbit@rabbit2]}]}, {running_nodes,[rabbit@rabbit2,rabbit@rabbit1]}]...done.
    36. 36. Highly Available
    37. 37. discuss ......
    38. 38. Thank youhttp://jeffkit.infohttp://twitter.com/jeff_kitjeff@techparty.org

    ×