首页 > 代码库 > Distributed Programming With Ruby》读书笔记七 Starling and AMQP/RabbitMQ (Part3 chapter7-8)

Distributed Programming With Ruby》读书笔记七 Starling and AMQP/RabbitMQ (Part3 chapter7-8)

Part III Distributed Message Queues
     Part III breaks from this "traditional" approach of distributed computing and looks at distributed message queues.
  • Chapter7 Starling: 
    • Including 9 parts:
      • What Is a Distributed Message Queue?
      • Installation
      • Getting Started with Starling 
      • "Hello World" the Starling Way
      • Building a Distributed Logger with Starling
      • Persisted Queues
      • Getting Starling States
      • Conclusion
      • Endnotes
    • "Starling is a powerful but simple messaging server that enables reliable distributed queuing with an absolutely minimal overhead."
    • It talks a lot about what a distributed message queue is, how to use it, and lets you in on some of the mistakes Twitter made so that you don’t make them yourself.
    • What Is a Distributed Message Queue?
      • you send a message to the queue that at some point in the future will be picked up by a remote system (processor) and will then be acted on.If there are no messages, the processor keeps checking until it finds a message to act on. When a message is found, the processor rocesses it, and the cycle starts again.
      • 技术分享技术分享
      • Picture Twitter’s application, if you can. Twitter has lots of people tweeting simultaneously. When a tweet comes in, it must be processed. When it is processed, the followers of the tweeters need to be notified of the new tweet. These notifications can range from emails to text messages to updating the tweeters page. If someone has a large number of followers, it can take several moments to generate and send those notifications. If Twitter were to try and do this in real time as new tweets arrived, then no new tweets would be able to get into the system because the servers would be too busy processing previous tweets. The system would fall down under the weight of it all. Enter the distributed message queue.
      • By using a distributed message queue, Twitter can process each tweet offline instead of when each one is submitted. This means that when tweets come in, the requests can be handled quickly. Later a processing server can come along, pick the tweets off the queue, and process them. This makes for a much more responsive and scalable system.
      • 技术分享技术分享
    • Installation
      • 命令行: gem install starling
    • Getting Started with Starling 
      • Starling is an interesting library. Instead of building everything from scratch, Blaine Cook and company decided to “speak” Memcached.
      • 命令: starling --help
      • 启动: sudo starling 
        • windows 就直接 starling呗。试了下大概这样
        • 技术分享技术分享
        • If you want to daemonize and create a complex server setup, I recommend using the config setting and creating a YAML3 file to store these settings to make it easy to start/restart your server. Page149有一点点怎么配置的讲解,就不黏过来了。
      • example: with our server now running:
      • 技术分享技术分享
      • 技术分享
      • 仍然没法运行成功,应该是缺Memcached?我也不知道…没心思调
      • Page152 提到starling.flush方法
    • "Hello World" the Starling Way
    • 例子:Page155 浏览了下,很简洁,基本就是set get
    • Building a Distributed Logger with Starling
    • 例子在Page157
    • Persisted Queues
      • As mentioned earlier, Starling uses the Memcached protocol, which might beg the question, “Why not just use Memcached?” That’s a great question. The answer is you could use Memcached instead of Starling, but you will lose several key features of Starling, including one very important feature—persisted queues.
      • When you shut down a Memcached server, you lose all of its contents. When you are trying to build a reliable queuing system, this is unacceptable. Starling solves this problem by persisting queues across server restarts. You can easily test this. First, place a message into the queue. Next, stop and restart the Starling server. Now try to retrieve the message from the queue. You’ll see that the message is still there.
      • Constantly persisting messages does have the negative side effect of slowing down the queue slightly because it has to talk to its persistence mechanism. But this is a small price to pay for the reliability of being able to recall unsent messages after a system failure or restart.
    • Getting Starling States
      • Getting statistics for any system is extremely important in helping diagnose issues with your system and in helping fine-tune and refine the system.
      • 例子在Page 160
    • Conclusion
    • Endnotes
    • 感觉这个东西会比较好用哎。直觉
  • Chapter8 AMQP/RabbitMQ
    • Here is what the developers of RabbitMQ have to say about it:
    • “RabbitMQ is a complete and highly reliable Enterprise Messaging system. The RabbitMQ client libraries and broker daemon can be used together to create an AMQP network, or used individually to bring the benefits of RabbitMQ to established networks.”
    • Including 10 parts:
      • What Is a AMQP?
      • Installation
      • "Hello World" the AMQP Way
      • Building a Distributed Logger with AMQP
      • Persisted AMQP Queues
      • Subscribing to a Message Queue
      • Topic Queues
      • Fanout Queues
      • Conclusion
      • Endnotes
    • What Is a AMQP?
      • AMQP stands for Advanced Message Queuing Protocol.
      • The AMQP website answers the questions of “why” and “what” quite nicely:
        • “Though many networking protocol needs have been addressed, a large gap exists in common guaranteed-delivery messaging middleware. AMQP fills that gap. AMQP enables complete interoperability for messaging middleware; both the networking protocol and the semantics of broker services are defined in AMQP.”
      • 技术分享技术分享
      • 技术分享技术分享
    • Installation
      • Installation of RabbitMQ: http://www.rabbitmq.com/install.html
      • 技术分享技术分享
      • Install AMQP : gem install amqp
    • "Hello World" the AMQP Way
      • start the RabbitMQ server
      • $ sudo -H -u rabbitmq rabbitma-server
      • In production I recommend running it as a background daemon using the -detached option. I also recommend that you read the accompanying documentation for other configuration information.
      • Page 168: Help with Stopping RabbitMQ &Documentation
      • Code: Page169
    • Building a Distributed Logger with AMQP
      • Page 178
    • Persisted AMQP Queues
    • Subscribing to a Message Queue
    • Topic Queues
    • Fanout Queues
      • Page 193 不练习感觉完全看不进去…
    • Conclusion
    • Endnotes

  这本书暂时告一段落啦。基本就是第一章认真练习了,后面就是草草地过了一遍。技术书也确实多读几遍才能够更好地消化,以后用得到或者有时间再来读吧。感谢作者的辛苦劳动:)

Distributed Programming With Ruby》读书笔记七 Starling and AMQP/RabbitMQ (Part3 chapter7-8)