Akka 2.0: towards new heights                        @remeniuk                                    emilypolar@flickr
Location Transparency
You’re doing your regular coding job for a localenvironment, and get ability to run your system in adistributed environmen...
RMI, EJB, CORBA, SOAP,XML-RPC, Thrift
RMI, EJB, CORBA, SOAP,XML-RPC, Thriftare easy, but ultimatelyflawed!Fail under networkpartitioning and partialfailure...
RMI, EJB, CORBA, SOAP,XML-RPCare easy, but ultimatelyflawed! It’s time for RPC to retire.Fail under networkpartitioning an...
RMI, EJB, CORBA, SOAP,     Akka*XML-RPC                           Simple toolkit for buildingare easy, but ultimately   di...
class HelloWorldActor extends Actor {   def receive = {       case msg => self reply (msg + " World")   }}                ...
Dispatcher stuffs actor[-s] with messagesclass ActorA extends Actor {  self.dispatcher = someDispatcher  ...}class ActorB ...
Actor Registry knows about all the localactors
registry.actorFor(id)registry.actorFor(uuid)registry.actorsFor(classOf[...])etc.
making actor accessible remotely
remote.start("localhost", 9999).register(     "hello-service", actorOf[HelloWorldActor])                                 R...
Moreover, there could be a pool ofactors behind the ActorRefclass MyLoadBalancer extends Actor with LoadBalancer {    val ...
Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
val supervisor = Supervisor( SupervisorConfig(  AllForOneStrategy(List(classOf[Exception]), 3, 1000),  Supervise(actorOf[M...
Akka 2.0
In Akka 2.0 there’re no                  local vs.remote actors anymore. All theactors are distributed (clustered, routed)
the new level of transparency
brand new akka-clusterin Soviet Russia by default, all the actors are localbut when you pass a configcluster magic starts ...
cluster magic•   actors migration•   actors replication•   cluster-wide routing•   adaptive load balancing•   distributed ...
New important concepts:• actor address• deployment config
[behind the scenes]                          actor clusteringget deployment configis scope                                ...
Using clustered actorakka.enabled-modules = ["cluster"]akka.event-handler-level = "WARNING"akka.actor.deployment.service-h...
[Akka 1.x] PROBLEM: synchronization ofregistries in a distributed network?POSSIBLE SOLUTION: https://github.com/remeniuk/a...
Distributed RegistryNode Anode.store(“my-actor", classOf[MyActor], serializerFor(classOf[MyActor]))Node Bnode.use(“my-acto...
Actor PropsactorOf(Props[TestActor]      .withDispatcher(new PinnedDispatcher())      .withFaultHandler(      OneForOneStr...
Composable Futures              !!                     *HINT: (actor ? message).get
Composable Futuresval future1 = for {       a <- (actor ? message1).mapTo[String]       b <- (actor ? message2).mapTo[Stri...
BONUS: multi-jvm testing withscalatest in specs2 https://github.com/typesafehub/sbt-multi-jvm https://github.com/jboner/ak...
GO AND TRY IT!> git clone https://github.com/jboner/akka> sbt
First glance at Akka 2.0
First glance at Akka 2.0
First glance at Akka 2.0
First glance at Akka 2.0
Upcoming SlideShare
Loading in …5
×

First glance at Akka 2.0

7,224 views

Published on

This presentation has been made at the 4th meetup of Belarusian Scala Enthusiasts by @remeniuk

1 Comment
10 Likes
Statistics
Notes
  • I can't wait the final version Akka 2.0 :)
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
7,224
On SlideShare
0
From Embeds
0
Number of Embeds
2,184
Actions
Shares
0
Downloads
125
Comments
1
Likes
10
Embeds 0
No embeds

No notes for slide

First glance at Akka 2.0

  1. 1. Akka 2.0: towards new heights @remeniuk emilypolar@flickr
  2. 2. Location Transparency
  3. 3. You’re doing your regular coding job for a localenvironment, and get ability to run your system in adistributed environment any time for free.
  4. 4. RMI, EJB, CORBA, SOAP,XML-RPC, Thrift
  5. 5. RMI, EJB, CORBA, SOAP,XML-RPC, Thriftare easy, but ultimatelyflawed!Fail under networkpartitioning and partialfailure...
  6. 6. RMI, EJB, CORBA, SOAP,XML-RPCare easy, but ultimatelyflawed! It’s time for RPC to retire.Fail under networkpartitioning and partial Steve Vinovskyfailure...
  7. 7. RMI, EJB, CORBA, SOAP, Akka*XML-RPC Simple toolkit for buildingare easy, but ultimately distributed, scalable,flawed! fault-tolerant systemsFail under network • actors / transactorspartitioning and partial • supervisorsfailure... • routing and dispatching • STM for better shared stated concurrency • much more…
  8. 8. class HelloWorldActor extends Actor { def receive = { case msg => self reply (msg + " World") }} LocalActorRefval myActor = actorOf[HelloWorldActor].start()val result = myActor !! “message”
  9. 9. Dispatcher stuffs actor[-s] with messagesclass ActorA extends Actor { self.dispatcher = someDispatcher ...}class ActorB extends Actor { self.dispatcher = someDispatcher ...}
  10. 10. Actor Registry knows about all the localactors
  11. 11. registry.actorFor(id)registry.actorFor(uuid)registry.actorsFor(classOf[...])etc.
  12. 12. making actor accessible remotely
  13. 13. remote.start("localhost", 9999).register( "hello-service", actorOf[HelloWorldActor]) RemoteActorRefval actor = remote.actorFor( "hello-service", "localhost", 9999)val result = actor !! "Hello"
  14. 14. Moreover, there could be a pool ofactors behind the ActorRefclass MyLoadBalancer extends Actor with LoadBalancer { val pinger = actorOf(new Actor { def receive = { case x => println("Pinger: " + x) } }).start() val ponger = actorOf(new Actor { def receive = { case x => println("Ponger: " + x) } }).start() val seq = new CyclicIterator[ActorRef](List(pinger,ponger))}
  15. 15. Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
  16. 16. Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
  17. 17. Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
  18. 18. Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
  19. 19. Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
  20. 20. Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
  21. 21. Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
  22. 22. Fault toleranceGroups of linked, supervised actors define subsystems:those actors crash and restart together
  23. 23. val supervisor = Supervisor( SupervisorConfig( AllForOneStrategy(List(classOf[Exception]), 3, 1000), Supervise(actorOf[MyActor1], Permanent) :: Supervise(actorOf[MyActor2], Permanent) ::Nil))actor1.link(actor2)supervisor.link(actor2)
  24. 24. Akka 2.0
  25. 25. In Akka 2.0 there’re no local vs.remote actors anymore. All theactors are distributed (clustered, routed)
  26. 26. the new level of transparency
  27. 27. brand new akka-clusterin Soviet Russia by default, all the actors are localbut when you pass a configcluster magic starts to happen
  28. 28. cluster magic• actors migration• actors replication• cluster-wide routing• adaptive load balancing• distributed actor registry• leader election• much more…
  29. 29. New important concepts:• actor address• deployment config
  30. 30. [behind the scenes] actor clusteringget deployment configis scope LocalActorReflocal? Distributed Registry add to local actor registry store serilized actor factory in ZooKeeper create create actor on actor node ClusteredActorRef / RoutedActorRef ZooKeeper is used for storing cluster configs, serialized actor factories, metrics, etc.
  31. 31. Using clustered actorakka.enabled-modules = ["cluster"]akka.event-handler-level = "WARNING"akka.actor.deployment.service-hello.router = "round-robin"akka.actor.deployment.service-hello.clustered.replication-factor = 2akka.actor.deployment.service-hello.clustered.preferred-nodes =["node:node1","node:node3"]node.start()helloActor = actorOf[HelloWorld]("service-hello“)
  32. 32. [Akka 1.x] PROBLEM: synchronization ofregistries in a distributed network?POSSIBLE SOLUTION: https://github.com/remeniuk/akka-easyscale
  33. 33. Distributed RegistryNode Anode.store(“my-actor", classOf[MyActor], serializerFor(classOf[MyActor]))Node Bnode.use(“my-actor")
  34. 34. Actor PropsactorOf(Props[TestActor] .withDispatcher(new PinnedDispatcher()) .withFaultHandler( OneForOneStrategy(List(classOf[Exception]), 5, 1000))actorOf(Props(self ⇒ { case “hello" ⇒ self tryReply “hello!"})
  35. 35. Composable Futures !! *HINT: (actor ? message).get
  36. 36. Composable Futuresval future1 = for { a <- (actor ? message1).mapTo[String] b <- (actor ? message2).mapTo[String]} yield a + bval future2 = (actor ? Message3).map(_.toString)val future3 = Futures.find[String](_.isEmpty)( Seq(future1, future2))
  37. 37. BONUS: multi-jvm testing withscalatest in specs2 https://github.com/typesafehub/sbt-multi-jvm https://github.com/jboner/akka/tree/master/akk a-cluster/src/multi-jvm https://github.com/remeniuk/sbt-multi-jvm
  38. 38. GO AND TRY IT!> git clone https://github.com/jboner/akka> sbt

×