Akka 介紹
Welcome to Akka, a set of open-source libraries for designing scalable, resilient systems that span processor cores and networks. Akka allows you to focus on meeting business needs instead of writing low-level code to provide reliable behavior, fault tolerance, and high performance
Akka 是一套用于設計可擴展的票灰,可容錯呕童,高并發(fā)的分布式系統(tǒng)的開源類庫,Akka 讓你可以專注于業(yè)務需求而不是糾結于如何處理可用性傍妒,容錯性和可靠性蛉签。
Common practices and programming models do not address important challenges inherent in designing systems for modern computer architectures. To be successful, distributed systems must cope in an environment where components crash without responding, messages get lost without a trace on the wire, and network latency fluctuates. These problems occur regularly in carefully managed intra-datacenter environments - even more so in virtualized architectures.
常見的實踐和編程模型沒有很好的解決在現代計算機架構中系統(tǒng)設計面臨的重要挑戰(zhàn)胡陪,一個成功的分布式系統(tǒng)必須能成功的應付由系統(tǒng)組件崩潰,消息丟失正蛙,網路延時帶來的問題督弓。這些問題經常出沒在細心維護的內部數據中营曼,在虛擬化架構中更是如此乒验。
To deal with these realities, Akka provides:
為了解決這些問題,Akka提供了如下手段:
Multi-threaded behavior without the use of low-level concurrency constructs like atomics or locks. You do not even need to think about memory visibility issues.
不使用低級別并發(fā)結構(原子操作或鎖)的多線程行為蒂阱,永遠不需要考慮內存的可見性問題锻全。
Transparent remote communication between systems and their components. You do not need to write or maintain difficult networking code.
系統(tǒng)間透明的遠程交互,不需要編寫和維護難懂的網絡編程代碼录煤。
A clustered, high-availability architecture that is elastic, scales in or out, on demand.
可按需擴張的容錯性的高可用集群架構
All of these features are available through a uniform programming model: Akka exploits the actor model to provide a level of abstraction that makes it easier to write correct concurrent, parallel and distributed systems. The actor model spans the set of Akka libraries, providing you with a consistent way of understanding and using them. Thus, Akka offers a depth of integration that you cannot achieve by picking libraries to solve individual problems and trying to piece them together.
所有這些特性基于同一的編程模型:Akka利用actor模型提供一種同一級別的抽象使得編寫正確的并發(fā)并行的分布式系統(tǒng)更加容易鳄厌。actor 模型貫穿了整個Akka類庫,使得你可以在同一的思想下的學習和使用它們妈踊,因此了嚎,Akka提供了一種深度融合讓你你不用為了解決個別的問題去挑選不同的類庫并把他們組裝在一起。
By learning Akka and its actor model, you will gain access to a vast and deep set of tools that solve difficult distributed/parallel systems problems in a uniform programming model where everything fits together tightly and efficiently.
通過學習Akka和它的Actor模型廊营⊥嵊荆可以獲得一個龐大的且具有深度的工具集,而這個工具集可用幫助你通過同一的編程模型解決復雜的分布式并行系統(tǒng)問題露筒,并且這些工具可以緊密而高效的配合呐伞。
什么事Actor 模型?
The characteristics of today’s computing environments are vastly different from the ones in use when the programming models of yesterday were conceived. Actors were invented decades ago byCarl Hewitt. But relatively recently, their applicability to the challenges of modern computing systems has been recognized and proved to be effective.
現在的計算機結構已經和之前編程模型所能應付的計算機架構有了很多不同慎式,Actor模型雖然早在十年前就被發(fā)明了伶氢,但是它被證明可以高效的應對現代計算機系統(tǒng)架構中的面臨的挑戰(zhàn)趟径。
The actor model provides an abstraction that allows you to think about your code in terms of communication, not unlike people in a large organization. The basic characteristic of actors is that they model the world as stateful entities communicating with each other by explicit message passing.
Actor模型把一切都抽象成有狀態(tài)的實體并通過消息傳遞的方式進行彼此之間的溝通
As computational entities, actors have these characteristics:
作為計算實體,actors 擁有如下特征:
They communicate with asynchronous messaging instead of method calls
通過異步消息溝通而不是方法調用
They manage their own state
自己管理自己的狀態(tài)
When responding to a message, they can:
當它們應答消息時癣防,他們可以做出以下動作:
Create other (child) actors
創(chuàng)建另外的actors(子actors)
Send messages to other actors
發(fā)送消息給其他的actors
Stop (child) actors or themselves
終止自己或者子actors