SlideShare a Scribd company logo
Concurrent and Distributed Applications 
with 
Akka, Java and Scala 
! 
Buenos Aires, Argentina, Oct 2012 
! 
@frodriguez
Moore’s law 
Moore's law says that every 18 months, 
the number of transistors that can fit within a 
given area on a chip doubles.
Moore’s law 
Moore's law says that every 18 months, 
the number of transistors that can fit within a 
given area on a chip doubles. 
Page's law says that every 18 months 
software becomes twice as slow
Modern CPUs 
intel ® 
Xeon 
® 
processor
Modern CPUs 
intel ® 
Xeon 
® 
processor 
Small improvements 
in 
execution speed
intel ® 
Xeon 
® 
processor 
Small improvements 
in 
execution speed 
but... 
Modern CPUs
Modern CPUs 
Core Core Core Core 
Cor 
Core 
Core 
Core 
Core 
Core 
Core 
Core 
Core Core 
Core Core 
Small improvements 
in 
execution speed 
but... 
Improved 
parallelism support 
Multicore processors
Alternative Moore’s & Page’s laws 
Every 18 months, 
the number of cores per chip doubles.
Alternative Moore’s & Page’s laws 
Every 18 months, 
the number of cores per chip doubles. 
Every 18 months the number of IDLE 
cores doubles
Modern Applications Demands...
Modern Applications Demands... 
Scalability
Modern Applications Demands... 
Scalability 
Vertical (scaling up) - Concurrency 
Horizontal (scaling out) - Distribution
Modern Applications Demands... 
Scalability 
Vertical (scaling up) - Concurrency 
Horizontal (scaling out) - Distribution 
Size (Resources, Users, ...) 
Geographically 
Admin / Management
Modern Applications Demands...
Modern Applications Demands... 
High Availability 
Fault Tolerance (local & distributed)
Modern Applications Demands... 
High Availability 
Fault Tolerance (local & distributed) 
Performance & Low Latency 
Efficient Use of Resources (CPU & Memory) 
Asynchronous (reduced latency) 
Distributed (cheap machines, better performance / $)
How to Write 
Concurrent Applications 
for 
Multicore Processors ?
Traditional Approach 
Threads (pools processing tasks) 
Shared (and mutable) State 
Synchronization and Locking 
Concurrent Collections
Traditional Threads ?
Traditional Threads ? 
process(...){ 
}
Traditional Threads ? 
process(...){ 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Updating State in the Heap 
Returning Results 
}
Traditional Threads ? 
process(...){ 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Updating State in the Heap 
Returning Results 
}
Traditional Threads ? 
process(...){ 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Blocked 
Updating State in the Heap 
Returning Results 
} 
Thread 
Suspended
Traditional Threads ? 
process(...){ 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Updating State in the Heap 
Returning Results 
}
Traditional Threads ? 
process(...){ 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Updating State in the Heap 
Returning Results 
}
Traditional Threads ? 
process(...){ 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Updating State in the Heap 
Returning Results 
} 
Add concurrency...
Traditional Threads ? 
process(...){ 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Updating State in the Heap 
Returning Results 
}
Traditional Threads ? 
process(...){ 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Updating State in the Heap 
Returning Results 
Requires 
Synchronization 
can be blocked 
Requires 
Synchronization 
can be blocked 
}
Traditional Threads ? 
process(...){ 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Updating State in the Heap 
Returning Results 
Requires 
Synchronization 
can be blocked 
Requires 
Synchronization 
can be blocked 
} 
Bad for 
CPU caches
Traditional Threads ? 
How many threads ? 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Updating State in the Heap 
Returning Results
Traditional Threads ? 
How many threads ? 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Updating State in the Heap 
Returning Results
Traditional Threads ? 
How many threads ? 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Updating State in the Heap 
Returning Results 
Improves with threads 
(Assuming blocking, 
non-async I/O is used...)
Traditional Threads ? 
How many threads ? 
Computing 
Reading State from Heap 
I/O (e.g: Disk, Network, DBs) 
Processing Results 
Updating State in the Heap 
Returning Results 
Degrades with more 
threads than cores 
Context Switching, 
Contention, 
L1 & L2 Caches
What About Latency ? 
Client 
Biz 
DB 
Fetching 
and 
Mapping N Items 
Latency (time to first item) 
Thread by task (instead of by layer). Sync Results
What About Latency ? 
Client 
Biz 
DB 
Fetching 
and 
Mapping N Items 
Latency (time to first item) 
Parallelism by Layer - Asynchronous and Partial Results 
From Request/Response to Request Stream/Response Stream
How to Write 
Distributed Applications ?
Traditional Approach 
RPC (WS, RMI, ...) 
Queues (JMS, AMQP, STOMP, etc), 
Raw Sockets
Traditional Approach 
RPC (WS, RMI, ...) 
Queues (JMS, AMQP, STOMP, etc), 
Raw Sockets 
Local != Remote 
Local should be an optimization, 
not a forced early decision...
Akka 
“Akka is a toolkit and runtime for 
building highly concurrent, 
distributed, and fault tolerant event-driven 
applications on the JVM. ” 
Based on the actor model
What is an Actor ? 
Actors are objects which 
encapsulate state and behavior 
Communicate exclusively by 
exchanging messages 
Conceptually have their own 
light-weight thread 
No Need for Synchronization
Actors 
Actor 
State 
Behavior
Actors 
Actor 
State 
Behavior 
Mailbox
Actors 
Actor 
State 
Behavior 
C B A 
Mailbox
Actors 
Actor 
State 
Behavior 
C B A 
Mailbox
Actors 
Actor 
State 
Behavior 
C B A 
Mailbox
Actors 
Actor 
State 
BehaAvior 
C B 
Mailbox
Actors 
Actor 
State 
Behavior 
C B 
Mailbox
Actors 
Actor 
State 
Behavior 
C B 
Mailbox
Actors 
Actor 
State 
Behavior 
C B 
Millions of 
Actors 
Mailbox 
One per Actor
Actors 
Actor 
State 
Behavior 
Number of 
Threads 
Proportional to 
number of 
Cores 
C B 
Millions of 
Actors 
Mailbox 
One per Actor
Actors: Processing Messages 
/myactor 
State 
Behavior 
A
Actors: Processing Messages 
/myactor 
State 
BehaAvior
Actors: Processing Messages 
/myactor 
New State 
State 
Behavior 
Change State
Actors: Processing Messages 
/myactor 
State 
NBeewh Baevhaioviorr 
Change State 
Change Behavior
Actors: Processing Messages 
/myactor 
State 
Behavior 
/someactor 
State 
B Behavior 
Change State 
Change Behavior 
Send a Message
Actors: Processing Messages 
/myactor 
State 
Behavior 
/someactor 
State 
Behavior 
B 
Change State 
Change Behavior 
Send a Message
Actors: Processing Messages 
/myactor 
State 
Behavior 
/someactor 
State 
BehaBvior 
Change State 
Change Behavior 
Send a Message
Actors: Processing Messages 
/myactor 
State 
Behavior 
/someactor 
State 
Behavior 
/myactor/child 
State 
Behavior 
Change State 
Change Behavior 
Send a Message 
Create Actors
Hello World Actor 
Define 
class HelloWorld extends Actor { 
def receive = { 
case msg => 
printf(“Received %sn”, msg) 
} 
} 
Create 
val system = ActorSystem(“MySystem”) 
val hello = system.actorOf(Props[HelloWorld], “hello”) 
Send Message 
hello ! “World”
Counter Actor 
Define 
class Counter extends Actor { 
var total = 0 
! 
def receive = { 
case Count(value) => 
total += value 
case GetStats => 
sender ! Stats(total) 
} 
} 
Protocol 
case class Count(n: Int) 
case class Stats(total: Int) 
case object GetStats
Sending a Message 
/actorB 
State 
Behavior 
/actorA 
State 
Behavior
Sending a Message 
/actorB 
State 
Behavior 
/actorA 
State 
Behavior 
actorB ! A
Sending a Message 
/actorB 
State 
Behavior 
/actorA 
State 
BehAavior 
actorB ! A
Sending a Message 
/actorB 
State 
Behavior 
/actorA 
State 
Behavior 
A 
actorB ! A
Sending a Message 
/actorB 
State 
Behavior 
/actorA 
State 
Behavior A 
actorB ! A
Sending a Message 
/actorB 
State 
Behavior 
/actorA 
State 
Behavior A 
actorB ! A sender ! B
Sending a Message 
/actorB 
State 
Behavior 
/actorA 
State 
Behavior 
B 
actorB ! A sender ! B
Sending a Message 
/actorB 
State 
Behavior 
/actorA 
State 
Behavior 
actorB ! A sender ! B 
B
Sending a Message 
/actorB 
State 
Behavior 
/actorA 
State 
Behavior 
B 
actorB ! A sender ! B
Sending a Message 
/actorB 
State 
Behavior 
/actorA 
State 
Behavior 
actorB ! A sender ! B
Sending a Message 
/actorB 
State 
Behavior 
/actorA 
State 
Behavior 
actorB ! A 
actorB tell A 
sender ! B 
sender tell B
Sending a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior
Sending a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB tell (A, actorC)
Sending a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
BehAavior 
actorB tell (A, actorC)
Sending a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
A 
actorB tell (A, actorC)
Sending a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior A 
actorB tell (A, actorC)
Sending a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior A 
actorB tell (A, actorC) sender ! B
Sending a Message 
/actorB 
State 
Behavior 
B 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB tell (A, actorC) sender ! B
Sending a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB tell (A, actorC) sender ! B 
B
Sending a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB tell (A, actorC) sender ! B 
B
Sending a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB tell (A, actorC) sender ! B
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB ! A
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
BehAavior 
actorB ! A
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
A 
actorB ! A
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior A 
actorB ! A
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior A 
actorB ! A actorC forward B
Forward a Message 
/actorB 
State 
Behavior 
B 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB ! A actorC forward B
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB ! A actorC forward B 
B
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB ! A actorC forward B 
B
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB ! A actorC forward B 
sender ! C B
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB ! A actorC forward B 
sender ! C C
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB ! A actorC forward B 
sender ! C 
C
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
C 
actorB ! A actorC forward B 
sender ! C
Forward a Message 
/actorB 
State 
Behavior 
/actorC 
State 
Behavior 
/actorA 
State 
Behavior 
actorB ! A actorC forward B 
sender ! C
Ask & Pipe Patterns 
Ask 
val response = actor ? Message 
! 
response onSuccess { 
case Response(a) => 
printf(“Response %s”, a) 
} 
Pipe 
val response = actor ? Message 
! 
response pipeTo actor2
Mailbox 
UnboundedMailbox (default) 
UnboundedPriorityMailbox 
BoundedMailbox (*) 
BoundedPriorityMailbox (*) 
* May produce deadlocks if used unproperly
Routing 
Round Robin Router 
val actor = system.actorOf( 
Props[MyActor].withRouter(RoundRobinRouter(4)), 
name = “myrouter” 
) 
Using actor with routers (no changes) 
! 
actor ! Message
Routing 
RoundRobinRouter 
RandomRouter 
SmallestMailboxRouter 
BroadcastRouter 
ScatterGatherFirstCompletedRouter
Routing Configuration 
Configuration overrides code 
akka.actor.deployment { 
/myrouter { 
router = round-robin 
nr-of-instances = 8 
} 
} 
Routers from Config 
val actor = system.actorOf( 
Props[MyActor].withRouter(FromConfig()), 
name = “myrouter” 
)
Remoting 
Accessing remote actor 
val actor = system.actorFor( 
“akka://sys@server:2552/user/actor” 
) 
Using remote actor (no changes) 
! 
actor ! Message 
! 
// Replies also work ok 
sender ! Response
Remote Deployment 
Code without changes 
val actor = system.actorOf( 
Props[MyActor], 
name = “myactor” 
) 
Configuration 
! 
akka.actor.deployment { 
/myactor { 
remote = “akka://sys@server:2553” 
} 
}
Remote Deployment (routers) 
akka.actor.deployment { 
/myrouter { 
router = round-robin 
nr-of-instances = 8 
! 
target { 
nodes = [“akka://sys@server1:2552” 
“akka://sys@server2:2552”] 
} 
} 
} 
Routers from Config 
val actor = system.actorOf( 
Props[MyActor].withRouter(FromConfig()), 
name = “myrouter” 
)
Fault Tolerance 
override val supervisorStrategy = OneForOneStrategy(...) 
{ 
case _: ArithmeticException => Resume 
case _: NullPointerException => Restart 
case _: IllegalArgumentException => Stop 
case _: Exception => Escalate 
} 
Supervision Hierarchies across machines
Thanks 
@frodriguez 
frodriguez <at> gmail.com
Ad

More Related Content

What's hot (20)

Introduction to MapReduce and Hadoop
Introduction to MapReduce and HadoopIntroduction to MapReduce and Hadoop
Introduction to MapReduce and Hadoop
Mohamed Elsaka
 
Introduction to Hadoop and MapReduce
Introduction to Hadoop and MapReduceIntroduction to Hadoop and MapReduce
Introduction to Hadoop and MapReduce
Dr Ganesh Iyer
 
Apache pig
Apache pigApache pig
Apache pig
Jigar Parekh
 
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
CloudxLab
 
A Deep Dive Into Spark
A Deep Dive Into SparkA Deep Dive Into Spark
A Deep Dive Into Spark
Ashish kumar
 
Apache pig power_tools_by_viswanath_gangavaram_r&d_dsg_i_labs
Apache pig power_tools_by_viswanath_gangavaram_r&d_dsg_i_labsApache pig power_tools_by_viswanath_gangavaram_r&d_dsg_i_labs
Apache pig power_tools_by_viswanath_gangavaram_r&d_dsg_i_labs
Viswanath Gangavaram
 
Shark SQL and Rich Analytics at Scale
Shark SQL and Rich Analytics at ScaleShark SQL and Rich Analytics at Scale
Shark SQL and Rich Analytics at Scale
DataWorks Summit
 
Introduction to Tokyo Products
Introduction to Tokyo ProductsIntroduction to Tokyo Products
Introduction to Tokyo Products
Mikio Hirabayashi
 
Onyx data processing the clojure way
Onyx   data processing  the clojure wayOnyx   data processing  the clojure way
Onyx data processing the clojure way
Bahadir Cambel
 
Hadoop & MapReduce
Hadoop & MapReduceHadoop & MapReduce
Hadoop & MapReduce
Newvewm
 
dmapply: A functional primitive to express distributed machine learning algor...
dmapply: A functional primitive to express distributed machine learning algor...dmapply: A functional primitive to express distributed machine learning algor...
dmapply: A functional primitive to express distributed machine learning algor...
Bikash Chandra Karmokar
 
Introduction to Spark
Introduction to SparkIntroduction to Spark
Introduction to Spark
Li Ming Tsai
 
BDAS Shark study report 03 v1.1
BDAS Shark study report  03 v1.1BDAS Shark study report  03 v1.1
BDAS Shark study report 03 v1.1
Stefanie Zhao
 
mesos-devoxx14
mesos-devoxx14mesos-devoxx14
mesos-devoxx14
Samir Bessalah
 
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
InfluxData
 
Hadoop 2
Hadoop 2Hadoop 2
Hadoop 2
EasyMedico.com
 
apache pig performance optimizations talk at apachecon 2010
apache pig performance optimizations talk at apachecon 2010apache pig performance optimizations talk at apachecon 2010
apache pig performance optimizations talk at apachecon 2010
Thejas Nair
 
Ruby on Big Data (Cassandra + Hadoop)
Ruby on Big Data (Cassandra + Hadoop)Ruby on Big Data (Cassandra + Hadoop)
Ruby on Big Data (Cassandra + Hadoop)
Brian O'Neill
 
Meethadoop
MeethadoopMeethadoop
Meethadoop
IIIT-H
 
Big Data Analysis With RHadoop
Big Data Analysis With RHadoopBig Data Analysis With RHadoop
Big Data Analysis With RHadoop
David Chiu
 
Introduction to MapReduce and Hadoop
Introduction to MapReduce and HadoopIntroduction to MapReduce and Hadoop
Introduction to MapReduce and Hadoop
Mohamed Elsaka
 
Introduction to Hadoop and MapReduce
Introduction to Hadoop and MapReduceIntroduction to Hadoop and MapReduce
Introduction to Hadoop and MapReduce
Dr Ganesh Iyer
 
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
CloudxLab
 
A Deep Dive Into Spark
A Deep Dive Into SparkA Deep Dive Into Spark
A Deep Dive Into Spark
Ashish kumar
 
Apache pig power_tools_by_viswanath_gangavaram_r&d_dsg_i_labs
Apache pig power_tools_by_viswanath_gangavaram_r&d_dsg_i_labsApache pig power_tools_by_viswanath_gangavaram_r&d_dsg_i_labs
Apache pig power_tools_by_viswanath_gangavaram_r&d_dsg_i_labs
Viswanath Gangavaram
 
Shark SQL and Rich Analytics at Scale
Shark SQL and Rich Analytics at ScaleShark SQL and Rich Analytics at Scale
Shark SQL and Rich Analytics at Scale
DataWorks Summit
 
Introduction to Tokyo Products
Introduction to Tokyo ProductsIntroduction to Tokyo Products
Introduction to Tokyo Products
Mikio Hirabayashi
 
Onyx data processing the clojure way
Onyx   data processing  the clojure wayOnyx   data processing  the clojure way
Onyx data processing the clojure way
Bahadir Cambel
 
Hadoop & MapReduce
Hadoop & MapReduceHadoop & MapReduce
Hadoop & MapReduce
Newvewm
 
dmapply: A functional primitive to express distributed machine learning algor...
dmapply: A functional primitive to express distributed machine learning algor...dmapply: A functional primitive to express distributed machine learning algor...
dmapply: A functional primitive to express distributed machine learning algor...
Bikash Chandra Karmokar
 
Introduction to Spark
Introduction to SparkIntroduction to Spark
Introduction to Spark
Li Ming Tsai
 
BDAS Shark study report 03 v1.1
BDAS Shark study report  03 v1.1BDAS Shark study report  03 v1.1
BDAS Shark study report 03 v1.1
Stefanie Zhao
 
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
InfluxData
 
apache pig performance optimizations talk at apachecon 2010
apache pig performance optimizations talk at apachecon 2010apache pig performance optimizations talk at apachecon 2010
apache pig performance optimizations talk at apachecon 2010
Thejas Nair
 
Ruby on Big Data (Cassandra + Hadoop)
Ruby on Big Data (Cassandra + Hadoop)Ruby on Big Data (Cassandra + Hadoop)
Ruby on Big Data (Cassandra + Hadoop)
Brian O'Neill
 
Meethadoop
MeethadoopMeethadoop
Meethadoop
IIIT-H
 
Big Data Analysis With RHadoop
Big Data Analysis With RHadoopBig Data Analysis With RHadoop
Big Data Analysis With RHadoop
David Chiu
 

Viewers also liked (6)

Scala collection
Scala collectionScala collection
Scala collection
Knoldus Inc.
 
System Integration with Akka and Apache Camel
System Integration with Akka and Apache CamelSystem Integration with Akka and Apache Camel
System Integration with Akka and Apache Camel
krasserm
 
Introduction to Option monad in Scala
Introduction to Option monad in ScalaIntroduction to Option monad in Scala
Introduction to Option monad in Scala
Jan Krag
 
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Sangcheol Hwang
 
Exception Handling in Scala
Exception Handling in ScalaException Handling in Scala
Exception Handling in Scala
Nag Arvind Gudiseva
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
pramode_ce
 
System Integration with Akka and Apache Camel
System Integration with Akka and Apache CamelSystem Integration with Akka and Apache Camel
System Integration with Akka and Apache Camel
krasserm
 
Introduction to Option monad in Scala
Introduction to Option monad in ScalaIntroduction to Option monad in Scala
Introduction to Option monad in Scala
Jan Krag
 
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Sangcheol Hwang
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
pramode_ce
 
Ad

Similar to Concurrent and Distributed Applications with Akka, Java and Scala (20)

Scaling Apache Storm - Strata + Hadoop World 2014
Scaling Apache Storm - Strata + Hadoop World 2014Scaling Apache Storm - Strata + Hadoop World 2014
Scaling Apache Storm - Strata + Hadoop World 2014
P. Taylor Goetz
 
Embrace NoSQL and Eventual Consistency with Ripple
Embrace NoSQL and Eventual Consistency with RippleEmbrace NoSQL and Eventual Consistency with Ripple
Embrace NoSQL and Eventual Consistency with Ripple
Sean Cribbs
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And Design
Yaroslav Tkachenko
 
Declarative Multilingual Information Extraction with SystemT
Declarative Multilingual Information Extraction with SystemTDeclarative Multilingual Information Extraction with SystemT
Declarative Multilingual Information Extraction with SystemT
Laura Chiticariu
 
Notes on a High-Performance JSON Protocol
Notes on a High-Performance JSON ProtocolNotes on a High-Performance JSON Protocol
Notes on a High-Performance JSON Protocol
Daniel Austin
 
Actors, a Unifying Pattern for Scalable Concurrency | C4 2006
Actors, a Unifying Pattern for Scalable Concurrency | C4 2006 Actors, a Unifying Pattern for Scalable Concurrency | C4 2006
Actors, a Unifying Pattern for Scalable Concurrency | C4 2006
Real Nobile
 
Introducing Akka
Introducing AkkaIntroducing Akka
Introducing Akka
Jonas Bonér
 
Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02
Typesafe
 
Introduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf TrainingIntroduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf Training
Sean Cribbs
 
Clouds: All fluff and no substance?
Clouds: All fluff and no substance?Clouds: All fluff and no substance?
Clouds: All fluff and no substance?
Guy Coates
 
Real-World Pulsar Architectural Patterns
Real-World Pulsar Architectural PatternsReal-World Pulsar Architectural Patterns
Real-World Pulsar Architectural Patterns
Devin Bost
 
Project Tungsten Phase II: Joining a Billion Rows per Second on a Laptop
Project Tungsten Phase II: Joining a Billion Rows per Second on a LaptopProject Tungsten Phase II: Joining a Billion Rows per Second on a Laptop
Project Tungsten Phase II: Joining a Billion Rows per Second on a Laptop
Databricks
 
Towards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresTowards Scalable Service Composition on Multicores
Towards Scalable Service Composition on Multicores
Cesare Pautasso
 
Reactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServicesReactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServices
Stéphane Maldini
 
Modern javascript localization with c-3po and the good old gettext
Modern javascript localization with c-3po and the good old gettextModern javascript localization with c-3po and the good old gettext
Modern javascript localization with c-3po and the good old gettext
Alexander Mostovenko
 
Presto at Tivo, Boston Hadoop Meetup
Presto at Tivo, Boston Hadoop MeetupPresto at Tivo, Boston Hadoop Meetup
Presto at Tivo, Boston Hadoop Meetup
Justin Borgman
 
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
Codemotion
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
Oleg Podsechin
 
Life on the Edge with ESI
Life on the Edge with ESILife on the Edge with ESI
Life on the Edge with ESI
Kit Chan
 
Parallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical SectionParallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical Section
Tony Albrecht
 
Scaling Apache Storm - Strata + Hadoop World 2014
Scaling Apache Storm - Strata + Hadoop World 2014Scaling Apache Storm - Strata + Hadoop World 2014
Scaling Apache Storm - Strata + Hadoop World 2014
P. Taylor Goetz
 
Embrace NoSQL and Eventual Consistency with Ripple
Embrace NoSQL and Eventual Consistency with RippleEmbrace NoSQL and Eventual Consistency with Ripple
Embrace NoSQL and Eventual Consistency with Ripple
Sean Cribbs
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And Design
Yaroslav Tkachenko
 
Declarative Multilingual Information Extraction with SystemT
Declarative Multilingual Information Extraction with SystemTDeclarative Multilingual Information Extraction with SystemT
Declarative Multilingual Information Extraction with SystemT
Laura Chiticariu
 
Notes on a High-Performance JSON Protocol
Notes on a High-Performance JSON ProtocolNotes on a High-Performance JSON Protocol
Notes on a High-Performance JSON Protocol
Daniel Austin
 
Actors, a Unifying Pattern for Scalable Concurrency | C4 2006
Actors, a Unifying Pattern for Scalable Concurrency | C4 2006 Actors, a Unifying Pattern for Scalable Concurrency | C4 2006
Actors, a Unifying Pattern for Scalable Concurrency | C4 2006
Real Nobile
 
Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02
Typesafe
 
Introduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf TrainingIntroduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf Training
Sean Cribbs
 
Clouds: All fluff and no substance?
Clouds: All fluff and no substance?Clouds: All fluff and no substance?
Clouds: All fluff and no substance?
Guy Coates
 
Real-World Pulsar Architectural Patterns
Real-World Pulsar Architectural PatternsReal-World Pulsar Architectural Patterns
Real-World Pulsar Architectural Patterns
Devin Bost
 
Project Tungsten Phase II: Joining a Billion Rows per Second on a Laptop
Project Tungsten Phase II: Joining a Billion Rows per Second on a LaptopProject Tungsten Phase II: Joining a Billion Rows per Second on a Laptop
Project Tungsten Phase II: Joining a Billion Rows per Second on a Laptop
Databricks
 
Towards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresTowards Scalable Service Composition on Multicores
Towards Scalable Service Composition on Multicores
Cesare Pautasso
 
Reactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServicesReactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServices
Stéphane Maldini
 
Modern javascript localization with c-3po and the good old gettext
Modern javascript localization with c-3po and the good old gettextModern javascript localization with c-3po and the good old gettext
Modern javascript localization with c-3po and the good old gettext
Alexander Mostovenko
 
Presto at Tivo, Boston Hadoop Meetup
Presto at Tivo, Boston Hadoop MeetupPresto at Tivo, Boston Hadoop Meetup
Presto at Tivo, Boston Hadoop Meetup
Justin Borgman
 
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
Codemotion
 
Life on the Edge with ESI
Life on the Edge with ESILife on the Edge with ESI
Life on the Edge with ESI
Kit Chan
 
Parallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical SectionParallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical Section
Tony Albrecht
 
Ad

Recently uploaded (20)

Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxbMain cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
SunilSingh610661
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
New Microsoft PowerPoint Presentation.pdf
New Microsoft PowerPoint Presentation.pdfNew Microsoft PowerPoint Presentation.pdf
New Microsoft PowerPoint Presentation.pdf
mohamedezzat18803
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
The Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLabThe Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLab
Journal of Soft Computing in Civil Engineering
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxbMain cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
SunilSingh610661
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
New Microsoft PowerPoint Presentation.pdf
New Microsoft PowerPoint Presentation.pdfNew Microsoft PowerPoint Presentation.pdf
New Microsoft PowerPoint Presentation.pdf
mohamedezzat18803
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 

Concurrent and Distributed Applications with Akka, Java and Scala

  • 1. Concurrent and Distributed Applications with Akka, Java and Scala ! Buenos Aires, Argentina, Oct 2012 ! @frodriguez
  • 2. Moore’s law Moore's law says that every 18 months, the number of transistors that can fit within a given area on a chip doubles.
  • 3. Moore’s law Moore's law says that every 18 months, the number of transistors that can fit within a given area on a chip doubles. Page's law says that every 18 months software becomes twice as slow
  • 4. Modern CPUs intel ® Xeon ® processor
  • 5. Modern CPUs intel ® Xeon ® processor Small improvements in execution speed
  • 6. intel ® Xeon ® processor Small improvements in execution speed but... Modern CPUs
  • 7. Modern CPUs Core Core Core Core Cor Core Core Core Core Core Core Core Core Core Core Core Small improvements in execution speed but... Improved parallelism support Multicore processors
  • 8. Alternative Moore’s & Page’s laws Every 18 months, the number of cores per chip doubles.
  • 9. Alternative Moore’s & Page’s laws Every 18 months, the number of cores per chip doubles. Every 18 months the number of IDLE cores doubles
  • 12. Modern Applications Demands... Scalability Vertical (scaling up) - Concurrency Horizontal (scaling out) - Distribution
  • 13. Modern Applications Demands... Scalability Vertical (scaling up) - Concurrency Horizontal (scaling out) - Distribution Size (Resources, Users, ...) Geographically Admin / Management
  • 15. Modern Applications Demands... High Availability Fault Tolerance (local & distributed)
  • 16. Modern Applications Demands... High Availability Fault Tolerance (local & distributed) Performance & Low Latency Efficient Use of Resources (CPU & Memory) Asynchronous (reduced latency) Distributed (cheap machines, better performance / $)
  • 17. How to Write Concurrent Applications for Multicore Processors ?
  • 18. Traditional Approach Threads (pools processing tasks) Shared (and mutable) State Synchronization and Locking Concurrent Collections
  • 20. Traditional Threads ? process(...){ }
  • 21. Traditional Threads ? process(...){ Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Updating State in the Heap Returning Results }
  • 22. Traditional Threads ? process(...){ Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Updating State in the Heap Returning Results }
  • 23. Traditional Threads ? process(...){ Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Blocked Updating State in the Heap Returning Results } Thread Suspended
  • 24. Traditional Threads ? process(...){ Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Updating State in the Heap Returning Results }
  • 25. Traditional Threads ? process(...){ Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Updating State in the Heap Returning Results }
  • 26. Traditional Threads ? process(...){ Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Updating State in the Heap Returning Results } Add concurrency...
  • 27. Traditional Threads ? process(...){ Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Updating State in the Heap Returning Results }
  • 28. Traditional Threads ? process(...){ Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Updating State in the Heap Returning Results Requires Synchronization can be blocked Requires Synchronization can be blocked }
  • 29. Traditional Threads ? process(...){ Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Updating State in the Heap Returning Results Requires Synchronization can be blocked Requires Synchronization can be blocked } Bad for CPU caches
  • 30. Traditional Threads ? How many threads ? Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Updating State in the Heap Returning Results
  • 31. Traditional Threads ? How many threads ? Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Updating State in the Heap Returning Results
  • 32. Traditional Threads ? How many threads ? Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Updating State in the Heap Returning Results Improves with threads (Assuming blocking, non-async I/O is used...)
  • 33. Traditional Threads ? How many threads ? Computing Reading State from Heap I/O (e.g: Disk, Network, DBs) Processing Results Updating State in the Heap Returning Results Degrades with more threads than cores Context Switching, Contention, L1 & L2 Caches
  • 34. What About Latency ? Client Biz DB Fetching and Mapping N Items Latency (time to first item) Thread by task (instead of by layer). Sync Results
  • 35. What About Latency ? Client Biz DB Fetching and Mapping N Items Latency (time to first item) Parallelism by Layer - Asynchronous and Partial Results From Request/Response to Request Stream/Response Stream
  • 36. How to Write Distributed Applications ?
  • 37. Traditional Approach RPC (WS, RMI, ...) Queues (JMS, AMQP, STOMP, etc), Raw Sockets
  • 38. Traditional Approach RPC (WS, RMI, ...) Queues (JMS, AMQP, STOMP, etc), Raw Sockets Local != Remote Local should be an optimization, not a forced early decision...
  • 39. Akka “Akka is a toolkit and runtime for building highly concurrent, distributed, and fault tolerant event-driven applications on the JVM. ” Based on the actor model
  • 40. What is an Actor ? Actors are objects which encapsulate state and behavior Communicate exclusively by exchanging messages Conceptually have their own light-weight thread No Need for Synchronization
  • 41. Actors Actor State Behavior
  • 42. Actors Actor State Behavior Mailbox
  • 43. Actors Actor State Behavior C B A Mailbox
  • 44. Actors Actor State Behavior C B A Mailbox
  • 45. Actors Actor State Behavior C B A Mailbox
  • 46. Actors Actor State BehaAvior C B Mailbox
  • 47. Actors Actor State Behavior C B Mailbox
  • 48. Actors Actor State Behavior C B Mailbox
  • 49. Actors Actor State Behavior C B Millions of Actors Mailbox One per Actor
  • 50. Actors Actor State Behavior Number of Threads Proportional to number of Cores C B Millions of Actors Mailbox One per Actor
  • 51. Actors: Processing Messages /myactor State Behavior A
  • 52. Actors: Processing Messages /myactor State BehaAvior
  • 53. Actors: Processing Messages /myactor New State State Behavior Change State
  • 54. Actors: Processing Messages /myactor State NBeewh Baevhaioviorr Change State Change Behavior
  • 55. Actors: Processing Messages /myactor State Behavior /someactor State B Behavior Change State Change Behavior Send a Message
  • 56. Actors: Processing Messages /myactor State Behavior /someactor State Behavior B Change State Change Behavior Send a Message
  • 57. Actors: Processing Messages /myactor State Behavior /someactor State BehaBvior Change State Change Behavior Send a Message
  • 58. Actors: Processing Messages /myactor State Behavior /someactor State Behavior /myactor/child State Behavior Change State Change Behavior Send a Message Create Actors
  • 59. Hello World Actor Define class HelloWorld extends Actor { def receive = { case msg => printf(“Received %sn”, msg) } } Create val system = ActorSystem(“MySystem”) val hello = system.actorOf(Props[HelloWorld], “hello”) Send Message hello ! “World”
  • 60. Counter Actor Define class Counter extends Actor { var total = 0 ! def receive = { case Count(value) => total += value case GetStats => sender ! Stats(total) } } Protocol case class Count(n: Int) case class Stats(total: Int) case object GetStats
  • 61. Sending a Message /actorB State Behavior /actorA State Behavior
  • 62. Sending a Message /actorB State Behavior /actorA State Behavior actorB ! A
  • 63. Sending a Message /actorB State Behavior /actorA State BehAavior actorB ! A
  • 64. Sending a Message /actorB State Behavior /actorA State Behavior A actorB ! A
  • 65. Sending a Message /actorB State Behavior /actorA State Behavior A actorB ! A
  • 66. Sending a Message /actorB State Behavior /actorA State Behavior A actorB ! A sender ! B
  • 67. Sending a Message /actorB State Behavior /actorA State Behavior B actorB ! A sender ! B
  • 68. Sending a Message /actorB State Behavior /actorA State Behavior actorB ! A sender ! B B
  • 69. Sending a Message /actorB State Behavior /actorA State Behavior B actorB ! A sender ! B
  • 70. Sending a Message /actorB State Behavior /actorA State Behavior actorB ! A sender ! B
  • 71. Sending a Message /actorB State Behavior /actorA State Behavior actorB ! A actorB tell A sender ! B sender tell B
  • 72. Sending a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior
  • 73. Sending a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior actorB tell (A, actorC)
  • 74. Sending a Message /actorB State Behavior /actorC State Behavior /actorA State BehAavior actorB tell (A, actorC)
  • 75. Sending a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior A actorB tell (A, actorC)
  • 76. Sending a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior A actorB tell (A, actorC)
  • 77. Sending a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior A actorB tell (A, actorC) sender ! B
  • 78. Sending a Message /actorB State Behavior B /actorC State Behavior /actorA State Behavior actorB tell (A, actorC) sender ! B
  • 79. Sending a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior actorB tell (A, actorC) sender ! B B
  • 80. Sending a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior actorB tell (A, actorC) sender ! B B
  • 81. Sending a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior actorB tell (A, actorC) sender ! B
  • 82. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior
  • 83. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior actorB ! A
  • 84. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State BehAavior actorB ! A
  • 85. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior A actorB ! A
  • 86. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior A actorB ! A
  • 87. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior A actorB ! A actorC forward B
  • 88. Forward a Message /actorB State Behavior B /actorC State Behavior /actorA State Behavior actorB ! A actorC forward B
  • 89. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior actorB ! A actorC forward B B
  • 90. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior actorB ! A actorC forward B B
  • 91. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior actorB ! A actorC forward B sender ! C B
  • 92. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior actorB ! A actorC forward B sender ! C C
  • 93. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior actorB ! A actorC forward B sender ! C C
  • 94. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior C actorB ! A actorC forward B sender ! C
  • 95. Forward a Message /actorB State Behavior /actorC State Behavior /actorA State Behavior actorB ! A actorC forward B sender ! C
  • 96. Ask & Pipe Patterns Ask val response = actor ? Message ! response onSuccess { case Response(a) => printf(“Response %s”, a) } Pipe val response = actor ? Message ! response pipeTo actor2
  • 97. Mailbox UnboundedMailbox (default) UnboundedPriorityMailbox BoundedMailbox (*) BoundedPriorityMailbox (*) * May produce deadlocks if used unproperly
  • 98. Routing Round Robin Router val actor = system.actorOf( Props[MyActor].withRouter(RoundRobinRouter(4)), name = “myrouter” ) Using actor with routers (no changes) ! actor ! Message
  • 99. Routing RoundRobinRouter RandomRouter SmallestMailboxRouter BroadcastRouter ScatterGatherFirstCompletedRouter
  • 100. Routing Configuration Configuration overrides code akka.actor.deployment { /myrouter { router = round-robin nr-of-instances = 8 } } Routers from Config val actor = system.actorOf( Props[MyActor].withRouter(FromConfig()), name = “myrouter” )
  • 101. Remoting Accessing remote actor val actor = system.actorFor( “akka://sys@server:2552/user/actor” ) Using remote actor (no changes) ! actor ! Message ! // Replies also work ok sender ! Response
  • 102. Remote Deployment Code without changes val actor = system.actorOf( Props[MyActor], name = “myactor” ) Configuration ! akka.actor.deployment { /myactor { remote = “akka://sys@server:2553” } }
  • 103. Remote Deployment (routers) akka.actor.deployment { /myrouter { router = round-robin nr-of-instances = 8 ! target { nodes = [“akka://sys@server1:2552” “akka://sys@server2:2552”] } } } Routers from Config val actor = system.actorOf( Props[MyActor].withRouter(FromConfig()), name = “myrouter” )
  • 104. Fault Tolerance override val supervisorStrategy = OneForOneStrategy(...) { case _: ArithmeticException => Resume case _: NullPointerException => Restart case _: IllegalArgumentException => Stop case _: Exception => Escalate } Supervision Hierarchies across machines
  • 105. Thanks @frodriguez frodriguez <at> gmail.com