SlideShare ist ein Scribd-Unternehmen logo
1 von 176
Downloaden Sie, um offline zu lesen
Building 
Reactive Systems 
with Akka 
Jonas Bonér 
Typesafe 
CTO & co-founder 
Twitter: @jboner
The rules of the game 
have changed
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors 
Expensive RAM
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors 
Expensive RAM Cheap RAM
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors 
Expensive RAM Cheap RAM 
Expensive disk
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors 
Expensive RAM Cheap RAM 
Expensive disk Cheap disk
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors 
Expensive RAM Cheap RAM 
Expensive disk Cheap disk 
Slow networks
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors 
Expensive RAM Cheap RAM 
Expensive disk Cheap disk 
Slow networks Fast networks
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors 
Expensive RAM Cheap RAM 
Expensive disk Cheap disk 
Slow networks Fast networks 
Few concurrent users
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors 
Expensive RAM Cheap RAM 
Expensive disk Cheap disk 
Slow networks Fast networks 
Few concurrent users Lots of concurrent users
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors 
Expensive RAM Cheap RAM 
Expensive disk Cheap disk 
Slow networks Fast networks 
Few concurrent users Lots of concurrent users 
Small data sets
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors 
Expensive RAM Cheap RAM 
Expensive disk Cheap disk 
Slow networks Fast networks 
Few concurrent users Lots of concurrent users 
Small data sets Large data sets
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors 
Expensive RAM Cheap RAM 
Expensive disk Cheap disk 
Slow networks Fast networks 
Few concurrent users Lots of concurrent users 
Small data sets Large data sets 
Latency in seconds
3 
Apps in the 60s-90s 
were written for 
Apps today 
are written for 
Single machines Clusters of machines 
Single core processors Multicore processors 
Expensive RAM Cheap RAM 
Expensive disk Cheap disk 
Slow networks Fast networks 
Few concurrent users Lots of concurrent users 
Small data sets Large data sets 
Latency in seconds Latency in milliseconds
Cost Gravity is at Work 
X
Cost Gravity is at Work 
X
Reactive applications share four traits 
Reactive 
Applications 
5
Reactive applications enrich the user 
experience with low latency response.
Responsive 
• Real-time, engaging, rich and collaborative 
• Create an open and ongoing dialog with users 
• More efficient workflow; inspires a feeling of connectedness 
• Fully Reactive enabling push instead of pull 
7 
“The move to these technologies is already paying off. 
Response times are down for processor intensive code–such as image 
and PDF generation–by around 75%.” 
Brian Pugh, VP of Engineering, Lucid Software
Reactive applications react to 
changes in the world around them.
Message-Driven 
• Loosely coupled architecture, easier to extend, maintain, evolve 
• Asynchronous and non-blocking 
• Concurrent by design, immutable state 
• Lower latency and higher throughput 
9 
“Clearly, the goal is to do these operations concurrently and 
non-blocking, so that entire blocks of seats or sections are not locked. 
We’re able to find and allocate seats under load in less than 20ms 
without trying very hard to achieve it.” 
Andrew Headrick, Platform Architect, Ticketfly
Introducing the Actor Model
11 
The Actor Model
11 
The Actor Model 
A computational model that embodies:
11 
The Actor Model 
A computational model that embodies: 
✓ Processing
11 
The Actor Model 
A computational model that embodies: 
✓ Processing 
✓ Storage
11 
The Actor Model 
A computational model that embodies: 
✓ Processing 
✓ Storage 
✓ Communication
A computational model that embodies: 
✓ Processing 
✓ Storage 
✓ Communication 
Supports 3 axioms—when an Actor receives a message it can: 
11 
The Actor Model
A computational model that embodies: 
✓ Processing 
✓ Storage 
✓ Communication 
Supports 3 axioms—when an Actor receives a message it can: 
1. Create new Actors 
11 
The Actor Model
A computational model that embodies: 
✓ Processing 
✓ Storage 
✓ Communication 
Supports 3 axioms—when an Actor receives a message it can: 
1. Create new Actors 
2. Send messages to Actors it knows 
11 
The Actor Model
A computational model that embodies: 
✓ Processing 
✓ Storage 
✓ Communication 
Supports 3 axioms—when an Actor receives a message it can: 
1. Create new Actors 
2. Send messages to Actors it knows 
3. Designate how it should handle the next message it receives 
11 
The Actor Model
The essence of an actor 
from Akka’s perspective 
0. DEFINE 
1. CREATE 
2. SEND 
3. BECOME 
4. SUPERVISE 
12
public class Greeting implements Serializable { 
public final String who; 
public Greeting(String who) { this.who = who; } 
} 
! 
public class Greeter extends AbstractActor {{ 
receive(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Hello " + m.who); 
}). 
matchAny(unknown -> { 
println(“Unknown message " + unknown); 
}).build()); 
}} 
0. DEFINE 
X
public class Greeting implements Serializable { 
public final String who; 
public Greeting(String who) { this.who = who; } 
} 
! 
public class Greeter extends AbstractActor {{ 
receive(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Hello " + m.who); 
}). 
matchAny(unknown -> { 
println(“Unknown message " + unknown); 
}).build()); 
}} 
0. DEFINE 
X 
Define the message(s) the Actor 
should be able to respond to
public class Greeting implements Serializable { 
public final String who; 
public Greeting(String who) { this.who = who; } 
} 
! 
public class Greeter extends AbstractActor {{ 
receive(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Hello " + m.who); 
}). 
matchAny(unknown -> { 
println(“Unknown message " + unknown); 
}).build()); 
}} 
0. DEFINE 
X 
Define the message(s) the Actor 
should be able to respond to 
Define the Actor class
public class Greeting implements Serializable { 
public final String who; 
public Greeting(String who) { this.who = who; } 
} 
! 
public class Greeter extends AbstractActor {{ 
receive(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Hello " + m.who); 
}). 
matchAny(unknown -> { 
println(“Unknown message " + unknown); 
}).build()); 
}} 
0. DEFINE 
X 
Define the message(s) the Actor 
should be able to respond to 
Define the Actor class 
Define the Actor’s behavior
1. CREATE 
ActorSystem system = ActorSystem.create("MySystem"); 
! 
ActorRef greeter = 
system.actorOf(Props.create(Greeter.class), “greeter");
1. CREATE 
Create an Actor system 
ActorSystem system = ActorSystem.create("MySystem"); 
! 
ActorRef greeter = 
system.actorOf(Props.create(Greeter.class), “greeter");
1. CREATE 
Create an Actor system 
Actor configuration 
ActorSystem system = ActorSystem.create("MySystem"); 
! 
ActorRef greeter = 
system.actorOf(Props.create(Greeter.class), “greeter");
1. CREATE 
Create an Actor system 
Actor configuration 
ActorSystem system = ActorSystem.create("MySystem"); 
! 
ActorRef greeter = 
system.actorOf(Props.create(Greeter.class), “greeter"); 
Give it a name
1. CREATE 
Create an Actor system 
ActorSystem system = ActorSystem.create("MySystem"); 
! 
ActorRef greeter = 
system.actorOf(Props.create(Greeter.class), “greeter"); 
Give it a name 
Create the Actor 
Actor configuration
1. CREATE 
Create an Actor system 
ActorSystem system = ActorSystem.create("MySystem"); 
! 
ActorRef greeter = 
system.actorOf(Props.create(Greeter.class), “greeter"); 
Give it a name 
You get an ActorRef back 
Create the Actor 
Actor configuration
0. DEFINE 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
13 
case Greeting(who) => log.info(s"Hello ${who}") 
} 
}
0. DEFINE 
13 
Define the message(s) the Actor 
should be able to respond to 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
case Greeting(who) => log.info(s"Hello ${who}") 
} 
}
0. DEFINE 
13 
Define the message(s) the Actor 
should be able to respond to 
Define the Actor class 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
case Greeting(who) => log.info(s"Hello ${who}") 
} 
}
0. DEFINE 
13 
Define the message(s) the Actor 
should be able to respond to 
Define the Actor class 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
case Greeting(who) => log.info(s"Hello ${who}") 
} 
} 
Define the Actor’s behavior
1. CREATE 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
case Greeting(who) => log.info("Hello " + who) 
} 
} 
! 
val system = ActorSystem("MySystem") 
val greeter = system.actorOf(Props[GreetingActor], name = "greeter")
1. CREATE 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
Create an Actor system 
case Greeting(who) => log.info("Hello " + who) 
} 
} 
! 
val system = ActorSystem("MySystem") 
val greeter = system.actorOf(Props[GreetingActor], name = "greeter")
1. CREATE 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
Create an Actor system 
case Greeting(who) => log.info("Hello " } 
Actor configuration 
+ who) 
} 
! 
val system = ActorSystem("MySystem") 
val greeter = system.actorOf(Props[GreetingActor], name = "greeter")
1. CREATE 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
case Greeting(who) => log.info("Hello " + who) 
} 
} 
! 
val system = ActorSystem("MySystem") 
val greeter = system.actorOf(Props[GreetingActor], name = "greeter") 
Give it a name 
Create an Actor system 
Actor configuration
1. CREATE 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
Create an Actor system 
case Greeting(who) => log.info("Hello " } 
Actor configuration 
+ who) 
} 
! 
val system = ActorSystem("MySystem") 
val greeter = system.actorOf(Props[GreetingActor], name = "greeter") 
Give it a name 
Create the Actor
1. CREATE 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
Create an Actor system 
case Greeting(who) => log.info("Hello " } 
Actor configuration 
+ who) 
} 
! 
val system = ActorSystem("MySystem") 
val greeter = system.actorOf(Props[GreetingActor], name = "greeter") 
Give it a name 
You get an ActorRef bCarcekate the Actor
Actors can form hierarchies 
Guardian System Actor
Actors can form hierarchies 
Guardian System Actor 
system.actorOf(Props.create(Foo.class), “Foo”);
Actors can form hierarchies 
Foo 
Guardian System Actor 
system.actorOf(Props.create(Foo.class), “Foo”);
Actors can form hierarchies 
Foo 
Guardian System Actor 
context().actorOf(Props.create(A.class), “A”);
Actors can form hierarchies 
A 
Foo 
Guardian System Actor 
context().actorOf(Props.create(A.class), “A”);
Actors can form hierarchies 
A 
Foo Bar 
B 
C 
B 
E 
A 
D 
C 
Guardian System Actor
Actors can form hierarchies 
Guardian System Actor
Actors can form hierarchies 
Guardian System Actor 
system.actorOf(Props[Foo], “Foo”)
Actors can form hierarchies 
Foo 
Guardian System Actor 
system.actorOf(Props[Foo], “Foo”)
Actors can form hierarchies 
Foo 
Guardian System Actor 
context.actorOf(Props[A], “A”)
Actors can form hierarchies 
A 
Foo 
Guardian System Actor 
context.actorOf(Props[A], “A”)
Actors can form hierarchies 
A 
Foo Bar 
B 
C 
B 
E 
A 
D 
C 
Guardian System Actor
Name resolution—like a file-system 
A 
Foo Bar 
B 
C 
B 
E 
A 
D 
C 
Guardian System Actor
Name resolution—like a file-system 
A 
Foo Bar 
B 
C 
B 
E 
A 
D 
C 
/Foo 
Guardian System Actor
Name resolution—like a file-system 
A 
Foo Bar 
B 
C 
B 
E 
A 
D 
C 
/Foo 
/Foo/A 
Guardian System Actor
Name resolution—like a file-system 
A 
Foo Bar 
B 
C 
B 
E 
A 
D 
C 
/Foo 
/Foo/A 
/Foo/A/B 
Guardian System Actor
Name resolution—like a file-system 
A 
Foo Bar 
B 
C 
B 
E 
A 
D 
C 
/Foo 
/Foo/A 
/Foo/A/B 
/Foo/A/D 
Guardian System Actor
2. SEND 
X 
greeter.tell(new Greeting("Charlie Parker”), sender);
2. SEND 
X 
greeter.tell(new Greeting("Charlie Parker”), sender); 
Send the message asynchronously
2. SEND 
X 
Pass in the sender ActorRef 
greeter.tell(new Greeting("Charlie Parker”), sender); 
Send the message asynchronously
Bring it together 
X 
public class Greeting implements Serializable { 
public final String who; 
public Greeting(String who) { this.who = who; } 
} 
public class Greeter extends AbstractActor {{ 
receive(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Hello " + m.who); 
}). 
matchAny(unknown -> { 
println(“Unknown message " + unknown); 
}).build()); 
} 
}} 
! 
ActorSystem system = ActorSystem.create("MySystem"); 
ActorRef greeter = system.actorOf(Props.create(Greeter.class), “greeter"); 
greeter.tell(new Greeting(“Charlie Parker”));
2. SEND 
17 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
case Greeting(who) => log.info(s”Hello ${who}") 
} 
} 
! 
val system = ActorSystem("MySystem") 
val greeter = system.actorOf(Props[GreetingActor], name = "greeter") 
greeter ! Greeting("Charlie Parker")
2. SEND 
17 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
case Greeting(who) => log.info(s”Hello ${who}") 
} 
} 
! 
val system = ActorSystem("MySystem") 
val greeter = system.actorOf(Props[GreetingActor], name = "greeter") 
greeter ! Greeting("Charlie Parker") 
Send the message asynchronously
Bring it together 
18 
case class Greeting(who: String) 
! 
class GreetingActor extends Actor with ActorLogging { 
def receive = { 
case Greeting(who) => log.info(s”Hello ${who}") 
} 
} 
! 
val system = ActorSystem("MySystem") 
val greeter = system.actorOf(Props[GreetingActor], name = "greeter") 
greeter ! Greeting("Charlie Parker")
DEMO TIME A simple game of ping pong
3. BECOME 
X 
public class Greeter extends AbstractActor { 
public Greeter { 
receive(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Hello " + m.who); 
}). 
matchEquals(“stop" -> { 
!!!! }).build(); 
} 
}
3. BECOME 
X 
public class Greeter extends AbstractActor { 
public Greeter { 
receive(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Hello " + m.who); 
}). 
matchEquals(“stop" -> { 
!!!! }).build(); 
} 
} 
context().become(ReceiveBuilder.
3. BECOME 
X 
public class Greeter extends AbstractActor { 
public Greeter { 
receive(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Hello " + m.who); 
}). 
matchEquals(“stop" -> { 
!!!! }).build(); 
} 
} 
Change the behavior 
context().become(ReceiveBuilder.
3. BECOME 
X 
public class Greeter extends AbstractActor { 
public Greeter { 
receive(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Hello " + m.who); 
}). 
matchEquals(“stop" -> { 
!!!! }).build(); 
} 
} 
Change the behavior 
context().become(ReceiveBuilder. 
match(Greeting.class, m -> {
3. BECOME 
X 
public class Greeter extends AbstractActor { 
public Greeter { 
receive(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Hello " + m.who); 
}). 
matchEquals(“stop" -> { 
!!!! }).build(); 
} 
} 
Change the behavior 
context().become(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Go Away!”);
3. BECOME 
X 
public class Greeter extends AbstractActor { 
public Greeter { 
receive(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Hello " + m.who); 
}). 
matchEquals(“stop" -> { 
!!!! }).build(); 
} 
} 
Change the behavior 
context().become(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Go Away!”); 
}).build());
3. BECOME 
X 
public class Greeter extends AbstractActor { 
public Greeter { 
receive(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Hello " + m.who); 
}). 
matchEquals(“stop" -> { 
!!!! }).build(); 
} 
} 
Change the behavior 
context().become(ReceiveBuilder. 
match(Greeting.class, m -> { 
println(“Go Away!”); 
}).build());
3. BECOME 
19 
class GreetingActor extends Actor with ActorLogging { 
def receive = happy 
! 
val happy: Receive = { 
case Greeting(who) => log.info(s”Hello ${who}") 
case Angry => context become angry 
} 
! 
val angry: Receive = { 
case Greeting(_) => log.info("Go away!") 
case Happy => context become happy 
} 
}
3. BECOME 
19 
class GreetingActor extends Actor with ActorLogging { 
def receive = happy 
! 
val happy: Receive = { 
case Greeting(who) => log.info(s”Hello ${who}") 
case Angry => context become angry 
} 
! 
val angry: Receive = { 
case Greeting(_) => log.info("Go away!") 
case Happy => context become happy 
} 
} 
Redefine the behavior
Reactive applications are architected 
to handle failure at all levels.
Resilient 
• Failure is embraced as a natural state in the app lifecycle 
• Resilience is a first-class construct 
• Failure is detected, isolated, and managed 
• Applications self heal 
21 
“The Typesafe Reactive Platform helps us maintain a very 
aggressive development and deployment cycle, all in a fail-forward manner. 
It’s now the default choice for developing all new services.” 
Peter Hausel, VP Engineering, Gawker Media
Think Vending Machine
Think Vending Machine 
Coffee 
Programmer Machine
Think Vending Machine 
Coffee 
Inserts coins 
Programmer Machine
Think Vending Machine 
Coffee 
Inserts coins 
Add more coins 
Programmer Machine
Think Vending Machine 
Coffee 
Inserts coins 
Add more coins 
Programmer Machine 
Gets coffee
Think Vending Machine 
Coffee 
Programmer Machine
Think Vending Machine 
Coffee 
Inserts coins 
Programmer Machine
Think Vending Machine 
Coffee 
Inserts coins 
Out of coffee beans error 
Programmer Machine
Think Vending Machine 
Coffee 
Inserts coins 
OutW of corfofeen begans error 
Programmer Machine
Think Vending Machine 
Coffee 
Inserts coins 
Programmer Machine
Think Vending Machine 
Coffee 
Inserts coins 
Out of 
coffee beans 
error 
Programmer Machine
Think Vending Machine 
Service 
Guy 
Coffee 
Inserts coins 
Out of 
coffee beans 
error 
Programmer Machine
Think Vending Machine 
Service 
Guy 
Coffee 
Inserts coins 
Out of 
coffee beans 
error 
Programmer Machine 
Adds 
more 
beans
Think Vending Machine 
Service 
Guy 
Coffee 
Inserts coins 
Programmer Machine 
Gets coffee 
Out of 
coffee beans 
error 
Adds 
more 
beans
The Right Way 
Client Service
The Right Way 
Request 
Client Service
The Right Way 
Request 
Client Service 
Response
The Right Way 
Request 
Validation Error 
Client Service 
Response
The Right Way 
Request 
Validation Error 
Client Service 
Response 
Application 
Error
The Right Way 
Supervisor 
Request 
Validation Error 
Client Service 
Response 
Application 
Error
The Right Way 
Supervisor 
Request 
Validation Error 
Client Service 
Response 
Application 
Error 
Manages 
Failure
Use Bulkheads 
• Isolate the failure 
• Compartmentalize 
• Manage failure locally 
• Avoid cascading failures
Use Bulkheads 
• Isolate the failure 
• Compartmentalize 
• Manage failure locally 
• Avoid cascading failures
Enter Supervision
Enter Supervision
Supervisor hierarchies 
A 
Foo Bar 
B 
C 
B 
E 
A 
D 
C 
Automatic and mandatory supervision
4. SUPERVISE 
X 
Every single actor has a default supervisor strategy. 
Which is usually sufficient. 
But it can be overridden. 
class Supervisor extends UntypedActor { 
private SupervisorStrategy strategy = new OneForOneStrategy( 
10, Duration.create(1, TimeUnit.MINUTES), 
DeciderBuilder. 
match(ArithmeticException.class, e -> resume()). 
match(NullPointerException.class, e -> restart()). 
matchAny( e -> escalate()). 
build()); 
! 
@Override public SupervisorStrategy supervisorStrategy() { 
return strategy; 
}
4. SUPERVISE 
X 
class Supervisor extends UntypedActor { 
private SupervisorStrategy strategy = new OneForOneStrategy( 
10, Duration.create(1, TimeUnit.MINUTES), 
DeciderBuilder. 
match(ArithmeticException.class, e -> resume()). 
match(NullPointerException.class, e -> restart()). 
matchAny( e -> escalate()). 
build()); 
! 
@Override public SupervisorStrategy supervisorStrategy() { 
return strategy; 
} 
ActorRef worker = context.actorOf( 
Props.create(Worker.class), "worker"); 
public void onReceive(Object i) throws Exception { 
… 
} 
}
Monitor through Death Watch 
X 
public class WatchActor extends AbstractActor { 
final ActorRef child = context().actorOf(Props.empty(), "child"); 
! 
public WatchActor() { 
context().watch(child); 
receive(ReceiveBuilder. 
match(Terminated.class, 
t -> t.actor().equals(child), 
t -> { 
… // handle termination 
}).build() 
); 
} 
}
Monitor through Death Watch 
X 
public class WatchActor extends AbstractActor { 
final ActorRef child = context().actorOf(Props.empty(), "child"); 
! 
public WatchActor() { 
context().watch(child); 
receive(ReceiveBuilder. 
match(Terminated.class, 
t -> t.actor().equals(child), 
t -> { 
… // handle termination 
}).build() 
); 
} 
} 
Create a child actor
Monitor through Death Watch 
X 
public class WatchActor extends AbstractActor { 
final ActorRef child = context().actorOf(Props.empty(), "child"); 
! 
public WatchActor() { 
context().watch(child); 
receive(ReceiveBuilder. 
match(Terminated.class, 
t -> t.actor().equals(child), 
t -> { 
… // handle termination 
}).build() 
); 
} 
} 
Create a child actor 
Watch it
Monitor through Death Watch 
X 
public class WatchActor extends AbstractActor { 
final ActorRef child = context().actorOf(Props.empty(), "child"); 
! 
public WatchActor() { 
context().watch(child); 
receive(ReceiveBuilder. 
match(Terminated.class, 
t -> t.actor().equals(child), 
t -> { 
… // handle termination 
}).build() 
); 
} 
} 
Create a child actor 
Watch it 
Handle termination message
4. SUPERVISE 
29 
Every single actor has a default 
supervisor strategy. 
Which is usually sufficient. 
But it can be overridden.
4. SUPERVISE 
29 
Every single actor has a default 
supervisor strategy. 
Which is usually sufficient. 
But it can be overridden. 
class Supervisor extends Actor { 
override val supervisorStrategy = 
OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) { 
case _: ArithmeticException => Resume 
case _: NullPointerException => Restart 
case _: Exception => Escalate 
} 
! 
val worker = context.actorOf(Props[Worker], name = "worker") 
! 
def receive = {
4. SUPERVISE 
29 
class Supervisor extends Actor { 
override val supervisorStrategy = 
OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) { 
case _: ArithmeticException => Resume 
case _: NullPointerException => Restart 
case _: Exception => Escalate 
} 
! 
val worker = context.actorOf(Props[Worker], name = "worker") 
! 
def receive = { 
case n: Int => worker forward n 
} 
} 
!
Cleanup & (Re)initialization 
30 
class Worker extends Actor { 
... 
override def preRestart( 
reason: Throwable, message: Option[Any]) { 
... // clean up before restart 
} 
override def postRestart(reason: Throwable) { 
... // init after restart 
} 
}
Monitor through Death Watch 
31 
class Watcher extends Actor { 
val child = context.actorOf(Props.empty, "child") 
context.watch(child) 
! 
def receive = { 
case Terminated(`child`) => … // handle child termination 
} 
}
Monitor through Death Watch 
31 
Create a child actor 
class Watcher extends Actor { 
val child = context.actorOf(Props.empty, "child") 
context.watch(child) 
! 
def receive = { 
case Terminated(`child`) => … // handle child termination 
} 
}
Monitor through Death Watch 
31 
Create a child actor 
Watch it 
class Watcher extends Actor { 
val child = context.actorOf(Props.empty, "child") 
context.watch(child) 
! 
def receive = { 
case Terminated(`child`) => … // handle child termination 
} 
}
Monitor through Death Watch 
31 
Create a child actor 
Watch it 
class Watcher extends Actor { 
val child = context.actorOf(Props.empty, "child") 
context.watch(child) 
Handle termination message 
! 
def receive = { 
case Terminated(`child`) => … // handle child termination 
} 
}
Reactive applications scale up 
and down to meet demand.
Elastic 
• Elasticity and Scalability to embrace the Cloud 
• Adaptive Scale on Demand 
• Clustered servers support joining and leaving of nodes 
• More cost-efficient utilization of hardware 
33 
“Our traffic can increase by as much as 100x for 15 minutes each day. 
Until a couple of years ago, noon was a stressful time. 
Nowadays, it’s usually a non-event.” 
Eric Bowman, VP Architecture, Gilt Groupe
34 
Scale UP 
Scale OUT
34 
Essentially the same thing
35 
We need to 
1. Minimize Contention 
2. Maximize Locality of Reference
36 
Share 
NOTHING 
Design
Fully event-driven apps are a necessity 
X 
Amdahl’s Law will hunt you down
Define a router 
ActorRef router = context().actorOf( 
new RoundRobinPool(5).props(Props.create(Worker.class)), 
“router”) 
X
Define a router 
37 
val router = context.actorOf( 
RoundRobinPool(5).props(Props[Worker])), “router”)
…or from config 
38 
akka.actor.deployment { 
/service/router { 
router = round-robin-pool 
resizer { 
lower-bound = 12 
upper-bound = 15 
} 
} 
}
Turn on clustering 
39 
akka { 
actor { 
provider = "akka.cluster.ClusterActorRefProvider" 
... 
} 
cluster { 
seed-nodes = [ 
“akka.tcp://ClusterSystem@127.0.0.1:2551", 
“akka.tcp://ClusterSystem@127.0.0.1:2552" 
] 
auto-down = off 
} 
}
Use clustered routers 
40 
akka.actor.deployment 
{ 
/service/master 
{ 
router 
= 
consistent-­‐hashing-­‐pool 
nr-­‐of-­‐instances 
= 
100 
! 
cluster 
{ 
enabled 
= 
on 
max-nr-of-instances-per-node = 3 
allow-­‐local-­‐routees 
= 
on 
use-­‐role 
= 
compute 
} 
} 
}
Use clustered routers 
40 
Or perhaps use an 
AdaptiveLoadBalancingPool 
akka.actor.deployment 
{ 
/service/master 
{ 
router 
= 
consistent-­‐hashing-­‐pool 
nr-­‐of-­‐instances 
= 
100 
! 
cluster 
{ 
enabled 
= 
on 
max-nr-of-instances-per-node = 3 
allow-­‐local-­‐routees 
= 
on 
use-­‐role 
= 
compute 
} 
} 
}
Use clustered pub-sub 
41
Use clustered pub-sub 
41 
class Subscriber extends Actor { 
val mediator = 
DistributedPubSubExtension(context.system).mediator 
mediator ! Subscribe(“content”, self) 
def receive = { … } 
}
Use clustered pub-sub 
41 
class Publisher extends Actor { 
val mediator = 
DistributedPubSubExtension(context.system).mediator 
def receive = { 
case in: String => 
mediator ! Publish("content", in.toUpperCase) 
} 
}
• Cluster Membership 
• Cluster Pub/Sub 
• Cluster Leader 
• Clustered Singleton 
• Cluster Roles 
• Cluster Sharding 
42 
Other Akka Cluster features
• Supports two different models: 
• Command Sourcing 
• Event Sourcing 
• Great for implementing 
• durable actors 
• replication 
• CQRS etc. 
• Messages persisted to Journal and replayed on restart 
43 
Use Akka Persistence
X 
Command Sourcing Event Sourcing
X 
Command Sourcing Event Sourcing 
write-ahead-log
X 
Command Sourcing Event Sourcing 
write-ahead-log derive events from a command
X 
Command Sourcing Event Sourcing 
write-ahead-log derive events from a command 
same behavior during recovery 
as normal operation
X 
Command Sourcing Event Sourcing 
write-ahead-log derive events from a command 
same behavior during recovery 
as normal operation 
only state-changing behavior 
during recovery
X 
Command Sourcing Event Sourcing 
write-ahead-log derive events from a command 
same behavior during recovery 
as normal operation 
only state-changing behavior 
during recovery 
persisted before validation
X 
Command Sourcing Event Sourcing 
write-ahead-log derive events from a command 
same behavior during recovery 
as normal operation 
only state-changing behavior 
during recovery 
persisted before validation events cannot fail
X 
Command Sourcing Event Sourcing 
write-ahead-log derive events from a command 
same behavior during recovery 
as normal operation 
only state-changing behavior 
during recovery 
persisted before validation events cannot fail 
allows retroactive changes to 
the business logic
X 
Command Sourcing Event Sourcing 
write-ahead-log derive events from a command 
same behavior during recovery 
as normal operation 
only state-changing behavior 
during recovery 
persisted before validation events cannot fail 
allows retroactive changes to 
the business logic 
fixing the business logic will not 
affect persisted events
X 
Command Sourcing Event Sourcing 
write-ahead-log derive events from a command 
same behavior during recovery 
as normal operation 
only state-changing behavior 
during recovery 
persisted before validation events cannot fail 
allows retroactive changes to 
the business logic 
fixing the business logic will not 
affect persisted events 
naming: represent intent, 
imperative
X 
Command Sourcing Event Sourcing 
write-ahead-log derive events from a command 
same behavior during recovery 
as normal operation 
only state-changing behavior 
during recovery 
persisted before validation events cannot fail 
allows retroactive changes to 
the business logic 
fixing the business logic will not 
affect persisted events 
naming: represent intent, 
imperative 
naming: things that have 
completed, verbs in past tense
Domain Events 
• Things that have completed, facts 
• Immutable 
• Verbs in past tense 
Akka 
Persistence 
Webinar 
• CustomerRelocated 
• CargoShipped 
• InvoiceSent 
“State transitions are an important part of our problem 
space and should be modeled within our domain.” 
Greg Young, 2008
Life beyond Distributed Transactions: 
an Apostate’s Opinion 
Position Paper by Pat Helland 
http://www-­‐db.cs.wisc.edu/cidr/cidr2007/papers/cidr07p15.pdf 
“In general, application developers simply do not implement 
large scalable applications assuming distributed transactions.” 
Pat Helland 
Akka 
Persistence 
Webinar
Consistency boundary 
• An Actor is can define an Aggregate Root 
• Each containing one or more Entities 
• Aggregate Root is the Transactional Boundary 
• Strong consistency within an Aggregate 
• Eventual consistency between Aggregates 
• No limit to scalability 
Akka 
Persistence 
Webinar
DEMO TIME Persist a game of ping pong
http://reactivemanifesto.org
Typesafe Activator 
http://typesafe.com/platform/getstarted
• Purely asynchronous and non-blocking 
web frameworks 
• No container required, no inherent 
bottlenecks in session management 
48 
Typesafe Reactive Platform 
• Actors are asynchronous and 
communicate via message passing 
• Supervision and clustering in support of 
fault tolerance 
• Asynchronous and immutable 
programming constructs 
• Composable abstractions enabling 
simpler concurrency and parallelism
Reactive is being adopted across 
a wide range of industries.
50 
Finance Internet/Social Media Mfg/Hardware Government Retail
Questions?
©Typesafe 2014 – All Rights Reserved

Weitere ähnliche Inhalte

Was ist angesagt?

Reactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysReactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysManuel Bernhardt
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETDavid Hoerster
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleansBill Tulloch
 
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in'tScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in'tKonrad Malawski
 
The Need for Async @ ScalaWorld
The Need for Async @ ScalaWorldThe Need for Async @ ScalaWorld
The Need for Async @ ScalaWorldKonrad Malawski
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaKonrad Malawski
 
Actor model in .NET - Akka.NET
Actor model in .NET - Akka.NETActor model in .NET - Akka.NET
Actor model in .NET - Akka.NETKonrad Dusza
 
The Cloud-natives are RESTless @ JavaOne
The Cloud-natives are RESTless @ JavaOneThe Cloud-natives are RESTless @ JavaOne
The Cloud-natives are RESTless @ JavaOneKonrad Malawski
 
A gentle introduction into AKKA and the actor model
A gentle introduction into AKKA and the actor modelA gentle introduction into AKKA and the actor model
A gentle introduction into AKKA and the actor modelMykhailo Kotsur
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterKonstantin Tsykulenko
 
Gruntwork Executive Summary
Gruntwork Executive SummaryGruntwork Executive Summary
Gruntwork Executive SummaryYevgeniy Brikman
 
Composable and streamable Play apps
Composable and streamable Play appsComposable and streamable Play apps
Composable and streamable Play appsYevgeniy Brikman
 
Reactive Streams, j.u.concurrent & Beyond!
Reactive Streams, j.u.concurrent & Beyond!Reactive Streams, j.u.concurrent & Beyond!
Reactive Streams, j.u.concurrent & Beyond!Konrad Malawski
 
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven SystemsGo Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven SystemsJonas Bonér
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Yevgeniy Brikman
 
Play Framework + Docker + CircleCI + AWS + EC2 Container Service
Play Framework + Docker + CircleCI + AWS + EC2 Container ServicePlay Framework + Docker + CircleCI + AWS + EC2 Container Service
Play Framework + Docker + CircleCI + AWS + EC2 Container ServiceJosh Padnick
 
Introduction to akka actors with java 8
Introduction to akka actors with java 8Introduction to akka actors with java 8
Introduction to akka actors with java 8Johan Andrén
 
Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Konrad Malawski
 
Akka in Practice: Designing Actor-based Applications
Akka in Practice: Designing Actor-based ApplicationsAkka in Practice: Designing Actor-based Applications
Akka in Practice: Designing Actor-based ApplicationsNLJUG
 

Was ist angesagt? (20)

Reactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysReactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDays
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NET
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleans
 
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in'tScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
 
The Need for Async @ ScalaWorld
The Need for Async @ ScalaWorldThe Need for Async @ ScalaWorld
The Need for Async @ ScalaWorld
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and Akka
 
Actor model in .NET - Akka.NET
Actor model in .NET - Akka.NETActor model in .NET - Akka.NET
Actor model in .NET - Akka.NET
 
The Cloud-natives are RESTless @ JavaOne
The Cloud-natives are RESTless @ JavaOneThe Cloud-natives are RESTless @ JavaOne
The Cloud-natives are RESTless @ JavaOne
 
A gentle introduction into AKKA and the actor model
A gentle introduction into AKKA and the actor modelA gentle introduction into AKKA and the actor model
A gentle introduction into AKKA and the actor model
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster
 
Gruntwork Executive Summary
Gruntwork Executive SummaryGruntwork Executive Summary
Gruntwork Executive Summary
 
Composable and streamable Play apps
Composable and streamable Play appsComposable and streamable Play apps
Composable and streamable Play apps
 
Reactive Streams, j.u.concurrent & Beyond!
Reactive Streams, j.u.concurrent & Beyond!Reactive Streams, j.u.concurrent & Beyond!
Reactive Streams, j.u.concurrent & Beyond!
 
Akka Fundamentals
Akka FundamentalsAkka Fundamentals
Akka Fundamentals
 
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven SystemsGo Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
 
Play Framework + Docker + CircleCI + AWS + EC2 Container Service
Play Framework + Docker + CircleCI + AWS + EC2 Container ServicePlay Framework + Docker + CircleCI + AWS + EC2 Container Service
Play Framework + Docker + CircleCI + AWS + EC2 Container Service
 
Introduction to akka actors with java 8
Introduction to akka actors with java 8Introduction to akka actors with java 8
Introduction to akka actors with java 8
 
Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016
 
Akka in Practice: Designing Actor-based Applications
Akka in Practice: Designing Actor-based ApplicationsAkka in Practice: Designing Actor-based Applications
Akka in Practice: Designing Actor-based Applications
 

Andere mochten auch

Reactive Supply To Changing Demand
Reactive Supply To Changing DemandReactive Supply To Changing Demand
Reactive Supply To Changing DemandJonas Bonér
 
Enterprise Search Summit - Speeding Up Search
Enterprise Search Summit - Speeding Up SearchEnterprise Search Summit - Speeding Up Search
Enterprise Search Summit - Speeding Up SearchAzul Systems Inc.
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Jonas Bonér
 
From Microliths To Microsystems
From Microliths To MicrosystemsFrom Microliths To Microsystems
From Microliths To MicrosystemsJonas Bonér
 
Reactive Microsystems: The Evolution of Microservices at Scale
Reactive Microsystems: The Evolution of Microservices at ScaleReactive Microsystems: The Evolution of Microservices at Scale
Reactive Microsystems: The Evolution of Microservices at ScaleJonas Bonér
 
How Events Are Reshaping Modern Systems
How Events Are Reshaping Modern SystemsHow Events Are Reshaping Modern Systems
How Events Are Reshaping Modern SystemsJonas Bonér
 
Akka cluster overview at 010dev
Akka cluster overview at 010devAkka cluster overview at 010dev
Akka cluster overview at 010devRoland Kuhn
 
Slides - Intro to Akka.Cluster
Slides - Intro to Akka.ClusterSlides - Intro to Akka.Cluster
Slides - Intro to Akka.Clusterpetabridge
 
Building Scalable, Highly Concurrent & Fault Tolerant Systems - Lessons Learned
Building Scalable, Highly Concurrent & Fault Tolerant Systems -  Lessons LearnedBuilding Scalable, Highly Concurrent & Fault Tolerant Systems -  Lessons Learned
Building Scalable, Highly Concurrent & Fault Tolerant Systems - Lessons LearnedJonas Bonér
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and AkkaYung-Lin Ho
 
Introduction to Akka
Introduction to AkkaIntroduction to Akka
Introduction to AkkaJohan Andrén
 
"Spark Search" - In-memory, Distributed Search with Lucene, Spark, and Tachyo...
"Spark Search" - In-memory, Distributed Search with Lucene, Spark, and Tachyo..."Spark Search" - In-memory, Distributed Search with Lucene, Spark, and Tachyo...
"Spark Search" - In-memory, Distributed Search with Lucene, Spark, and Tachyo...Lucidworks
 
Spark shuffle introduction
Spark shuffle introductionSpark shuffle introduction
Spark shuffle introductioncolorant
 
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Jonas Bonér
 
バッチを Akka Streams で再実装したら100倍速くなった話 #ScalaMatsuri
バッチを Akka Streams で再実装したら100倍速くなった話 #ScalaMatsuriバッチを Akka Streams で再実装したら100倍速くなった話 #ScalaMatsuri
バッチを Akka Streams で再実装したら100倍速くなった話 #ScalaMatsuriKazuki Negoro
 

Andere mochten auch (17)

Reactive Supply To Changing Demand
Reactive Supply To Changing DemandReactive Supply To Changing Demand
Reactive Supply To Changing Demand
 
Enterprise Search Summit - Speeding Up Search
Enterprise Search Summit - Speeding Up SearchEnterprise Search Summit - Speeding Up Search
Enterprise Search Summit - Speeding Up Search
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
 
From Microliths To Microsystems
From Microliths To MicrosystemsFrom Microliths To Microsystems
From Microliths To Microsystems
 
Reactive Microsystems: The Evolution of Microservices at Scale
Reactive Microsystems: The Evolution of Microservices at ScaleReactive Microsystems: The Evolution of Microservices at Scale
Reactive Microsystems: The Evolution of Microservices at Scale
 
How Events Are Reshaping Modern Systems
How Events Are Reshaping Modern SystemsHow Events Are Reshaping Modern Systems
How Events Are Reshaping Modern Systems
 
Akka cluster overview at 010dev
Akka cluster overview at 010devAkka cluster overview at 010dev
Akka cluster overview at 010dev
 
Slides - Intro to Akka.Cluster
Slides - Intro to Akka.ClusterSlides - Intro to Akka.Cluster
Slides - Intro to Akka.Cluster
 
Building Scalable, Highly Concurrent & Fault Tolerant Systems - Lessons Learned
Building Scalable, Highly Concurrent & Fault Tolerant Systems -  Lessons LearnedBuilding Scalable, Highly Concurrent & Fault Tolerant Systems -  Lessons Learned
Building Scalable, Highly Concurrent & Fault Tolerant Systems - Lessons Learned
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and Akka
 
Introduction to Akka
Introduction to AkkaIntroduction to Akka
Introduction to Akka
 
"Spark Search" - In-memory, Distributed Search with Lucene, Spark, and Tachyo...
"Spark Search" - In-memory, Distributed Search with Lucene, Spark, and Tachyo..."Spark Search" - In-memory, Distributed Search with Lucene, Spark, and Tachyo...
"Spark Search" - In-memory, Distributed Search with Lucene, Spark, and Tachyo...
 
Spark shuffle introduction
Spark shuffle introductionSpark shuffle introduction
Spark shuffle introduction
 
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
 
バッチを Akka Streams で再実装したら100倍速くなった話 #ScalaMatsuri
バッチを Akka Streams で再実装したら100倍速くなった話 #ScalaMatsuriバッチを Akka Streams で再実装したら100倍速くなった話 #ScalaMatsuri
バッチを Akka Streams で再実装したら100倍速くなった話 #ScalaMatsuri
 
Modern Data Architecture
Modern Data ArchitectureModern Data Architecture
Modern Data Architecture
 
Apache Spark Architecture
Apache Spark ArchitectureApache Spark Architecture
Apache Spark Architecture
 

Ähnlich wie Building Reactive Systems with Akka (in Java 8 or Scala)

Building Reactive Applications with Akka & Java 8 - Bonèr
Building Reactive Applications with Akka & Java 8 - BonèrBuilding Reactive Applications with Akka & Java 8 - Bonèr
Building Reactive Applications with Akka & Java 8 - BonèrCodemotion
 
Clear AppSec Visibility with AppSpider and ThreadFix
 Clear AppSec Visibility with AppSpider and ThreadFix Clear AppSec Visibility with AppSpider and ThreadFix
Clear AppSec Visibility with AppSpider and ThreadFixDenim Group
 
Node.js meetup 17.05.2017 ember.js - escape the javascript fatigue
Node.js meetup 17.05.2017   ember.js - escape the javascript fatigueNode.js meetup 17.05.2017   ember.js - escape the javascript fatigue
Node.js meetup 17.05.2017 ember.js - escape the javascript fatigueTobias Braner
 
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVMVoxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVMManuel Bernhardt
 
Modern Release Engineering in a Nutshell - Why Researchers should Care!
Modern Release Engineering in a Nutshell - Why Researchers should Care!Modern Release Engineering in a Nutshell - Why Researchers should Care!
Modern Release Engineering in a Nutshell - Why Researchers should Care!Bram Adams
 
Develop & Deploy cloud-native apps as resilient Microservices Architectures
Develop & Deploy cloud-native apps as resilient Microservices ArchitecturesDevelop & Deploy cloud-native apps as resilient Microservices Architectures
Develop & Deploy cloud-native apps as resilient Microservices ArchitecturesRed Hat Developers
 
Cassandra & puppet, scaling data at $15 per month
Cassandra & puppet, scaling data at $15 per monthCassandra & puppet, scaling data at $15 per month
Cassandra & puppet, scaling data at $15 per monthdaveconnors
 
Intro to @viewport & other new Responsive Web Design CSS features
Intro to @viewport & other new Responsive Web Design CSS featuresIntro to @viewport & other new Responsive Web Design CSS features
Intro to @viewport & other new Responsive Web Design CSS featuresAndreas Bovens
 
David Bilík: Anko – modern way to build your layouts?
David Bilík: Anko – modern way to build your layouts?David Bilík: Anko – modern way to build your layouts?
David Bilík: Anko – modern way to build your layouts?mdevtalk
 
3 Tips to Deliver Fast Performance Across Mobile Web
3 Tips to Deliver Fast Performance Across Mobile Web3 Tips to Deliver Fast Performance Across Mobile Web
3 Tips to Deliver Fast Performance Across Mobile WebDynatrace
 
Proxy Deep Dive Voxxed Belgrad 2015
Proxy Deep Dive Voxxed Belgrad 2015Proxy Deep Dive Voxxed Belgrad 2015
Proxy Deep Dive Voxxed Belgrad 2015Sven Ruppert
 
Fishing Graphs in a Hadoop Data Lake
Fishing Graphs in a Hadoop Data LakeFishing Graphs in a Hadoop Data Lake
Fishing Graphs in a Hadoop Data LakeArangoDB Database
 
EricEvans_StrategicDesign.ppt
EricEvans_StrategicDesign.pptEricEvans_StrategicDesign.ppt
EricEvans_StrategicDesign.pptNisha819927
 
The Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To KnowThe Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To KnowAll Things Open
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsNathan Smith
 
Building High Performance Apps with In-memory Data
Building High Performance Apps with In-memory DataBuilding High Performance Apps with In-memory Data
Building High Performance Apps with In-memory DataAmazon Web Services
 
5 Key Components of Genrocket
5 Key Components of Genrocket5 Key Components of Genrocket
5 Key Components of GenrocketGenRocket
 
Deep Dive Xamarin.Android
Deep Dive Xamarin.AndroidDeep Dive Xamarin.Android
Deep Dive Xamarin.AndroidBenjamin Bishop
 

Ähnlich wie Building Reactive Systems with Akka (in Java 8 or Scala) (20)

Building Reactive Applications with Akka & Java 8 - Bonèr
Building Reactive Applications with Akka & Java 8 - BonèrBuilding Reactive Applications with Akka & Java 8 - Bonèr
Building Reactive Applications with Akka & Java 8 - Bonèr
 
Clear AppSec Visibility with AppSpider and ThreadFix
 Clear AppSec Visibility with AppSpider and ThreadFix Clear AppSec Visibility with AppSpider and ThreadFix
Clear AppSec Visibility with AppSpider and ThreadFix
 
Node.js meetup 17.05.2017 ember.js - escape the javascript fatigue
Node.js meetup 17.05.2017   ember.js - escape the javascript fatigueNode.js meetup 17.05.2017   ember.js - escape the javascript fatigue
Node.js meetup 17.05.2017 ember.js - escape the javascript fatigue
 
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVMVoxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
 
Modern Release Engineering in a Nutshell - Why Researchers should Care!
Modern Release Engineering in a Nutshell - Why Researchers should Care!Modern Release Engineering in a Nutshell - Why Researchers should Care!
Modern Release Engineering in a Nutshell - Why Researchers should Care!
 
Develop & Deploy cloud-native apps as resilient Microservices Architectures
Develop & Deploy cloud-native apps as resilient Microservices ArchitecturesDevelop & Deploy cloud-native apps as resilient Microservices Architectures
Develop & Deploy cloud-native apps as resilient Microservices Architectures
 
Cassandra & puppet, scaling data at $15 per month
Cassandra & puppet, scaling data at $15 per monthCassandra & puppet, scaling data at $15 per month
Cassandra & puppet, scaling data at $15 per month
 
Meteorjs
MeteorjsMeteorjs
Meteorjs
 
Meteorjs
MeteorjsMeteorjs
Meteorjs
 
Intro to @viewport & other new Responsive Web Design CSS features
Intro to @viewport & other new Responsive Web Design CSS featuresIntro to @viewport & other new Responsive Web Design CSS features
Intro to @viewport & other new Responsive Web Design CSS features
 
David Bilík: Anko – modern way to build your layouts?
David Bilík: Anko – modern way to build your layouts?David Bilík: Anko – modern way to build your layouts?
David Bilík: Anko – modern way to build your layouts?
 
3 Tips to Deliver Fast Performance Across Mobile Web
3 Tips to Deliver Fast Performance Across Mobile Web3 Tips to Deliver Fast Performance Across Mobile Web
3 Tips to Deliver Fast Performance Across Mobile Web
 
Proxy Deep Dive Voxxed Belgrad 2015
Proxy Deep Dive Voxxed Belgrad 2015Proxy Deep Dive Voxxed Belgrad 2015
Proxy Deep Dive Voxxed Belgrad 2015
 
Fishing Graphs in a Hadoop Data Lake
Fishing Graphs in a Hadoop Data LakeFishing Graphs in a Hadoop Data Lake
Fishing Graphs in a Hadoop Data Lake
 
EricEvans_StrategicDesign.ppt
EricEvans_StrategicDesign.pptEricEvans_StrategicDesign.ppt
EricEvans_StrategicDesign.ppt
 
The Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To KnowThe Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To Know
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile Apps
 
Building High Performance Apps with In-memory Data
Building High Performance Apps with In-memory DataBuilding High Performance Apps with In-memory Data
Building High Performance Apps with In-memory Data
 
5 Key Components of Genrocket
5 Key Components of Genrocket5 Key Components of Genrocket
5 Key Components of Genrocket
 
Deep Dive Xamarin.Android
Deep Dive Xamarin.AndroidDeep Dive Xamarin.Android
Deep Dive Xamarin.Android
 

Mehr von Jonas Bonér

We are drowning in complexity—can we do better?
We are drowning in complexity—can we do better?We are drowning in complexity—can we do better?
We are drowning in complexity—can we do better?Jonas Bonér
 
Kalix: Tackling the The Cloud to Edge Continuum
Kalix: Tackling the The Cloud to Edge ContinuumKalix: Tackling the The Cloud to Edge Continuum
Kalix: Tackling the The Cloud to Edge ContinuumJonas Bonér
 
The Reactive Principles: Design Principles For Cloud Native Applications
The Reactive Principles: Design Principles For Cloud Native ApplicationsThe Reactive Principles: Design Principles For Cloud Native Applications
The Reactive Principles: Design Principles For Cloud Native ApplicationsJonas Bonér
 
Cloudstate—Towards Stateful Serverless
Cloudstate—Towards Stateful ServerlessCloudstate—Towards Stateful Serverless
Cloudstate—Towards Stateful ServerlessJonas Bonér
 
Designing Events-first Microservices
Designing Events-first MicroservicesDesigning Events-first Microservices
Designing Events-first MicroservicesJonas Bonér
 
Without Resilience, Nothing Else Matters
Without Resilience, Nothing Else MattersWithout Resilience, Nothing Else Matters
Without Resilience, Nothing Else MattersJonas Bonér
 
Life Beyond the Illusion of Present
Life Beyond the Illusion of PresentLife Beyond the Illusion of Present
Life Beyond the Illusion of PresentJonas Bonér
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsGo Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsJonas Bonér
 
Event Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspectiveEvent Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspectiveJonas Bonér
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsJonas Bonér
 
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVMState: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVMJonas Bonér
 

Mehr von Jonas Bonér (11)

We are drowning in complexity—can we do better?
We are drowning in complexity—can we do better?We are drowning in complexity—can we do better?
We are drowning in complexity—can we do better?
 
Kalix: Tackling the The Cloud to Edge Continuum
Kalix: Tackling the The Cloud to Edge ContinuumKalix: Tackling the The Cloud to Edge Continuum
Kalix: Tackling the The Cloud to Edge Continuum
 
The Reactive Principles: Design Principles For Cloud Native Applications
The Reactive Principles: Design Principles For Cloud Native ApplicationsThe Reactive Principles: Design Principles For Cloud Native Applications
The Reactive Principles: Design Principles For Cloud Native Applications
 
Cloudstate—Towards Stateful Serverless
Cloudstate—Towards Stateful ServerlessCloudstate—Towards Stateful Serverless
Cloudstate—Towards Stateful Serverless
 
Designing Events-first Microservices
Designing Events-first MicroservicesDesigning Events-first Microservices
Designing Events-first Microservices
 
Without Resilience, Nothing Else Matters
Without Resilience, Nothing Else MattersWithout Resilience, Nothing Else Matters
Without Resilience, Nothing Else Matters
 
Life Beyond the Illusion of Present
Life Beyond the Illusion of PresentLife Beyond the Illusion of Present
Life Beyond the Illusion of Present
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsGo Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
 
Event Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspectiveEvent Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspective
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
 
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVMState: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
 

Kürzlich hochgeladen

Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Communityprachaibot
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...
22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...
22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...KrishnaveniKrishnara1
 
Module-1-Building Acoustics(Introduction)(Unit-1).pdf
Module-1-Building Acoustics(Introduction)(Unit-1).pdfModule-1-Building Acoustics(Introduction)(Unit-1).pdf
Module-1-Building Acoustics(Introduction)(Unit-1).pdfManish Kumar
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfBalamuruganV28
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewsandhya757531
 
Secure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech LabsSecure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech Labsamber724300
 
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...shreenathji26
 
Analysis and Evaluation of Dal Lake Biomass for Conversion to Fuel/Green fert...
Analysis and Evaluation of Dal Lake Biomass for Conversion to Fuel/Green fert...Analysis and Evaluation of Dal Lake Biomass for Conversion to Fuel/Green fert...
Analysis and Evaluation of Dal Lake Biomass for Conversion to Fuel/Green fert...arifengg7
 
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSsandhya757531
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfManish Kumar
 
tourism-management-srs_compress-software-engineering.pdf
tourism-management-srs_compress-software-engineering.pdftourism-management-srs_compress-software-engineering.pdf
tourism-management-srs_compress-software-engineering.pdfchess188chess188
 
Structural Integrity Assessment Standards in Nigeria by Engr Nimot Muili
Structural Integrity Assessment Standards in Nigeria by Engr Nimot MuiliStructural Integrity Assessment Standards in Nigeria by Engr Nimot Muili
Structural Integrity Assessment Standards in Nigeria by Engr Nimot MuiliNimot Muili
 
Uk-NO1 kala jadu karne wale ka contact number kala jadu karne wale baba kala ...
Uk-NO1 kala jadu karne wale ka contact number kala jadu karne wale baba kala ...Uk-NO1 kala jadu karne wale ka contact number kala jadu karne wale baba kala ...
Uk-NO1 kala jadu karne wale ka contact number kala jadu karne wale baba kala ...Amil baba
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionSneha Padhiar
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Sumanth A
 
priority interrupt computer organization
priority interrupt computer organizationpriority interrupt computer organization
priority interrupt computer organizationchnrketan
 
Javier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier Fernández Muñoz
 

Kürzlich hochgeladen (20)

Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Community
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...
22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...
22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...
 
Module-1-Building Acoustics(Introduction)(Unit-1).pdf
Module-1-Building Acoustics(Introduction)(Unit-1).pdfModule-1-Building Acoustics(Introduction)(Unit-1).pdf
Module-1-Building Acoustics(Introduction)(Unit-1).pdf
 
Versatile Engineering Construction Firms
Versatile Engineering Construction FirmsVersatile Engineering Construction Firms
Versatile Engineering Construction Firms
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdf
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overview
 
Secure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech LabsSecure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech Labs
 
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
 
Analysis and Evaluation of Dal Lake Biomass for Conversion to Fuel/Green fert...
Analysis and Evaluation of Dal Lake Biomass for Conversion to Fuel/Green fert...Analysis and Evaluation of Dal Lake Biomass for Conversion to Fuel/Green fert...
Analysis and Evaluation of Dal Lake Biomass for Conversion to Fuel/Green fert...
 
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
 
tourism-management-srs_compress-software-engineering.pdf
tourism-management-srs_compress-software-engineering.pdftourism-management-srs_compress-software-engineering.pdf
tourism-management-srs_compress-software-engineering.pdf
 
Structural Integrity Assessment Standards in Nigeria by Engr Nimot Muili
Structural Integrity Assessment Standards in Nigeria by Engr Nimot MuiliStructural Integrity Assessment Standards in Nigeria by Engr Nimot Muili
Structural Integrity Assessment Standards in Nigeria by Engr Nimot Muili
 
Uk-NO1 kala jadu karne wale ka contact number kala jadu karne wale baba kala ...
Uk-NO1 kala jadu karne wale ka contact number kala jadu karne wale baba kala ...Uk-NO1 kala jadu karne wale ka contact number kala jadu karne wale baba kala ...
Uk-NO1 kala jadu karne wale ka contact number kala jadu karne wale baba kala ...
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based question
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
 
priority interrupt computer organization
priority interrupt computer organizationpriority interrupt computer organization
priority interrupt computer organization
 
Javier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptx
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 

Building Reactive Systems with Akka (in Java 8 or Scala)

