Top Banner
Above the Clouds: Introducing Akka Jonas Bonér CTO Typesafe Twitter: @jboner torsdag 13 oktober 11
93

Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Jan 30, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Above the Clouds:Introducing Akka

Jonas BonérCTO Typesafe

Twitter : @jboner

torsdag 13 oktober 11

Page 2: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

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

torsdag 13 oktober 11

Page 3: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

akkaIntroducing

torsdag 13 oktober 11

Page 4: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Vision

Simpler

Concurrency

Scalability

Fault-tolerance

torsdag 13 oktober 11

Page 5: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Vision

...with a single unified

Programming model

Runtime service

torsdag 13 oktober 11

Page 6: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Manage system overload

torsdag 13 oktober 11

Page 7: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Scale up & Scale out

torsdag 13 oktober 11

Page 8: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Replicate and distribute for fault-tolerance

torsdag 13 oktober 11

Page 9: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Transparent load balancingtorsdag 13 oktober 11

Page 10: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

CORE SERVICES

ARCHITECTURE

torsdag 13 oktober 11

Page 11: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ADD-ON MODULES

ARCHITECTURE

torsdag 13 oktober 11

Page 12: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ARCHITECTURE

CLOUDY AKKA

torsdag 13 oktober 11

Page 13: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

FINANCE

• Stock trend Analysis & Simulation

• Event-driven messaging systems

BETTING & GAMING

• Massive multiplayer online gaming

• High throughput and transactional betting

TELECOM

• Streaming media network gateways

SIMULATION

• 3D simulation engines

E-COMMERCE

• Social media community sites

SOME EXAMPLES:

WHERE IS AKKA USED?

torsdag 13 oktober 11

Page 14: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

What is an Actor?

torsdag 13 oktober 11

Page 15: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Behavior

State

Actor

torsdag 13 oktober 11

Page 16: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Event-drivenThread

Behavior

State

Actor

torsdag 13 oktober 11

Page 17: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Event-drivenThread

Behavior

State

Actor

torsdag 13 oktober 11

Page 18: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Event-drivenThread

Behavior

State

Actor

torsdag 13 oktober 11

Page 19: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Event-drivenThread

Behavior

State

Actor

torsdag 13 oktober 11

Page 20: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Event-drivenThread

Behavior

State

Actor

torsdag 13 oktober 11

Page 21: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Behavior

State

Actor

torsdag 13 oktober 11

Page 22: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Event-drivenThread

Behavior

State

Actor

torsdag 13 oktober 11

Page 23: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Akka Actorsone tool in the toolbox

torsdag 13 oktober 11

Page 24: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

case object Tick

class Counter extends Actor { var counter = 0

def receive = { case Tick => counter += 1 println(counter) }}

Actors

torsdag 13 oktober 11

Page 25: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

val counter = actorOf[Counter]

Create Actors

counter is an ActorRef

torsdag 13 oktober 11

Page 26: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

val counter = actorOf[Counter].start

Start actors

torsdag 13 oktober 11

Page 27: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

val counter = actorOf[Counter].startcounter.stop

Stop actors

torsdag 13 oktober 11

Page 28: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

counter ! Tick

Send: !

fire-forget

torsdag 13 oktober 11

Page 29: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

// returns a futureval future = actor ? Message

future onComplete { f => f.value}

Send: ?

returns the Future directly

torsdag 13 oktober 11

Page 30: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Futureval future1, future2, future3 = Future.empty[String]

future1.awaitfuture2 onComplete { f => ... }future3 onResult { ... } onException { ... } onTimeout { ... }future1 foreach { ... }future1 map { ... }future1 flatMap { ... }future1 filter { ... }

torsdag 13 oktober 11

Page 31: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

val f0 = Future { ... }

Future.firstCompletedOf(futures)Future.reduce(futures)((x, y) => ..)Future.fold(zero)(futures)((x, y) => ...)Future.find { ... }Future.sequence { ... }Future.traverse { ... }

Future

torsdag 13 oktober 11

Page 32: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Promise

promise1.completeWithResult(...) promise2.completeWithException(...)promise3.completeWith(promise2)

The write side of the Future

torsdag 13 oktober 11

Page 33: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Dataflowimport Future.flow

val x, y, z = Promise[Int]()

flow { z << x() + y() println("z = " + z())}flow { x << 40 }flow { y << 2 }

torsdag 13 oktober 11

Page 34: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

