Effective Akka (Paperback)
暫譯: 有效的 Akka (平裝本)

Jamie Allen

  • 出版商: O'Reilly
  • 出版日期: 2013-10-01
  • 定價: $525
  • 售價: 9.5$499
  • 語言: 英文
  • 頁數: 74
  • 裝訂: Paperback
  • ISBN: 1449360076
  • ISBN-13: 9781449360078
  • 相關分類: Java 相關技術
  • 立即出貨 (庫存 < 4)

買這商品的人也買了...

商品描述

content<div><p>Avoid common mistakes when building distributed, asynchronous, high-performance software with the Akka toolkit and runtime. With this concise guide, author Jamie Allen provides a collection of best practices based on several years of using the actor model. The book also includes examples of actor application types and two primary patterns of actor usage, the Extra Pattern and Cameo Pattern. </p><p> Allen, the Director of Consulting for Typesafe—creator of Akka and the Scala programming language—examines actors with a banking-service use case throughout the book, using examples shown in Akka and Scala. If you have any experience with Akka, this guide is essential. </p><ul><li>Delve into domain-driven and work-distribution actor applications </li><li>Understand why it’s important to have actors do only one job </li><li>Avoid thread blocking by allowing logic to be delegated to a Future </li><li>Model interactions as simply as possible to avoid premature optimization </li><li>Create well-defined interactions, and know exactly what failures can occur </li><li>Learn why you should never treat actors as you would an ordinary class </li><li>Keep track of what goes on in production by monitoring everything </li><li>Tune Akka applications with the Typesafe Console </li></ul></div>sourceProduct Descriptioncontent<div class="aplus"> <h4>Q&A with Jamie Allen, author of "Effective Akka: Patterns and Best Practices"</h4> <p><strong>Q. Why is this an important book for people to read now</strong></p> <p>A. The advent of the many-core platform means that developers have more processing resources in the form of "cores" at their disposal than ever before. Traditional programming constructs do not allow developers to leverage these cores. As computers add more and more cores with each new platform released by hardware manufacturers, developers will need to find ways to maximize the utilization of these resources. Akka provides a platform for doing just that, and allowing your application to scale up and out as more resources become available.</p> <p><strong>Q. What will readers walk away with after reading "Effective Akka?"</strong></p> <p>A. After reading "Effective Akka," readers should have a firm grasp of the kinds of coding issues they may encounter when developing with actors, regardless of whether they're using Scala/Akka or Erlang. Many of the concepts are relevant to developers who are writing asynchronous code without actors as well. Effective Akka provides guidance with respect to coding style and best practices so that developers are able to avoid common pitfalls. </p> <p><strong>Q. What's so exciting and important about patterns and best prices?</strong></p> <p>A. The move to "reactive" solutions. Developers can perform much more work nowadays by using asynchrony-- not wasting threads that spawn blocking operations, instead defining work that can be applied automatically when such work is completed. Many technologies are emerging in this space, such as ReactiveJava, Node.js, Go, Clojure's core.async and Scala's futures, actors and async support. Never before have developers had so many useful tools at their disposal to write applications that are interactive, low-latency, fault tolerant, and scalable. Every language and platform is looking to provide a solution in this space. </p> <p><strong>Q. Can you give us a few tips when building high-performance software with Akka?</strong></p> <p><ol><li>Be very careful about closing over state from outside of a code block. Capture and stabilize such state by placing it into local values so that you know you will have an unchanged value at the time you actually need it.</li> <li>Keep your code simple. Make more atomic methods and functions that do only one thing, and combine them to accomplish your goals.</li> <li>Never reference the keyword "this" from inside an actor. Don't use it and don't register it elsewhere. Pretend the concept does not exist, where possible. Learn to think in terms of "ActorRef" and use them at all times, even when communicating with yourself.</li> <li>Create failure zones in your application by assigning thread pool resources to specific groups of actors. This way, if one actor is monopolizing a thread with a computationally-intense activity, only a limited subset of other actors are affected by not having that resource available to them.</li> <li>Avoid blocking as much as possible. Always write code to be asynchronous unless there is a specific block of code where blocking must occur. Put any such blocking tasks on their own threads, or use Scala's Managed Blocking to keep other resources from being starved of a thread.</li> </ol></p> </div>sourceAmazon.com Review

