SlideShare une entreprise Scribd logo
1  sur  105
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

Contenu connexe

Tendances

Introduction to MapReduce and Hadoop
Introduction to MapReduce and HadoopIntroduction to MapReduce and Hadoop
Introduction to MapReduce and HadoopMohamed Elsaka
 
Introduction to Hadoop and MapReduce
Introduction to Hadoop and MapReduceIntroduction to Hadoop and MapReduce
Introduction to Hadoop and MapReduceDr 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 | CloudxLabCloudxLab
 
A Deep Dive Into Spark
A Deep Dive Into SparkA Deep Dive Into Spark
A Deep Dive Into SparkAshish 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_labsViswanath 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 ScaleDataWorks Summit
 
Introduction to Tokyo Products
Introduction to Tokyo ProductsIntroduction to Tokyo Products
Introduction to Tokyo ProductsMikio Hirabayashi
 
Onyx data processing the clojure way
Onyx   data processing  the clojure wayOnyx   data processing  the clojure way
Onyx data processing the clojure wayBahadir Cambel
 
Hadoop & MapReduce
Hadoop & MapReduceHadoop & MapReduce
Hadoop & MapReduceNewvewm
 
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 SparkLi 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.1Stefanie 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 2010Thejas 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
MeethadoopIIIT-H
 
Big Data Analysis With RHadoop
Big Data Analysis With RHadoopBig Data Analysis With RHadoop
Big Data Analysis With RHadoopDavid Chiu
 

Tendances (20)

Introduction to MapReduce and Hadoop
Introduction to MapReduce and HadoopIntroduction to MapReduce and Hadoop
Introduction to MapReduce and Hadoop
 
Introduction to Hadoop and MapReduce
Introduction to Hadoop and MapReduceIntroduction to Hadoop and MapReduce
Introduction to Hadoop and MapReduce
 
Apache pig
Apache pigApache pig
Apache pig
 
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
 
A Deep Dive Into Spark
A Deep Dive Into SparkA Deep Dive Into Spark
A Deep Dive Into Spark
 
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
 
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
 
Introduction to Tokyo Products
Introduction to Tokyo ProductsIntroduction to Tokyo Products
Introduction to Tokyo Products
 
Onyx data processing the clojure way
Onyx   data processing  the clojure wayOnyx   data processing  the clojure way
Onyx data processing the clojure way
 
Hadoop & MapReduce
Hadoop & MapReduceHadoop & MapReduce
Hadoop & MapReduce
 
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...
 
Introduction to Spark
Introduction to SparkIntroduction to Spark
Introduction to Spark
 
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
 
mesos-devoxx14
mesos-devoxx14mesos-devoxx14
mesos-devoxx14
 
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...
 
Hadoop 2
Hadoop 2Hadoop 2
Hadoop 2
 
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
 
Ruby on Big Data (Cassandra + Hadoop)
Ruby on Big Data (Cassandra + Hadoop)Ruby on Big Data (Cassandra + Hadoop)
Ruby on Big Data (Cassandra + Hadoop)
 
Meethadoop
MeethadoopMeethadoop
Meethadoop
 
Big Data Analysis With RHadoop
Big Data Analysis With RHadoopBig Data Analysis With RHadoop
Big Data Analysis With RHadoop
 

En vedette

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 Camelkrasserm
 
Introduction to Option monad in Scala
Introduction to Option monad in ScalaIntroduction to Option monad in Scala
Introduction to Option monad in ScalaJan Krag
 
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4Sangcheol Hwang
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scalapramode_ce
 

En vedette (6)

Scala collection
Scala collectionScala collection
Scala collection
 
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
 
Introduction to Option monad in Scala
Introduction to Option monad in ScalaIntroduction to Option monad in Scala
Introduction to Option monad in Scala
 
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
 
Exception Handling in Scala
Exception Handling in ScalaException Handling in Scala
Exception Handling in Scala
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
 

Similaire à Concurrent and Distributed Applications with Akka, Java and Scala

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 2014P. 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 RippleSean Cribbs
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And DesignYaroslav Tkachenko
 
Declarative Multilingual Information Extraction with SystemT
Declarative Multilingual Information Extraction with SystemTDeclarative Multilingual Information Extraction with SystemT
Declarative Multilingual Information Extraction with SystemTLaura 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 ProtocolDaniel 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-phpapp02Typesafe
 
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 TrainingSean 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 PatternsDevin 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 LaptopDatabricks
 
Towards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresTowards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresCesare Pautasso
 
Reactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServicesReactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServicesSté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 gettextAlexander Mostovenko
 
Presto at Tivo, Boston Hadoop Meetup
Presto at Tivo, Boston Hadoop MeetupPresto at Tivo, Boston Hadoop Meetup
Presto at Tivo, Boston Hadoop MeetupJustin 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 ESIKit Chan
 
Parallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical SectionParallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical SectionTony Albrecht
 

Similaire à 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
 
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
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And Design
 
Declarative Multilingual Information Extraction with SystemT
Declarative Multilingual Information Extraction with SystemTDeclarative Multilingual Information Extraction with SystemT
Declarative Multilingual Information Extraction with SystemT
 
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
 
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
 
Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02
 
Introducing Akka
Introducing AkkaIntroducing Akka
Introducing Akka
 
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
 
Clouds: All fluff and no substance?
Clouds: All fluff and no substance?Clouds: All fluff and no substance?
Clouds: All fluff and no substance?
 
Real-World Pulsar Architectural Patterns
Real-World Pulsar Architectural PatternsReal-World Pulsar Architectural Patterns
Real-World Pulsar Architectural Patterns
 
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
 
Towards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresTowards Scalable Service Composition on Multicores
Towards Scalable Service Composition on Multicores
 
Reactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServicesReactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServices
 
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
 
Presto at Tivo, Boston Hadoop Meetup
Presto at Tivo, Boston Hadoop MeetupPresto at Tivo, Boston Hadoop Meetup
Presto at Tivo, Boston Hadoop Meetup
 
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...
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Life on the Edge with ESI
Life on the Edge with ESILife on the Edge with ESI
Life on the Edge with ESI
 
Parallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical SectionParallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical Section
 

Dernier

VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 

Dernier (20)

VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 

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