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 是一套用于設(shè)計(jì)可擴(kuò)展的,可容錯(cuò),高并發(fā)的分布式系統(tǒng)的開源類庫(kù),Akka 讓你可以專注于業(yè)務(wù)需求而不是糾結(jié)于如何處理可用性,容錯(cuò)性和可靠性。
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.
常見的實(shí)踐和編程模型沒(méi)有很好的解決在現(xiàn)代計(jì)算機(jī)架構(gòu)中系統(tǒng)設(shè)計(jì)面臨的重要挑戰(zhàn),一個(gè)成功的分布式系統(tǒng)必須能成功的應(yīng)付由系統(tǒng)組件崩潰,消息丟失,網(wǎng)路延時(shí)帶來(lái)的問(wèn)題。這些問(wèn)題經(jīng)常出沒(méi)在細(xì)心維護(hù)的內(nèi)部數(shù)據(jù)中,在虛擬化架構(gòu)中更是如此。
To deal with these realities, Akka provides:
為了解決這些問(wèn)題,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.
不使用低級(jí)別并發(fā)結(jié)構(gòu)(原子操作或鎖)的多線程行為,永遠(yuǎn)不需要考慮內(nèi)存的可見性問(wèn)題。
Transparent remote communication between systems and their components. You do not need to write or maintain difficult networking code.
系統(tǒng)間透明的遠(yuǎn)程交互,不需要編寫和維護(hù)難懂的網(wǎng)絡(luò)編程代碼。
A clustered, high-availability architecture that is elastic, scales in or out, on demand.
可按需擴(kuò)張的容錯(cuò)性的高可用集群架構(gòu)
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模型提供一種同一級(jí)別的抽象使得編寫正確的并發(fā)并行的分布式系統(tǒng)更加容易。actor 模型貫穿了整個(gè)Akka類庫(kù),使得你可以在同一的思想下的學(xué)習(xí)和使用它們,因此,Akka提供了一種深度融合讓你你不用為了解決個(gè)別的問(wèn)題去挑選不同的類庫(kù)并把他們組裝在一起。
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.
通過(guò)學(xué)習(xí)Akka和它的Actor模型??梢垣@得一個(gè)龐大的且具有深度的工具集,而這個(gè)工具集可用幫助你通過(guò)同一的編程模型解決復(fù)雜的分布式并行系統(tǒng)問(wèn)題,并且這些工具可以緊密而高效的配合。
什么事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.
現(xiàn)在的計(jì)算機(jī)結(jié)構(gòu)已經(jīng)和之前編程模型所能應(yīng)付的計(jì)算機(jī)架構(gòu)有了很多不同,Actor模型雖然早在十年前就被發(fā)明了,但是它被證明可以高效的應(yīng)對(duì)現(xiàn)代計(jì)算機(jī)系統(tǒng)架構(gòu)中的面臨的挑戰(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)的實(shí)體并通過(guò)消息傳遞的方式進(jìn)行彼此之間的溝通
As computational entities, actors have these characteristics:
作為計(jì)算實(shí)體,actors 擁有如下特征:
They communicate with asynchronous messaging instead of method calls
通過(guò)異步消息溝通而不是方法調(diào)用
They manage their own state
自己管理自己的狀態(tài)
When responding to a message, they can:
當(dāng)它們應(yīng)答消息時(shí),他們可以做出以下動(dòng)作:
Create other (child) actors
創(chuàng)建另外的actors(子actors)
Send messages to other actors
發(fā)送消息給其他的actors
Stop (child) actors or themselves
終止自己或者子actors