108
Above the Clouds: Clustered Akka Jonas Bonér CTO Typesafe Twitter: @jboner

Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Above the Clouds:Clustered Akka

Jonas BonérCTO Typesafe

Twitter : @jboner

Page 2: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

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

Page 3: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akkaIntroducing

Page 4: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Vision

Simpler

Concurrency

Scalability

Fault-tolerance

Page 5: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Vision

...with a single unified

Programming model

Runtime service

Page 6: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Manage system overload

Page 7: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Scale up & Scale out

Page 8: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Replicate and distribute for fault-tolerance

Page 9: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Transparent load balancing

Page 10: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Remote ActorsSo far...

Page 11: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

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

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

Remote Server

Scalable implementation based on NIO (Netty) & Protobuf

Page 12: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor._

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

server part

Remote actor

Page 13: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

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

service ! message

Remote actor

client part

Page 14: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Does not meet the vision

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

So...what’s the problem?

Page 15: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Clustered ActorsIntroducing...

Page 16: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

val actor = actorOf[MyActor]

Address

Bind the actor to a virtual address

Page 17: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

val actor = actorOf[MyActor]

Address

Bind the actor to a virtual address

(“my-service”)

Page 18: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akka { actor { deployment { my-service { router = "least-cpu" clustered { replicas = 3 stateless = on } } } }}

Deployment configuration

Page 19: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akka { actor { deployment { my-service { router = "least-cpu" clustered { replicas = 3 stateless = on } } } }}

Deployment configuration

Address

Page 20: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akka { actor { deployment { my-service { router = "least-cpu" clustered { replicas = 3 stateless = on } } } }}

Deployment configuration

Address Type of load-balancing

Page 21: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akka { actor { deployment { my-service { router = "least-cpu" clustered { replicas = 3 stateless = on } } } }}

Deployment configuration

Address Type of load-balancing

Nr of replicas in cluster

Page 22: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akka { actor { deployment { my-service { router = "least-cpu" clustered { replicas = 3 stateless = on } } } }}

Deployment configuration

Address Type of load-balancing

Nr of replicas in clusterStateless

Page 23: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Deployment

Page 24: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Actor address is virtual and decoupled from how it is deployed

Deployment

Page 25: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Actor address is virtual and decoupled from how it is deployed

•If no deployment configuration exists then actor is deployed as local

Deployment

Page 26: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•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)

Deployment

Page 27: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•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

Deployment

Page 28: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•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

Page 29: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

The runtime provides

Page 30: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Subscription-based cluster membership service

The runtime provides

Page 31: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Subscription-based cluster membership service•Highly available cluster registry for actors

The runtime provides

Page 32: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Subscription-based cluster membership service•Highly available cluster registry for actors•Automatic cluster-wide deployment

The runtime provides

Page 33: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Subscription-based cluster membership service•Highly available cluster registry for actors•Automatic cluster-wide deployment•Automatic replication with fail-over upon node crash

The runtime provides

Page 34: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Subscription-based cluster membership service•Highly available cluster registry for actors•Automatic cluster-wide deployment•Automatic replication with fail-over upon node crash•Transparent and user-configurable load-balancing

The runtime provides

Page 35: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Subscription-based cluster membership service•Highly available cluster registry for actors•Automatic cluster-wide deployment•Automatic replication with fail-over upon node crash•Transparent and user-configurable load-balancing•Transparent adaptive cluster rebalancing

The runtime provides

Page 36: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Subscription-based cluster membership service•Highly available cluster registry for actors•Automatic cluster-wide deployment•Automatic replication with fail-over upon node crash•Transparent and user-configurable load-balancing•Transparent adaptive cluster rebalancing•Leader election

The runtime provides

Page 37: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Subscription-based cluster membership service•Highly available cluster registry for actors•Automatic cluster-wide deployment•Automatic replication with fail-over upon node crash•Transparent and user-configurable load-balancing•Transparent adaptive cluster rebalancing•Leader election•Durable mailboxes - guaranteed delivery

The runtime provides

Page 38: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Subscription-based cluster membership service•Highly available cluster registry for actors•Automatic cluster-wide deployment•Automatic replication with fail-over upon node crash•Transparent and user-configurable load-balancing•Transparent adaptive cluster rebalancing•Leader election•Durable mailboxes - guaranteed delivery•Highly available centralized configuration service

The runtime provides