  • 1. Building Reactive Systems with Akka Jonas Bonér Typesafe CTO & co-founder Twitter: @jboner
  • 2. The rules of the game have changed
  • 3. 3 Apps in the 60s-90s were written for Apps today are written for
  • 4. 3 Apps in the 60s-90s were written for Apps today are written for Single machines
  • 5. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines
  • 6. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors
  • 7. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors
  • 8. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors Expensive RAM
  • 9. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM
  • 10. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk
  • 11. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk
  • 12. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks
  • 13. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks
  • 14. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks Few concurrent users
  • 15. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks Few concurrent users Lots of concurrent users
  • 16. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks Few concurrent users Lots of concurrent users Small data sets
  • 17. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks Few concurrent users Lots of concurrent users Small data sets Large data sets
  • 18. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks Few concurrent users Lots of concurrent users Small data sets Large data sets Latency in seconds
  • 19. 3 Apps in the 60s-90s were written for Apps today are written for Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks Few concurrent users Lots of concurrent users Small data sets Large data sets Latency in seconds Latency in milliseconds
  • 20.
  • 21. Cost Gravity is at Work X
  • 22. Cost Gravity is at Work X
  • 23. Reactive applications share four traits Reactive Applications 5
  • 24. Reactive applications enrich the user experience with low latency response.
  • 25. Responsive • Real-time, engaging, rich and collaborative • Create an open and ongoing dialog with users • More efficient workflow; inspires a feeling of connectedness • Fully Reactive enabling push instead of pull 7 “The move to these technologies is already paying off. Response times are down for processor intensive code–such as image and PDF generation–by around 75%.” Brian Pugh, VP of Engineering, Lucid Software
  • 26. Reactive applications react to changes in the world around them.
  • 27. Message-Driven • Loosely coupled architecture, easier to extend, maintain, evolve • Asynchronous and non-blocking • Concurrent by design, immutable state • Lower latency and higher throughput 9 “Clearly, the goal is to do these operations concurrently and non-blocking, so that entire blocks of seats or sections are not locked. We’re able to find and allocate seats under load in less than 20ms without trying very hard to achieve it.” Andrew Headrick, Platform Architect, Ticketfly
  • 29. 11 The Actor Model
  • 30. 11 The Actor Model A computational model that embodies:
  • 31. 11 The Actor Model A computational model that embodies: ✓ Processing
  • 32. 11 The Actor Model A computational model that embodies: ✓ Processing ✓ Storage
  • 33. 11 The Actor Model A computational model that embodies: ✓ Processing ✓ Storage ✓ Communication
  • 34. A computational model that embodies: ✓ Processing ✓ Storage ✓ Communication Supports 3 axioms—when an Actor receives a message it can: 11 The Actor Model
  • 35. A computational model that embodies: ✓ Processing ✓ Storage ✓ Communication Supports 3 axioms—when an Actor receives a message it can: 1. Create new Actors 11 The Actor Model
  • 36. A computational model that embodies: ✓ Processing ✓ Storage ✓ Communication Supports 3 axioms—when an Actor receives a message it can: 1. Create new Actors 2. Send messages to Actors it knows 11 The Actor Model
  • 37. A computational model that embodies: ✓ Processing ✓ Storage ✓ Communication Supports 3 axioms—when an Actor receives a message it can: 1. Create new Actors 2. Send messages to Actors it knows 3. Designate how it should handle the next message it receives 11 The Actor Model
  • 38. The essence of an actor from Akka’s perspective 0. DEFINE 1. CREATE 2. SEND 3. BECOME 4. SUPERVISE 12
  • 39. public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } ! public class Greeter extends AbstractActor {{ receive(ReceiveBuilder. match(Greeting.class, m -> { println(“Hello " + m.who); }). matchAny(unknown -> { println(“Unknown message " + unknown); }).build()); }} 0. DEFINE X
  • 40. public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } ! public class Greeter extends AbstractActor {{ receive(ReceiveBuilder. match(Greeting.class, m -> { println(“Hello " + m.who); }). matchAny(unknown -> { println(“Unknown message " + unknown); }).build()); }} 0. DEFINE X Define the message(s) the Actor should be able to respond to
  • 41. public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } ! public class Greeter extends AbstractActor {{ receive(ReceiveBuilder. match(Greeting.class, m -> { println(“Hello " + m.who); }). matchAny(unknown -> { println(“Unknown message " + unknown); }).build()); }} 0. DEFINE X Define the message(s) the Actor should be able to respond to Define the Actor class
  • 42. public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } ! public class Greeter extends AbstractActor {{ receive(ReceiveBuilder. match(Greeting.class, m -> { println(“Hello " + m.who); }). matchAny(unknown -> { println(“Unknown message " + unknown); }).build()); }} 0. DEFINE X Define the message(s) the Actor should be able to respond to Define the Actor class Define the Actor’s behavior
  • 43. 1. CREATE ActorSystem system = ActorSystem.create("MySystem"); ! ActorRef greeter = system.actorOf(Props.create(Greeter.class), “greeter");
  • 44. 1. CREATE Create an Actor system ActorSystem system = ActorSystem.create("MySystem"); ! ActorRef greeter = system.actorOf(Props.create(Greeter.class), “greeter");
  • 45. 1. CREATE Create an Actor system Actor configuration ActorSystem system = ActorSystem.create("MySystem"); ! ActorRef greeter = system.actorOf(Props.create(Greeter.class), “greeter");
  • 46. 1. CREATE Create an Actor system Actor configuration ActorSystem system = ActorSystem.create("MySystem"); ! ActorRef greeter = system.actorOf(Props.create(Greeter.class), “greeter"); Give it a name
  • 47. 1. CREATE Create an Actor system ActorSystem system = ActorSystem.create("MySystem"); ! ActorRef greeter = system.actorOf(Props.create(Greeter.class), “greeter"); Give it a name Create the Actor Actor configuration
  • 48. 1. CREATE Create an Actor system ActorSystem system = ActorSystem.create("MySystem"); ! ActorRef greeter = system.actorOf(Props.create(Greeter.class), “greeter"); Give it a name You get an ActorRef back Create the Actor Actor configuration
  • 49. 0. DEFINE case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { 13 case Greeting(who) => log.info(s"Hello ${who}") } }
  • 50. 0. DEFINE 13 Define the message(s) the Actor should be able to respond to case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info(s"Hello ${who}") } }
  • 51. 0. DEFINE 13 Define the message(s) the Actor should be able to respond to Define the Actor class case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info(s"Hello ${who}") } }
  • 52. 0. DEFINE 13 Define the message(s) the Actor should be able to respond to Define the Actor class case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info(s"Hello ${who}") } } Define the Actor’s behavior
  • 53. 1. CREATE case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info("Hello " + who) } } ! val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter")
  • 54. 1. CREATE case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { Create an Actor system case Greeting(who) => log.info("Hello " + who) } } ! val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter")
  • 55. 1. CREATE case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { Create an Actor system case Greeting(who) => log.info("Hello " } Actor configuration + who) } ! val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter")
  • 56. 1. CREATE case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info("Hello " + who) } } ! val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") Give it a name Create an Actor system Actor configuration
  • 57. 1. CREATE case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { Create an Actor system case Greeting(who) => log.info("Hello " } Actor configuration + who) } ! val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") Give it a name Create the Actor
  • 58. 1. CREATE case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { Create an Actor system case Greeting(who) => log.info("Hello " } Actor configuration + who) } ! val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") Give it a name You get an ActorRef bCarcekate the Actor
  • 59. Actors can form hierarchies Guardian System Actor
  • 60. Actors can form hierarchies Guardian System Actor system.actorOf(Props.create(Foo.class), “Foo”);
  • 61. Actors can form hierarchies Foo Guardian System Actor system.actorOf(Props.create(Foo.class), “Foo”);
  • 62. Actors can form hierarchies Foo Guardian System Actor context().actorOf(Props.create(A.class), “A”);
  • 63. Actors can form hierarchies A Foo Guardian System Actor context().actorOf(Props.create(A.class), “A”);
  • 64. Actors can form hierarchies A Foo Bar B C B E A D C Guardian System Actor
  • 65. Actors can form hierarchies Guardian System Actor
  • 66. Actors can form hierarchies Guardian System Actor system.actorOf(Props[Foo], “Foo”)
  • 67. Actors can form hierarchies Foo Guardian System Actor system.actorOf(Props[Foo], “Foo”)
  • 68. Actors can form hierarchies Foo Guardian System Actor context.actorOf(Props[A], “A”)
  • 69. Actors can form hierarchies A Foo Guardian System Actor context.actorOf(Props[A], “A”)
  • 70. Actors can form hierarchies A Foo Bar B C B E A D C Guardian System Actor
  • 71. Name resolution—like a file-system A Foo Bar B C B E A D C Guardian System Actor
  • 72. Name resolution—like a file-system A Foo Bar B C B E A D C /Foo Guardian System Actor
  • 73. Name resolution—like a file-system A Foo Bar B C B E A D C /Foo /Foo/A Guardian System Actor
  • 74. Name resolution—like a file-system A Foo Bar B C B E A D C /Foo /Foo/A /Foo/A/B Guardian System Actor
  • 75. Name resolution—like a file-system A Foo Bar B C B E A D C /Foo /Foo/A /Foo/A/B /Foo/A/D Guardian System Actor
  • 76. 2. SEND X greeter.tell(new Greeting("Charlie Parker”), sender);
  • 77. 2. SEND X greeter.tell(new Greeting("Charlie Parker”), sender); Send the message asynchronously
  • 78. 2. SEND X Pass in the sender ActorRef greeter.tell(new Greeting("Charlie Parker”), sender); Send the message asynchronously
  • 79. Bring it together X public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } public class Greeter extends AbstractActor {{ receive(ReceiveBuilder. match(Greeting.class, m -> { println(“Hello " + m.who); }). matchAny(unknown -> { println(“Unknown message " + unknown); }).build()); } }} ! ActorSystem system = ActorSystem.create("MySystem"); ActorRef greeter = system.actorOf(Props.create(Greeter.class), “greeter"); greeter.tell(new Greeting(“Charlie Parker”));
  • 80. 2. SEND 17 case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info(s”Hello ${who}") } } ! val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") greeter ! Greeting("Charlie Parker")
  • 81. 2. SEND 17 case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info(s”Hello ${who}") } } ! val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") greeter ! Greeting("Charlie Parker") Send the message asynchronously
  • 82. Bring it together 18 case class Greeting(who: String) ! class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info(s”Hello ${who}") } } ! val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") greeter ! Greeting("Charlie Parker")
  • 83. DEMO TIME A simple game of ping pong
  • 84. 3. BECOME X public class Greeter extends AbstractActor { public Greeter { receive(ReceiveBuilder. match(Greeting.class, m -> { println(“Hello " + m.who); }). matchEquals(“stop" -> { !!!! }).build(); } }
  • 85. 3. BECOME X public class Greeter extends AbstractActor { public Greeter { receive(ReceiveBuilder. match(Greeting.class, m -> { println(“Hello " + m.who); }). matchEquals(“stop" -> { !!!! }).build(); } } context().become(ReceiveBuilder.
  • 86. 3. BECOME X public class Greeter extends AbstractActor { public Greeter { receive(ReceiveBuilder. match(Greeting.class, m -> { println(“Hello " + m.who); }). matchEquals(“stop" -> { !!!! }).build(); } } Change the behavior context().become(ReceiveBuilder.
  • 87. 3. BECOME X public class Greeter extends AbstractActor { public Greeter { receive(ReceiveBuilder. match(Greeting.class, m -> { println(“Hello " + m.who); }). matchEquals(“stop" -> { !!!! }).build(); } } Change the behavior context().become(ReceiveBuilder. match(Greeting.class, m -> {
  • 88. 3. BECOME X public class Greeter extends AbstractActor { public Greeter { receive(ReceiveBuilder. match(Greeting.class, m -> { println(“Hello " + m.who); }). matchEquals(“stop" -> { !!!! }).build(); } } Change the behavior context().become(ReceiveBuilder. match(Greeting.class, m -> { println(“Go Away!”);
  • 89. 3. BECOME X public class Greeter extends AbstractActor { public Greeter { receive(ReceiveBuilder. match(Greeting.class, m -> { println(“Hello " + m.who); }). matchEquals(“stop" -> { !!!! }).build(); } } Change the behavior context().become(ReceiveBuilder. match(Greeting.class, m -> { println(“Go Away!”); }).build());
  • 90. 3. BECOME X public class Greeter extends AbstractActor { public Greeter { receive(ReceiveBuilder. match(Greeting.class, m -> { println(“Hello " + m.who); }). matchEquals(“stop" -> { !!!! }).build(); } } Change the behavior context().become(ReceiveBuilder. match(Greeting.class, m -> { println(“Go Away!”); }).build());
  • 91. 3. BECOME 19 class GreetingActor extends Actor with ActorLogging { def receive = happy ! val happy: Receive = { case Greeting(who) => log.info(s”Hello ${who}") case Angry => context become angry } ! val angry: Receive = { case Greeting(_) => log.info("Go away!") case Happy => context become happy } }
  • 92. 3. BECOME 19 class GreetingActor extends Actor with ActorLogging { def receive = happy ! val happy: Receive = { case Greeting(who) => log.info(s”Hello ${who}") case Angry => context become angry } ! val angry: Receive = { case Greeting(_) => log.info("Go away!") case Happy => context become happy } } Redefine the behavior
  • 93. Reactive applications are architected to handle failure at all levels.
  • 94. Resilient • Failure is embraced as a natural state in the app lifecycle • Resilience is a first-class construct • Failure is detected, isolated, and managed • Applications self heal 21 “The Typesafe Reactive Platform helps us maintain a very aggressive development and deployment cycle, all in a fail-forward manner. It’s now the default choice for developing all new services.” Peter Hausel, VP Engineering, Gawker Media
  • 96. Think Vending Machine Coffee Programmer Machine
  • 97. Think Vending Machine Coffee Inserts coins Programmer Machine
  • 98. Think Vending Machine Coffee Inserts coins Add more coins Programmer Machine
  • 99. Think Vending Machine Coffee Inserts coins Add more coins Programmer Machine Gets coffee
  • 100. Think Vending Machine Coffee Programmer Machine
  • 101. Think Vending Machine Coffee Inserts coins Programmer Machine
  • 102. Think Vending Machine Coffee Inserts coins Out of coffee beans error Programmer Machine
  • 103. Think Vending Machine Coffee Inserts coins OutW of corfofeen begans error Programmer Machine
  • 104. Think Vending Machine Coffee Inserts coins Programmer Machine
  • 105. Think Vending Machine Coffee Inserts coins Out of coffee beans error Programmer Machine
  • 106. Think Vending Machine Service Guy Coffee Inserts coins Out of coffee beans error Programmer Machine
  • 107. Think Vending Machine Service Guy Coffee Inserts coins Out of coffee beans error Programmer Machine Adds more beans
  • 108. Think Vending Machine Service Guy Coffee Inserts coins Programmer Machine Gets coffee Out of coffee beans error Adds more beans
  • 109. The Right Way Client Service
  • 110. The Right Way Request Client Service
  • 111. The Right Way Request Client Service Response
  • 112. The Right Way Request Validation Error Client Service Response
  • 113. The Right Way Request Validation Error Client Service Response Application Error
  • 114. The Right Way Supervisor Request Validation Error Client Service Response Application Error
  • 115. The Right Way Supervisor Request Validation Error Client Service Response Application Error Manages Failure
  • 116.
  • 117. Use Bulkheads • Isolate the failure • Compartmentalize • Manage failure locally • Avoid cascading failures
  • 118. Use Bulkheads • Isolate the failure • Compartmentalize • Manage failure locally • Avoid cascading failures
  • 121. Supervisor hierarchies A Foo Bar B C B E A D C Automatic and mandatory supervision
  • 122. 4. SUPERVISE X Every single actor has a default supervisor strategy. Which is usually sufficient. But it can be overridden. class Supervisor extends UntypedActor { private SupervisorStrategy strategy = new OneForOneStrategy( 10, Duration.create(1, TimeUnit.MINUTES), DeciderBuilder. match(ArithmeticException.class, e -> resume()). match(NullPointerException.class, e -> restart()). matchAny( e -> escalate()). build()); ! @Override public SupervisorStrategy supervisorStrategy() { return strategy; }
  • 123. 4. SUPERVISE X class Supervisor extends UntypedActor { private SupervisorStrategy strategy = new OneForOneStrategy( 10, Duration.create(1, TimeUnit.MINUTES), DeciderBuilder. match(ArithmeticException.class, e -> resume()). match(NullPointerException.class, e -> restart()). matchAny( e -> escalate()). build()); ! @Override public SupervisorStrategy supervisorStrategy() { return strategy; } ActorRef worker = context.actorOf( Props.create(Worker.class), "worker"); public void onReceive(Object i) throws Exception { … } }
  • 124. Monitor through Death Watch X public class WatchActor extends AbstractActor { final ActorRef child = context().actorOf(Props.empty(), "child"); ! public WatchActor() { context().watch(child); receive(ReceiveBuilder. match(Terminated.class, t -> t.actor().equals(child), t -> { … // handle termination }).build() ); } }
  • 125. Monitor through Death Watch X public class WatchActor extends AbstractActor { final ActorRef child = context().actorOf(Props.empty(), "child"); ! public WatchActor() { context().watch(child); receive(ReceiveBuilder. match(Terminated.class, t -> t.actor().equals(child), t -> { … // handle termination }).build() ); } } Create a child actor
  • 126. Monitor through Death Watch X public class WatchActor extends AbstractActor { final ActorRef child = context().actorOf(Props.empty(), "child"); ! public WatchActor() { context().watch(child); receive(ReceiveBuilder. match(Terminated.class, t -> t.actor().equals(child), t -> { … // handle termination }).build() ); } } Create a child actor Watch it
  • 127. Monitor through Death Watch X public class WatchActor extends AbstractActor { final ActorRef child = context().actorOf(Props.empty(), "child"); ! public WatchActor() { context().watch(child); receive(ReceiveBuilder. match(Terminated.class, t -> t.actor().equals(child), t -> { … // handle termination }).build() ); } } Create a child actor Watch it Handle termination message
  • 128. 4. SUPERVISE 29 Every single actor has a default supervisor strategy. Which is usually sufficient. But it can be overridden.
  • 129. 4. SUPERVISE 29 Every single actor has a default supervisor strategy. Which is usually sufficient. But it can be overridden. class Supervisor extends Actor { override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) { case _: ArithmeticException => Resume case _: NullPointerException => Restart case _: Exception => Escalate } ! val worker = context.actorOf(Props[Worker], name = "worker") ! def receive = {
  • 130. 4. SUPERVISE 29 class Supervisor extends Actor { override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) { case _: ArithmeticException => Resume case _: NullPointerException => Restart case _: Exception => Escalate } ! val worker = context.actorOf(Props[Worker], name = "worker") ! def receive = { case n: Int => worker forward n } } !
  • 131. Cleanup & (Re)initialization 30 class Worker extends Actor { ... override def preRestart( reason: Throwable, message: Option[Any]) { ... // clean up before restart } override def postRestart(reason: Throwable) { ... // init after restart } }
  • 132. Monitor through Death Watch 31 class Watcher extends Actor { val child = context.actorOf(Props.empty, "child") context.watch(child) ! def receive = { case Terminated(`child`) => … // handle child termination } }
  • 133. Monitor through Death Watch 31 Create a child actor class Watcher extends Actor { val child = context.actorOf(Props.empty, "child") context.watch(child) ! def receive = { case Terminated(`child`) => … // handle child termination } }
  • 134. Monitor through Death Watch 31 Create a child actor Watch it class Watcher extends Actor { val child = context.actorOf(Props.empty, "child") context.watch(child) ! def receive = { case Terminated(`child`) => … // handle child termination } }
  • 135. Monitor through Death Watch 31 Create a child actor Watch it class Watcher extends Actor { val child = context.actorOf(Props.empty, "child") context.watch(child) Handle termination message ! def receive = { case Terminated(`child`) => … // handle child termination } }
  • 136. Reactive applications scale up and down to meet demand.
  • 137. Elastic • Elasticity and Scalability to embrace the Cloud • Adaptive Scale on Demand • Clustered servers support joining and leaving of nodes • More cost-efficient utilization of hardware 33 “Our traffic can increase by as much as 100x for 15 minutes each day. Until a couple of years ago, noon was a stressful time. Nowadays, it’s usually a non-event.” Eric Bowman, VP Architecture, Gilt Groupe
  • 138. 34 Scale UP Scale OUT
  • 139. 34 Essentially the same thing
  • 140. 35 We need to 1. Minimize Contention 2. Maximize Locality of Reference
  • 141. 36 Share NOTHING Design
  • 142. Fully event-driven apps are a necessity X Amdahl’s Law will hunt you down
  • 143. Define a router ActorRef router = context().actorOf( new RoundRobinPool(5).props(Props.create(Worker.class)), “router”) X
  • 144. Define a router 37 val router = context.actorOf( RoundRobinPool(5).props(Props[Worker])), “router”)
  • 145. …or from config 38 akka.actor.deployment { /service/router { router = round-robin-pool resizer { lower-bound = 12 upper-bound = 15 } } }
  • 146. Turn on clustering 39 akka { actor { provider = "akka.cluster.ClusterActorRefProvider" ... } cluster { seed-nodes = [ “akka.tcp://ClusterSystem@127.0.0.1:2551", “akka.tcp://ClusterSystem@127.0.0.1:2552" ] auto-down = off } }
  • 147. Use clustered routers 40 akka.actor.deployment { /service/master { router = consistent-­‐hashing-­‐pool nr-­‐of-­‐instances = 100 ! cluster { enabled = on max-nr-of-instances-per-node = 3 allow-­‐local-­‐routees = on use-­‐role = compute } } }
  • 148. Use clustered routers 40 Or perhaps use an AdaptiveLoadBalancingPool akka.actor.deployment { /service/master { router = consistent-­‐hashing-­‐pool nr-­‐of-­‐instances = 100 ! cluster { enabled = on max-nr-of-instances-per-node = 3 allow-­‐local-­‐routees = on use-­‐role = compute } } }
  • 150. Use clustered pub-sub 41 class Subscriber extends Actor { val mediator = DistributedPubSubExtension(context.system).mediator mediator ! Subscribe(“content”, self) def receive = { … } }
  • 151. Use clustered pub-sub 41 class Publisher extends Actor { val mediator = DistributedPubSubExtension(context.system).mediator def receive = { case in: String => mediator ! Publish("content", in.toUpperCase) } }
  • 152. • Cluster Membership • Cluster Pub/Sub • Cluster Leader • Clustered Singleton • Cluster Roles • Cluster Sharding 42 Other Akka Cluster features
  • 153. • Supports two different models: • Command Sourcing • Event Sourcing • Great for implementing • durable actors • replication • CQRS etc. • Messages persisted to Journal and replayed on restart 43 Use Akka Persistence
  • 154. X Command Sourcing Event Sourcing
  • 155. X Command Sourcing Event Sourcing write-ahead-log
  • 156. X Command Sourcing Event Sourcing write-ahead-log derive events from a command
  • 157. X Command Sourcing Event Sourcing write-ahead-log derive events from a command same behavior during recovery as normal operation
  • 158. X Command Sourcing Event Sourcing write-ahead-log derive events from a command same behavior during recovery as normal operation only state-changing behavior during recovery
  • 159. X Command Sourcing Event Sourcing write-ahead-log derive events from a command same behavior during recovery as normal operation only state-changing behavior during recovery persisted before validation
  • 160. X Command Sourcing Event Sourcing write-ahead-log derive events from a command same behavior during recovery as normal operation only state-changing behavior during recovery persisted before validation events cannot fail
  • 161. X Command Sourcing Event Sourcing write-ahead-log derive events from a command same behavior during recovery as normal operation only state-changing behavior during recovery persisted before validation events cannot fail allows retroactive changes to the business logic
  • 162. X Command Sourcing Event Sourcing write-ahead-log derive events from a command same behavior during recovery as normal operation only state-changing behavior during recovery persisted before validation events cannot fail allows retroactive changes to the business logic fixing the business logic will not affect persisted events
  • 163. X Command Sourcing Event Sourcing write-ahead-log derive events from a command same behavior during recovery as normal operation only state-changing behavior during recovery persisted before validation events cannot fail allows retroactive changes to the business logic fixing the business logic will not affect persisted events naming: represent intent, imperative
  • 164. X Command Sourcing Event Sourcing write-ahead-log derive events from a command same behavior during recovery as normal operation only state-changing behavior during recovery persisted before validation events cannot fail allows retroactive changes to the business logic fixing the business logic will not affect persisted events naming: represent intent, imperative naming: things that have completed, verbs in past tense
  • 165. Domain Events • Things that have completed, facts • Immutable • Verbs in past tense Akka Persistence Webinar • CustomerRelocated • CargoShipped • InvoiceSent “State transitions are an important part of our problem space and should be modeled within our domain.” Greg Young, 2008
  • 166. Life beyond Distributed Transactions: an Apostate’s Opinion Position Paper by Pat Helland http://www-­‐db.cs.wisc.edu/cidr/cidr2007/papers/cidr07p15.pdf “In general, application developers simply do not implement large scalable applications assuming distributed transactions.” Pat Helland Akka Persistence Webinar
  • 167. Consistency boundary • An Actor is can define an Aggregate Root • Each containing one or more Entities • Aggregate Root is the Transactional Boundary • Strong consistency within an Aggregate • Eventual consistency between Aggregates • No limit to scalability Akka Persistence Webinar
  • 168. DEMO TIME Persist a game of ping pong
  • 169.
  • 172. • Purely asynchronous and non-blocking web frameworks • No container required, no inherent bottlenecks in session management 48 Typesafe Reactive Platform • Actors are asynchronous and communicate via message passing • Supervision and clustering in support of fault tolerance • Asynchronous and immutable programming constructs • Composable abstractions enabling simpler concurrency and parallelism
  • 173. Reactive is being adopted across a wide range of industries.
  • 174. 50 Finance Internet/Social Media Mfg/Hardware Government Retail
  • 176. ©Typesafe 2014 – All Rights Reserved