Distributed Programming With Ruby》讀書筆記七 Starling and AMQP/RabbitMQ (Part3 chapter7-8)

來源:互聯網
上載者:User

標籤:todo   opd   rem   tdd   cin   apm   完全   kvo   call   

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)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.