Page 39: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Subscription-based cluster membership service•Highly available cluster registry for actors•Automatic cluster-wide deployment•Automatic replication with fail-over upon node crash•Transparent and user-configurable load-balancing•Transparent adaptive cluster rebalancing•Leader election•Durable mailboxes - guaranteed delivery•Highly available centralized configuration service•...and more

The runtime provides

Page 40: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Clustering of Stateless Actor

Page 41: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Akka Node

Page 42: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Akka Node

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

ping ! Ball(pong)

Page 43: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Akka Node

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

ping ! Ball(pong)

Ping Pong

Page 44: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Akka Node

AkkaCluster Node

Ping Pong

Page 45: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Akka Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

Ping Pong

Page 46: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

Ping Pong

Page 47: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akka { actor { deployment { ping {} pong { router = "round-robin" clustered { replicas = 3 stateless = on } } } }}

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

Ping Pong

Page 48: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akka { actor { deployment { ping {} pong { router = "round-robin" clustered { replicas = 3 stateless = on } } } }}

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodePing

Pong

Page 49: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akka { actor { deployment { ping {} pong { router = "round-robin" clustered { replicas = 3 stateless = on } } } }}

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodePing

Pong

Pong

Pong

Page 50: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

ZooKeeperZooKeeperZooKeeperEnsemble

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodePing

Pong

Pong

Pong

Page 51: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodePing

Pong

Pong

Pong

Fail-over

Redirect references

Page 52: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Clustering of Stateful Actor

Page 53: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Replication

1Transaction log

Page 54: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akka { actor { deployment { carts { clustered { home = "node:test-node-1" stateless = off } } } }}

Deployment configuration

Page 55: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akka { actor { deployment { carts { clustered { home = "node:test-node-1" stateless = off } } } }}

Deployment configuration

Home node

Page 56: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akka { actor { deployment { carts { clustered { home = "node:test-node-1" stateless = off } } } }}

Deployment configuration

Home node

Stateful

Page 57: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Akka Node

Page 58: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Akka Node

val carts = actorOf[CartRepository](“carts”)val client = actorOf[Pong](“client”)

Page 59: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Akka Node

val carts = actorOf[CartRepository](“carts”)val client = actorOf[Pong](“client”)

Client Carts

Page 60: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Akka Node

AkkaCluster Node

Client Carts

Page 61: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Akka Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

Client Carts

Page 62: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

Client Carts

Page 63: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

akka { actor { deployment { carts { clustered { stateless = off } } } }}

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

Client Carts

Page 64: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient

Carts

Transaction LogTransaction LogTransaction Log

Page 65: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient

Carts

Write behindreplication

Transaction LogTransaction LogTransaction Log

Asynchronouslogging

Page 66: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient

Carts

Write through replication

Client

Transaction LogTransaction LogTransaction Log

Synchronouslogging

Page 67: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient

Carts

Write through replication

Client

Transaction LogTransaction LogTransaction Log

Page 68: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient Carts

Client

Fail-over

Transaction LogTransaction LogTransaction Log

Page 69: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient Carts

Replay transaction log

Client

Fail-over

Transaction LogTransaction LogTransaction Log

Page 70: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient Carts

Client

Fail-over

Transaction LogTransaction LogTransaction Log

Page 71: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient Carts

Client

Fail-over

Redirect references

Transaction LogTransaction LogTransaction Log

Page 72: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Transaction logStore messages

Page 73: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Transaction logStore messages

Cart Created

Page 74: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Transaction logStore messages

Cart Created

Added 2 Socks

Page 75: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Transaction logStore messages

Cart Created

Added 2 Socks

Added 2 Shirts

Page 76: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Transaction logStore messages

Cart Created

Added 2 Socks

Added 2 Shirts

Shipping Info Added

Page 77: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Transaction logReplaying messages

Page 78: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Transaction logReplaying messages

1 2 3 4 5 6 7

Page 79: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Transaction logRolling Snapshot

1 2 100...

Page 80: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Transaction logRolling Snapshot

1 2 100...

CartsSnapshot

Page 81: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Transaction logRolling Snapshot

1 2 100 101 102 103 104...

CartsSnapshot

Page 82: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Replication

2Data Grid

Page 83: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Actor state•Stored in “external” Data Grid•Transactional (distributed STM)•Versioned•Replicated•QueriesImplementations•Custom Akka Data Grid•SPI for third-party Data Grids