class SomeActor extends Actor { def receive = { case User(name) => // use reply self.reply(“Hi ” + name) }}

Reply

torsdag 13 oktober 11

Page 35: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

HotSwap

self become { // new body case NewMessage => ... }

torsdag 13 oktober 11

Page 36: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

HotSwap

self.unbecome()

torsdag 13 oktober 11

Page 37: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

class MyActor extends Actor { self.dispatcher = Dispatchers .newPinnedDispatcher(self) ...}

actor.dispatcher = dispatcher // before started

Set dispatcher

torsdag 13 oktober 11

Page 38: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Remote Actors

torsdag 13 oktober 11

Page 39: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

// use host & port in configActor.remote.start()

Actor.remote.start("localhost", 2552)

Remote Server

Scalable implementation based on NIO (Netty) & Protobuf

torsdag 13 oktober 11

Page 40: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

import Actor._

remote.register(“service:id”, actorOf[MyService])

Register and manage actor on serverclient gets “dumb” proxy handle

server part

torsdag 13 oktober 11

Page 41: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

val service = remote.actorFor( “service:id”, “darkstar”, 9999)

service ! message

client part

torsdag 13 oktober 11

Page 42: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

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

Remoting in Akka 1.2

torsdag 13 oktober 11

Page 43: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Clustered Actors(in development for upcoming Akka 2.x)

torsdag 13 oktober 11

Page 44: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

val actor = actorOf[MyActor](“my-service”)

Address

Bind the actor to a virtual address

torsdag 13 oktober 11

Page 45: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

•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

Deployment

torsdag 13 oktober 11

Page 46: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

akka { actor { deployment { my-service { router = "least-cpu" failure-detector = "accrual"

clustered { nr-of-instances = 3

replication { storage = "transaction-log" strategy = "write-through" } } } } }}

Deployment configuration

torsdag 13 oktober 11

Page 47: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

•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

The runtime provides

torsdag 13 oktober 11

Page 48: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Akka Node

torsdag 13 oktober 11

Page 49: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Akka Node

val ping = actorOf[Ping](“ping”)val pong = actorOf[Pong](“pong”)

ping ! Ball(pong)

torsdag 13 oktober 11

Page 50: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Akka Node

val ping = actorOf[Ping](“ping”)val pong = actorOf[Pong](“pong”)

ping ! Ball(pong)

Ping Pong

torsdag 13 oktober 11

Page 51: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Akka Node

AkkaCluster Node

Ping Pong

torsdag 13 oktober 11

Page 52: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Akka Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

Ping Pong

torsdag 13 oktober 11

Page 53: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

Ping Pong

torsdag 13 oktober 11

Page 54: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

akka { actor { deployment { ping {} pong { router = "round-robin" clustered { nr-of-instances = 3 } } } }}

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

Ping Pong

torsdag 13 oktober 11

Page 55: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

akka { actor { deployment { ping {} pong { router = "round-robin" clustered { nr-of-instances = 3 } } } }}

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodePing

Pong

torsdag 13 oktober 11

Page 56: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

akka { actor { deployment { ping {} pong { router = "round-robin" clustered { nr-of-instances = 3 } } } }}

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodePing

Pong

Pong

Pong

torsdag 13 oktober 11

Page 57: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

akka { actor { deployment { ping {} pong { router = "round-robin" clustered { nr-of-instances = 3 } } } }}

ZooKeeperZooKeeperZooKeeperEnsemble

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodePing

Pong

Pong

Pong

torsdag 13 oktober 11

Page 58: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Let it crash fault-tolerance

torsdag 13 oktober 11

Page 59: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

The

Erlangmodel

torsdag 13 oktober 11

Page 60: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

9 nines

torsdag 13 oktober 11

Page 61: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

...let’s take a standard OO application

torsdag 13 oktober 11

Page 62: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

torsdag 13 oktober 11

Page 63: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Which components have critically important state

and explicit error handling?

torsdag 13 oktober 11

Page 64: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

torsdag 13 oktober 11

Page 65: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

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

torsdag 13 oktober 11

Page 66: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

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

torsdag 13 oktober 11

Page 67: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

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

Must be protected

by any means

torsdag 13 oktober 11

Page 68: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Fault-tolerant onion-layered Error Kernel

torsdag 13 oktober 11

Page 69: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 70: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 71: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 72: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 73: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 74: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 75: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 76: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 77: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 78: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 79: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 80: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 81: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 82: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 83: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

ErrorKernel

torsdag 13 oktober 11

Page 84: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

torsdag 13 oktober 11

Page 85: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

torsdag 13 oktober 11

Page 86: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Node 1 Node 2

torsdag 13 oktober 11

Page 87: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

link(actor)unlink(actor)

startLink(actor)spawnLink[MyActor]

Linking

torsdag 13 oktober 11

Page 88: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

AllForOneStrategy( errors, maxNrOfRetries, withinTimeRange)

OneForOneStrategy( errors, maxNrOfRetries, withinTimeRange)

Fault handlers

torsdag 13 oktober 11

Page 89: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

class  Supervisor  extends  Actor  {    faultHandler  =  AllForOneStrategy(        List(classOf[IllegalStateException])          5,  5000))

   def  receive  =  {        case  Register(actor)  =>  link(actor)    }}

Supervision

torsdag 13 oktober 11

Page 90: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

class FaultTolerantService extends Actor { ... override def preRestart(reason: Throwable) = { ... // clean up before restart } override def postRestart(reason: Throwable) = { ... // init after restart }}

Manage failure

torsdag 13 oktober 11

Page 91: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

AMQPDataflow

Security

...and much much more

HTTP

Guice

scalaz

FSMSTM

Spring

Camel

OSGi

Microkernel

torsdag 13 oktober 11

Page 92: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

Get it and learn morehttp://akka.io

torsdag 13 oktober 11

Page 93: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-amsterdam-2011/slides/JonasBonr_AboveTheCloudsIntroducingAkka.pdfThe problem It is way too hard to build: 1.

EOFtorsdag 13 oktober 11