商品描述(中文翻譯)

避免在使用 Akka 工具包和運行時構建分散式、非同步、高效能軟體時常見的錯誤。作者 Jamie Allen 提供了這本簡明指南,根據多年使用演員模型的經驗,整理出一系列最佳實踐。本書還包括演員應用類型的範例以及兩種主要的演員使用模式:Extra Pattern 和 Cameo Pattern。

Allen 是 Typesafe 的顧問總監,該公司是 Akka 和 Scala 程式語言的創造者,他在全書中以銀行服務的使用案例來探討演員,並使用 Akka 和 Scala 中的範例。如果您對 Akka 有任何經驗,這本指南是必不可少的。

- 深入了解以領域驅動和工作分配為基礎的演員應用
- 理解為什麼演員只應該執行一項工作是重要的
- 通過將邏輯委派給 Future 來避免線程阻塞
- 盡可能簡化模型互動,以避免過早優化
- 創建明確的互動,並確切了解可能發生的失敗
- 學習為什麼您永遠不應該將演員視為普通類別
- 透過監控所有內容來跟蹤生產環境中的狀況
- 使用 Typesafe Console 調整 Akka 應用

與《Effective Akka: Patterns and Best Practices》作者 Jamie Allen 的問答

**問:為什麼這本書現在對人們來說很重要?**
答:多核心平台的出現意味著開發人員擁有比以往更多的處理資源,這些資源以「核心」的形式提供。傳統的程式設計結構無法讓開發人員充分利用這些核心。隨著每個新平台的推出,計算機的核心數量不斷增加,開發人員需要找到方法來最大化這些資源的利用率。Akka 提供了一個平台來實現這一點,並允許您的應用隨著資源的增加而擴展。

**問:讀者在閱讀《Effective Akka》後會獲得什麼?**
答:在閱讀《Effective Akka》後,讀者應該能夠牢牢掌握在使用演員開發時可能遇到的各種編碼問題,無論他們使用的是 Scala/Akka 還是 Erlang。許多概念對於編寫非同步代碼但不使用演員的開發人員同樣適用。《Effective Akka》提供了有關編碼風格和最佳實踐的指導,幫助開發人員避免常見的陷阱。

**問:模式和最佳實踐有什麼令人興奮和重要的地方?**
答:轉向「反應式」解決方案。如今,開發人員可以通過使用非同步來執行更多的工作——不浪費執行阻塞操作的線程,而是定義可以在工作完成時自動應用的工作。許多技術在這個領域中不斷湧現,例如 ReactiveJava、Node.js、Go、Clojure 的 core.async 和 Scala 的 futures、演員及非同步支持。開發人員從未擁有如此多有用的工具來編寫互動性強、低延遲、容錯和可擴展的應用。每種語言和平台都在尋求在這個領域提供解決方案。

**問:在使用 Akka 構建高效能軟體時,您能給我們幾個建議嗎?**
答:
1. 對於從代碼塊外部關閉狀態要非常小心。通過將狀態放入本地變數來捕獲和穩定這些狀態,以便在實際需要時知道您將擁有不變的值。
2. 保持代碼簡單。創建更多原子方法和函數,讓它們只做一件事,然後將它們組合起來以達成您的目標。
3. 永遠不要從演員內部引用關鍵字 'this'。不要使用它,也不要在其他地方註冊它。盡可能假裝這個概念不存在。學會以 'ActorRef' 的方式思考,並在所有時候使用它們,即使是在與自己通信時。
4. 通過將線程池資源分配給特定的演員組來創建應用中的失敗區域。這樣,如果一個演員因計算密集型活動而壟斷了一個線程,只有有限的其他演員會受到影響,因為他們無法使用該資源。
5. 儘量避免阻塞。除非有特定的代碼塊必須發生阻塞,否則始終編寫非同步代碼。將任何此類阻塞任務放在自己的線程上,或使用 Scala 的 Managed Blocking 來防止其他資源因缺乏線程而被餓死。