Data Grid

Page 84: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient

Carts

Page 85: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient

Carts

akka { actor { deployment { carts { clustered { stateless = off replicas = 3 } } } }}

Page 86: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient

Carts

Transaction LogTransaction LogData Grid

Page 87: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient

Carts

Transaction LogTransaction LogData Grid

Take snapshot

Store snapshot in Data Grid

CartsCartsCarts

Page 88: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient

Fail-over

Transaction LogTransaction LogData Grid

Carts

CartsCartsCarts

Page 89: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient

Read in snapshot from Data Grid

Fail-over

Transaction LogTransaction LogData Grid

CartsCarts

CartsCarts

Page 90: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster Node

AkkaCluster NodeClient

Fail-over

Redirect references

Transaction LogTransaction LogData Grid

Carts

CartsCarts

Page 91: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

For power users: Cluster API

Page 92: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

For power users: Cluster API

Page 93: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

cluster.start()

For power users: Cluster API

Page 94: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

cluster.start() cluster.shutdown()

For power users: Cluster API

Page 95: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

cluster.start() cluster.shutdown()

cluster register (new ChangeListener {

For power users: Cluster API

Page 96: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

cluster.start() cluster.shutdown()

cluster register (new ChangeListener { def nodeConnected(node: String, client: ClusterNode) { ... }

For power users: Cluster API

Page 97: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

cluster.start() cluster.shutdown()

cluster register (new ChangeListener { def nodeConnected(node: String, client: ClusterNode) { ... } ...

For power users: Cluster API

Page 98: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

cluster.start() cluster.shutdown()

cluster register (new ChangeListener { def nodeConnected(node: String, client: ClusterNode) { ... } ... })

For power users: Cluster API

Page 99: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

cluster.start() cluster.shutdown()

cluster register (new ChangeListener { def nodeConnected(node: String, client: ClusterNode) { ... } ... })

cluster store actorRef

For power users: Cluster API

Page 100: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

cluster.start() cluster.shutdown()

cluster register (new ChangeListener { def nodeConnected(node: String, client: ClusterNode) { ... } ... })

cluster store actorRef cluster remove actorAddress

For power users: Cluster API

Page 101: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

cluster.start() cluster.shutdown()

cluster register (new ChangeListener { def nodeConnected(node: String, client: ClusterNode) { ... } ... })

cluster store actorRef cluster remove actorAddress

val actorRef = cluster use actorAddress

For power users: Cluster API

Page 102: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

cluster.start() cluster.shutdown()

cluster register (new ChangeListener { def nodeConnected(node: String, client: ClusterNode) { ... } ... })

cluster store actorRef cluster remove actorAddress

val actorRef = cluster use actorAddress val actorRef = cluster ref (actorAddress, router)

For power users: Cluster API

Page 103: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

cluster.start() cluster.shutdown()

cluster register (new ChangeListener { def nodeConnected(node: String, client: ClusterNode) { ... } ... })

cluster store actorRef cluster remove actorAddress

val actorRef = cluster use actorAddress val actorRef = cluster ref (actorAddress, router)

cluster migrate (fromNode, toNode, actorAddress)

For power users: Cluster API

Page 104: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

import Actor.cluster

cluster.start() cluster.shutdown()

cluster register (new ChangeListener { def nodeConnected(node: String, client: ClusterNode) { ... } ... })

cluster store actorRef cluster remove actorAddress

val actorRef = cluster use actorAddress val actorRef = cluster ref (actorAddress, router)

cluster migrate (fromNode, toNode, actorAddress)

cluster send (() => { ... }, nrReplicas) map (_.result)

For power users: Cluster API

Page 105: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•Direct•Random•Round robin•Least CPU (soon)•Least RAM (soon)•Least messages (soon)•Custom

Routers

Page 106: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

•File-based•Redis-based•Beanstalk-based•MongoDB-based•ZooKeeper-based•Cassandra-based (soon)•AMQP-based (soon)•JMS-based (soon)

Durable Mailboxes

Page 107: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

Part of Akka 2.0ETA mid fall

http://akka.io

Page 108: Above the Clouds: Clustered Akkadays2011.scala-lang.org/sites/days2011/files/43... · 2011-09-09 · Fault-tolerance. Vision...with a single unified Programming model Runtime service

EOF