Akka is using the Actors together with STM to create a unified runtime and programming model for scaling both UP (multi-core) and OUT (grid/cloud). Akka provides location transparency by abstracting away both these tangents of scalability by turning them into an ops task. This gives the Akka runtime freedom to do adaptive automatic load-balancing, cluster rebalancing, replication & partitioning
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Above the clouds: introducing Akka
1. Above the Clouds:
Introducing Akka
Jonas Bonér
CTO Typesafe
Twitter: @jboner
presented by Martin Odersky
2. The problem
It is way too hard to build:
1. correct highly concurrent systems
2. truly scalable systems
3. fault-tolerant systems that self-heals
...using “state-of-the-art” tools
13. WHERE IS AKKA USED?
SOME EXAMPLES:
FINANCE TELECOM
• Stock trend Analysis & Simulation
• Streaming media network gateways
• Event-driven messaging systems
SIMULATION
BETTING & GAMING • 3D simulation engines
• Massive multiplayer online gaming
E-COMMERCE
• High throughput and transactional
• Social media community sites
betting
31. Future
val f1 = Futures.future(callable)
val f2 = Futures.firstCompletedOf(futures)
val f3 = Futures.reduce(futures)((x, y) => ..)
val f4 = Futures.fold(zero)(futures)((x, y) => ...)
32. Future
val future1 = for {
a: Int <- actor !!! "Hello" // returns 5
b: String <- actor !!! a // returns "10"
c: String <- actor !!! 7 // returns "14"
} yield b + "-" + c
val future2 = for {
a <- actor !!! Req("Hello") collect { case Res(x: Int) => x }
b <- actor !!! Req(a) collect { case Res(x: String) => x }
c <- actor !!! Req(7) collect { case Res(x: String) => x }
} yield b + "-" + c
33. Dataflow
import Future.flow
val x, y, z = Promise[Int]()
flow {
z << x() + y()
println("z = " + z())
}
flow { x << 40 }
flow { y << 2 }
34. Send: !!
val result = (actor !! Message).as[String]
uses Future under the hood and blocks until
timeout or completion
39. Set dispatcher
class MyActor extends Actor {
self.dispatcher = Dispatchers
.newThreadBasedDispatcher(self)
...
}
actor.dispatcher = dispatcher // before started
41. Remote Server
// use host & port in config
Actor.remote.start()
Actor.remote.start("localhost", 2552)
Scalable implementation based on
NIO (Netty) & Protobuf
42. Two types of
remote actors
Client initiated & managed
Server initiated & managed
43. Client-managed
supervision works across nodes
import Actor._
val service = remote.actorOf[MyActor](host, port)
service ! message
44. Server-managed
register and manage actor on server
client gets “dumb” proxy handle
import Actor._
remote.register(“service:id”, actorOf[MyService])
server part
45. Server-managed
val service = remote.actorFor(
“service:id”,
“darkstar”,
9999)
service ! message
client part
46. Server-managed
import Actor._
remote.register(actorOf[MyService])
remote.registerByUuid(actorOf[MyService])
remote.registerPerSession(
“service:id”, actorOf[MyService])
remote.unregister(“service:id”)
remote.unregister(actorRef)
server part
47. Remoting in Akka 1.1
Remote Actors
Client-managed
Server-managed
Problem
Deployment (local vs remote) is a dev decision
We get a fixed and hard-coded topology
Can’t change it dynamically and adaptively
Needs to be a
deployment & runtime decision
49. Address
val actor = actorOf[MyActor](“my-service”)
Bind the actor to a virtual address
50. Deployment
•Actor address is virtual and decoupled from how it
is deployed
•If no deployment configuration exists then actor is
deployed as local
•The same system can be configured as distributed
without code change (even change at runtime)
•Write as local but deploy as distributed in the
cloud without code change
•Allows runtime to dynamically and adaptively
change topology
51. Deployment configuration
akka {
actor {
deployment {
my-service {
router = "least-cpu"
clustered {
home = "node:test-node-1"
replicas = 3
stateless = on
}
}
}
}
}
53. Deployment configuration
akka { Address
actor { Type of load-
deployment {
my-service {
router = "least-cpu"
clustered {
home = "node:test-node-1"
replicas = 3
stateless = on
}
}
}
}
}
54. Deployment configuration
akka { Address
actor { Type of load-
deployment {
my-service {
router = "least-cpu"
clustered {
home = "node:test-node-1"
Clustered replicas = 3
or Local stateless = on
}
}
}
}
}
55. Deployment configuration
akka { Address
actor { Type of load-
deployment {
my-service {
router = "least-cpu"
clustered {
home = "node:test-node-1"
Clustered replicas = 3
or Local stateless = on
} Home node
}
}
}
}
56. Deployment configuration
akka { Address
actor { Type of load-
deployment {
my-service {
router = "least-cpu"
clustered {
home = "node:test-node-1"
Clustered replicas = 3
or Local stateless = on
} Home node
}
}
} Nr of replicas
} in cluster
57. Deployment configuration
akka { Address
actor { Type of load-
deployment {
my-service {
router = "least-cpu"
clustered {
home = "node:test-node-1"
Clustered replicas = 3
or Local stateless = on
} Home node
}
}
}
Stateful or Nr of replicas
} in cluster
Stateless
58. The runtime provides
•Subscription-based cluster membership service
•Highly available cluster registry for actors
•Automatic cluster-wide deployment
•Highly available centralized configuration service
•Automatic replication with automatic fail-over upon
node crash
•Transparent and user-configurable load-balancing
•Transparent adaptive cluster rebalancing
•Leader election
•Durable mailboxes - guaranteed delivery
77. Classification of State
• Scratch data
• Static data
• Supplied at boot time
• Supplied by other components
• Dynamic data
• Data possible to recompute
• Input from other sources; data
that is impossible to recompute
•
78. Classification of State
• Scratch data
• Static data
• Supplied at boot time
• Supplied by other components
• Dynamic data
• Data possible to recompute
• Input from other sources; data
that is impossible to recompute
•
79. Classification of State
• Scratch data
• Static data
• Supplied Must time
at boot be
• Supplied by other components
protected
• Dynamic data
• Databy anyto recompute
possible means
• Input from other sources; data
that is impossible to recompute
•
Scalable: Scala stands for SCALAble language which means that the language is designed to scale with the usage. Concepts and abstractions scale from small to larges\nComponent-Oriented: scala was initially designed as a language to do component oriented programming, with its requirements on reusability, maintainability, orthogonality and extensibility.\nCoherent: Scala has managed to build a coherent whole while merging the FP and OO paradigms.\nHigh level: Scala allows you to program it to very high level utilizing its powerful abstractions both in OO and FP\nExtensible: It is great for building Domain Specific Languages (DSLs). Since Scala has a good type inference, a very flexible syntax which gives it a dynamic feel similar to Ruby and Python.\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Scalable: Scala stands for SCALAble language which means that the language is designed to scale with the usage. Concepts and abstractions scale from small to larges\nComponent-Oriented: scala was initially designed as a language to do component oriented programming, with its requirements on reusability, maintainability, orthogonality and extensibility.\nCoherent: Scala has managed to build a coherent whole while merging the FP and OO paradigms.\nHigh level: Scala allows you to program it to very high level utilizing its powerful abstractions both in OO and FP\nExtensible: It is great for building Domain Specific Languages (DSLs). Since Scala has a good type inference, a very flexible syntax which gives it a dynamic feel similar to Ruby and Python.\n
\n
\n
\n
\n
\n
\n
\n
Scalable: Scala stands for SCALAble language which means that the language is designed to scale with the usage. Concepts and abstractions scale from small to larges\nComponent-Oriented: scala was initially designed as a language to do component oriented programming, with its requirements on reusability, maintainability, orthogonality and extensibility.\nCoherent: Scala has managed to build a coherent whole while merging the FP and OO paradigms.\nHigh level: Scala allows you to program it to very high level utilizing its powerful abstractions both in OO and FP\nExtensible: It is great for building Domain Specific Languages (DSLs). Since Scala has a good type inference, a very flexible syntax which gives it a dynamic feel similar to Ruby and Python.\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Scalable: Scala stands for SCALAble language which means that the language is designed to scale with the usage. Concepts and abstractions scale from small to larges\nComponent-Oriented: scala was initially designed as a language to do component oriented programming, with its requirements on reusability, maintainability, orthogonality and extensibility.\nCoherent: Scala has managed to build a coherent whole while merging the FP and OO paradigms.\nHigh level: Scala allows you to program it to very high level utilizing its powerful abstractions both in OO and FP\nExtensible: It is great for building Domain Specific Languages (DSLs). Since Scala has a good type inference, a very flexible syntax which gives it a dynamic feel similar to Ruby and Python.\n
Scalable: Scala stands for SCALAble language which means that the language is designed to scale with the usage. Concepts and abstractions scale from small to larges\nComponent-Oriented: scala was initially designed as a language to do component oriented programming, with its requirements on reusability, maintainability, orthogonality and extensibility.\nCoherent: Scala has managed to build a coherent whole while merging the FP and OO paradigms.\nHigh level: Scala allows you to program it to very high level utilizing its powerful abstractions both in OO and FP\nExtensible: It is great for building Domain Specific Languages (DSLs). Since Scala has a good type inference, a very flexible syntax which gives it a dynamic feel similar to Ruby and Python.\n
Scalable: Scala stands for SCALAble language which means that the language is designed to scale with the usage. Concepts and abstractions scale from small to larges\nComponent-Oriented: scala was initially designed as a language to do component oriented programming, with its requirements on reusability, maintainability, orthogonality and extensibility.\nCoherent: Scala has managed to build a coherent whole while merging the FP and OO paradigms.\nHigh level: Scala allows you to program it to very high level utilizing its powerful abstractions both in OO and FP\nExtensible: It is great for building Domain Specific Languages (DSLs). Since Scala has a good type inference, a very flexible syntax which gives it a dynamic feel similar to Ruby and Python.\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Scalable: Scala stands for SCALAble language which means that the language is designed to scale with the usage. Concepts and abstractions scale from small to larges\nComponent-Oriented: scala was initially designed as a language to do component oriented programming, with its requirements on reusability, maintainability, orthogonality and extensibility.\nCoherent: Scala has managed to build a coherent whole while merging the FP and OO paradigms.\nHigh level: Scala allows you to program it to very high level utilizing its powerful abstractions both in OO and FP\nExtensible: It is great for building Domain Specific Languages (DSLs). Since Scala has a good type inference, a very flexible syntax which gives it a dynamic feel similar to Ruby and Python.\n
\n
Scalable: Scala stands for SCALAble language which means that the language is designed to scale with the usage. Concepts and abstractions scale from small to larges\nComponent-Oriented: scala was initially designed as a language to do component oriented programming, with its requirements on reusability, maintainability, orthogonality and extensibility.\nCoherent: Scala has managed to build a coherent whole while merging the FP and OO paradigms.\nHigh level: Scala allows you to program it to very high level utilizing its powerful abstractions both in OO and FP\nExtensible: It is great for building Domain Specific Languages (DSLs). Since Scala has a good type inference, a very flexible syntax which gives it a dynamic feel similar to Ruby and Python.\n