SlideShare a Scribd company logo
1 of 62
Akka in Action
Raymond Roestenburg
@RayRoestenburg
rroestenburg@xebia.com
github.com/RayRoestenburg
manning.com/roestenburg
12mp25 for 42% Off!
Early Akka adopter (v0.7, 2010)
Akka Committer (akka-camel in 2.x)
Co-author of Akka in Action
“The free lunch is over” / TANSTAAFL
Herb Sutter 2005 http://www.gotw.ca/publications/concurrency-ddj.htm
Number
of transistors
Clock Speed
Can‟t I just..
Parallelize
that Sh*t™?
Put that in a box!
Something like this?
Parallel
Version
9
Hey Oracle don‟t sue me, of course it‟s fake
Nope. Parallelize that Sh*t™
Not every algorithm can be parallelized
Dynamic coordination (concurrent)
Amdahl‟s Law
Sequential fraction determines max speedup
Threads?
Shared (mutable) state + locks
Require synchronization
Diminishing returns**
Which primitives to use?
Difficult to predict & maintain
Deadlock
Livelock
Thread starvation
Race condition
*Using threads directly is meant here
**Performance improvement degrades with more threads than cores.
“Life is too short for
Blocking code”*
*Mario Fusco just the other day on twitter
Why Async? Less latency.
Service
Service A
Service B
Service C
4 sec
6 sec
3 sec
Sync takes 13 seconds
Async takes max 6 seconds
Asynchronous „first completed response‟ is easy to do
1. The world is concurrent
2. Things in the world don't share data
3. Things communicate with messages
4. Things fail
Joe Armstrong (creator of Erlang)
We need better tools to build..
Reactive*
Applications
* The latest need-to-know buzz word!
event driven
scalable
asynchronous
resilient
Scale Up and Out
Concurrent
Distributed
Many Nodes
Many ThreadsAkkaA uniform model for both up
and out, embraces
concurrency and failure
Maximize the use of cores
_and_ nodes.
Concurrent(moreCores)
Distributed (more Nodes)
Actors
Futures
Agents
Scale Up
Processes (even less**)
Actors (2.7 million / 1GB)
Threads (4096 / 1GB)
Actors are small*
* Disclaimer: text is not shown to scale, actors are way smaller..
** Especially JVM processes
Reactive Asynchronous Building Blocks
1. CREATE
2. SEND
3. BECOME
4. SUPERVISE*
Actor
Actor
Instance
ActorRef
Mailbox
ActorRef
Actor
Instance
ActorRef
Mailbox
Points to Actor
Delivers messages to Mailbox
Mailbox
Actor
Instance
ActorRef
Mailbox
Processes Messages asynchronously*
Invokes Actor Instance with message
*The Mailbox runs on a Dispatcher that abstracts threading
Actor Instance
Actor
Instance
ActorRef
Mailbox
Receives messages one at a time
Your code runs here.
Actor Instance
Crashed Actor
Instance
Mailbox
An Actor Instance crashes instead of handling
Exceptions. A Supervisor decides it‟s fate.
ActorRef
Restart / Resume / Stop / Escalate
New Actor
Instance
ActorRef
Actor
Instance
Mailbox
Immutable. Only the ActorRef is accessible
From the outside.
ActorRef
ActorRef
Actor
Instance
Mailbox
The ActorRef is used
for both local and remote actors.
ActorRef
ActorRef
Actor
Instance
Mailbox
The ActorRef always points 1 on 1 to the
„same‟ Actor instance. (Alive or Restarted)
ActorRef
Actor
Instance
ActorRef
Dead Actor
Instance
Mailbox
The ActorRef points to deadletters ActorRef
when the actor is dead (terminated).
ActorRef
deadletters
msg
msg
Immutable messages
msg
Location
Transparency
msg Serialized messages
Actor System
Actor System
Actor System
Actor systems
Event
Immutable messages
msg
msg
app@node2
app@node1
app@node3
“app” clustered
actor system
On three nodes
Clustered actor system
msg
msg
“GoTicks.com”
Build a REST API
PUT /events
{
“event” : “RHCP”,
“nrOfTickets”: 300
}
GET /ticket/RHCP
Response:
{
“event”: “RHCP”,
“nr”: 1
}
GET /events
Response:
[
{ “event”: “RHCP”, “nrOfTickets”: 299 }
]
RestApi
Ticket
Seller
Ticket
Seller
BoxOffice
GoTicks.com
Spray
&
Akka
“goticks” ActorSystem
REST Spray-can
GoTicks.com
REST Interface
Handles HTTP calls
Translates to and from
JSON
RestApi
REST Spray-can
GoTicks.com
BoxOffice
REST Spray-can
BoxOffice
Creates Events
Creates TicketSeller
One for every Event
Partition / shard per event
Many sharding strategies possible
GoTicks.com
Ticket
Seller
Ticket
Seller
REST Spray-can
TicketSeller
Contains list of Tickets
Sells Tickets for a Event
until SoldOut
RestApi
Ticket
Seller
Ticket
Seller
BoxOffice
Clustered GoTicks.com
Ticket
Seller
Ticket
Seller
BoxOffice
Consistent
Hashing
Consistent
Hashing
Code
1. CREATE
Inside our Main class…
val system = new ActorSystem(“goticks”)
Create
The system
ActorSystem(“goticks”)
Inside Main…
val system = new ActorSystem(“goticks”)
val api = system.actorOf(
Props[RestInterface],
“httpInterface”)
…
CREATE
RestInterface
ActorSystem(“goticks”)
Top Level Actor
ActorSystem(“goticks”)
REST Interface
Inside Main…
val system = new ActorSystem(“goticks”)
val api = system.actorOf(
Props[RestInterface],
“httpInterface”)
…
CREATE
RestInterface
ActorSystem(“goticks”)
Factory/Creator/ Immutable Configuration object
ActorSystem(“goticks”)
REST Interface
Inside Main…
val system = new ActorSystem(“goticks”)
val api = system.actorOf(
Props[RestInterface],
“httpInterface”)
…
CREATE
RestInterface
ActorSystem(“goticks”)
ActorRef to the Actor
ActorSystem(“goticks”)
REST Interface
ActorSystem(“goticks”)ActorSystem(“goticks”)
Inside RestInterface..
val master = context.actorOf(
Props[BoxOffice],”boxOffice”
)
1. CREATE
BoxOffice
REST Interface
BoxOffice
Child of
REST Interface Actor
ActorSystem(“goticks”)ActorSystem(“goticks”)
Inside RestInterface..
val master = context.actorOf(
Props[BoxOffice],”boxOffice”
)
1. CREATE
BoxOffice
REST Interface
BoxOffice
An Actor has a name, part of an ActorPath
Inside BoxOffice…
val child = context.actorOf(
Props[TicketSeller],
eventName
)
1. CREATE
TicketSeller
ActorSystem(“goticks”)ActorSystem(“goticks”)
REST Interface
BoxOffice
TicketSeller
Child of
BoxOffice Actor
Inside BoxOffice…
val child = context.actorOf(
Props[TicketSeller],
eventName
)
1. CREATE
TicketSeller
ActorSystem(“goticks”)ActorSystem(“goticks”)
REST Interface
BoxOffice
TicketSeller
Ticket sellers are named by event
2. SEND/RECEIVE
Receiving messages
class BoxOffice extends Actor {
def receive = {
case TicketRequest(name) =>
…
case GetEvents =>
…
case event: Event =>
…
}
}
Pattern Matching
On Messages
Receiving messages
class TicketSeller extends Actor {
def receive = soldOut
def soldOut:Receive = {
case Tickets(newTickets) =>
.. //store new tickets
become(selling)
}
def selling:Receive = {
case BuyTicket(name) =>
…
}
}
Partial Function
3. BECOME:
You can change th
behavior at
every msg
Create Event
ActorSystem(“goticks”)ActorSystem(“goticks”)
REST Interface
BoxOffice
Event(“RHCP”, 250)
{ event: “RHCP” nrOfTickets: 250}
Inside RestInterface… (receives JSON, unmarshall to event)
boxOffice ! event
Create Event
ActorSystem(“goticks”)ActorSystem(“goticks”)
REST Interface
BoxOffice
Event(“RHCP”, 250)
{ event: “RHCP” nrOfTickets: 250}
Inside RestInterface… (receives JSON, unmarshall to event)
boxOffice ! event
Bang Operator
„Tell‟
„One-way‟
ActorSystem(“goticks”)ActorSystem(“goticks”)
REST Interface
BoxOffice
Event(“RHCP”, 250)
{ event: “RHCP” nrOfTickets: 250}
Inside RestInterface…
boxOffice ! event
Receiver can respond
to „sender‟
Send Event
To BoxOffice
ActorSystem(“goticks”)ActorSystem(“goticks”)
REST Interface
BoxOffice
EventCreated
Inside BoxOffice…
sender ! EventCreated
Respond with
EventCreated,
results in OK
HTTP OK
ActorSystem(“goticks”)ActorSystem(“goticks”)
REST Interface
BoxOffice
{ event: “RHCP” nrOfTickets: 250}
BuyTicket
TicketSeller
Inside BoxOffice…
ticketSeller forward BuyTicket
Get a Ticket
Forward keeps sender
(RestInterface)
TicketRequest(“RHCP”)
ActorSystem(“goticks”)ActorSystem(“goticks”)
REST Interface
BoxOffice
{ event: “RHCP”, nr :1}
TicketSeller
Inside TicketSeller…
sender ! ticket
Respond to
original senderBuyTicketTicket(“RHCP”, 1)
CODE
Questions?
@RayRoestenburg
rroestenburg@xebia.com
www.xebia.com
github.com/RayRoestenburg/xebicon
Backup slides
“Async sending subscription
data”
Send
Thread X
Consumer
Consumer
Consumer
Thread 1
Thread 2
Thread 1
Service A
Send
Thread X
Consumer
Consumer
Consumer
Thread 1
Thread 2
Thread 1
Service A
Thread 2 fails
Send
Thread X
Consumer
Consumer
Consumer
Thread 1
Thread 2
Thread 1
Service A
Thread 2 fails
Handle every possible error
inside Thread 2, never fail?
Not completely under your control.
Send
Thread X
Consumer
Consumer
Consumer
Thread 1
Thread 2
Thread 1
Service A
Thread 2 fails
Restart / Stop?
Monitor?
Handle errors
across all subscriptions?
4. Supervise*
Untangle behavior and errors
„Just Reboot‟
Let It Crash ™
Error Kernel
4. Supervise*
Strategies
One for One
(Poison Pill /Seppuku)
All for One
4. Supervise*
val supervisorStrategy =
OneForOneStrategy(maxNrOfRetries = 5,
withinTimeRange = 1 minute) {
case _: Exception => Restart
}
4. Supervise*
val supervisorStrategy =
OneForOneStrategy(maxNrOfRetries = 5,
withinTimeRange = 1 minute) {
case _: Exception => Restart
}
Restart,
Resume,
Escalate,
Stop,

More Related Content

What's hot

Decorators in Python
Decorators in PythonDecorators in Python
Decorators in Python
Ben James
 
GR8Conf 2011: GPars
GR8Conf 2011: GParsGR8Conf 2011: GPars
GR8Conf 2011: GPars
GR8Conf
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Mario Fusco
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
Adieu
 

What's hot (20)

Google guava
Google guavaGoogle guava
Google guava
 
Decorators in Python
Decorators in PythonDecorators in Python
Decorators in Python
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard Library
 
2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
 
Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.
Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.
Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.
 
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
 
An Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End DevelopersAn Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End Developers
 
Google Guava for cleaner code
Google Guava for cleaner codeGoogle Guava for cleaner code
Google Guava for cleaner code
 
GR8Conf 2011: GPars
GR8Conf 2011: GParsGR8Conf 2011: GPars
GR8Conf 2011: GPars
 
Web Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for PerformanceWeb Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for Performance
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
 
Python decorators
Python decoratorsPython decorators
Python decorators
 
Zope component architechture
Zope component architechtureZope component architechture
Zope component architechture
 
Google guava - almost everything you need to know
Google guava - almost everything you need to knowGoogle guava - almost everything you need to know
Google guava - almost everything you need to know
 
Swift internals
Swift internalsSwift internals
Swift internals
 
Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)
 
Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
 

Similar to Akka in-action

Exception handling poirting in gcc
Exception handling poirting in gccException handling poirting in gcc
Exception handling poirting in gcc
Shiva Chen
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
Vaclav Pech
 

Similar to Akka in-action (20)

Buiilding reactive distributed systems with Akka
Buiilding reactive distributed systems with AkkaBuiilding reactive distributed systems with Akka
Buiilding reactive distributed systems with Akka
 
Akka Actors: an Introduction
Akka Actors: an IntroductionAkka Actors: an Introduction
Akka Actors: an Introduction
 
First glance at Akka 2.0
First glance at Akka 2.0First glance at Akka 2.0
First glance at Akka 2.0
 
Scalaz 8 vs Akka Actors
Scalaz 8 vs Akka ActorsScalaz 8 vs Akka Actors
Scalaz 8 vs Akka Actors
 
Akka (BeJUG)
Akka (BeJUG)Akka (BeJUG)
Akka (BeJUG)
 
Clojure concurrency
Clojure concurrencyClojure concurrency
Clojure concurrency
 
Exception handling poirting in gcc
Exception handling poirting in gccException handling poirting in gcc
Exception handling poirting in gcc
 
Building Massively Scalable application with Akka 2.0
Building Massively Scalable application with Akka 2.0Building Massively Scalable application with Akka 2.0
Building Massively Scalable application with Akka 2.0
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
 
Let'swift "Concurrency in swift"
Let'swift "Concurrency in swift"Let'swift "Concurrency in swift"
Let'swift "Concurrency in swift"
 
A gentle introduction into AKKA and the actor model
A gentle introduction into AKKA and the actor modelA gentle introduction into AKKA and the actor model
A gentle introduction into AKKA and the actor model
 
Hadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm ArchitectureHadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm Architecture
 
Concurrent programming with Celluloid (MWRC 2012)
Concurrent programming with Celluloid (MWRC 2012)Concurrent programming with Celluloid (MWRC 2012)
Concurrent programming with Celluloid (MWRC 2012)
 
Akka and futures
Akka and futuresAkka and futures
Akka and futures
 
Discovering the Service Fabric's actor model
Discovering the Service Fabric's actor modelDiscovering the Service Fabric's actor model
Discovering the Service Fabric's actor model
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and Akka
 
Current State of Coroutines
Current State of CoroutinesCurrent State of Coroutines
Current State of Coroutines
 
The dark side of Akka and the remedy
The dark side of Akka and the remedyThe dark side of Akka and the remedy
The dark side of Akka and the remedy
 
Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka features
 
Testing akka-actors
Testing akka-actorsTesting akka-actors
Testing akka-actors
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

Akka in-action

Editor's Notes

  1. TODOMake specific to Rabo -> Scala Java comparison.Show basic powerful features of Scala anyone would love. (REPL, case classes, pattern matching, collectionsVery simple example of Futures. Very simple example of Actor. Very simple example of Agent?
  2. The free lunch is over. (Actually it has been over for a while now!)This graph is from an article by Herb Sutter of C++ fame.While the number of transistors per chip still increases, the clock speed has leveled out over the last coupld of years.Chip manufacturers focus on multi core abilities instead of higher clock speeds.So new chips will not immediately increase the speed of sequential programs.This means that concurrent programs are necessary to make full use of multi-core CPU’s
  3. Can’t I just get these really smart compiler and runtime guys to do parallelization behind the scenes?Gimme that shiny box!Released in 2018? I kid.
  4. Some part of your application is going to be sequential, which limits the improvement that can be achieved by parallel execution.Algorithms that require very low sequential execution can benefit the most from parallel execution.Example: Map Reduce style (batch) processing
  5. ThreadsAn standalone execution path within a process - Has its own timeline- Call Stack- Shares Address space (Heap) with other Threads within the same process Performance improvement degrades with more threads than cores.Knowing up front which locks need to be locked Breaks encapsulationAll locks need to be taken before modification - in the correct orderAll locks must be unlocked Thread are expensive and their lifecycle management is error prone Traditional problem: Dining Philosophers
  6. ThreadsAn standalone execution path within a process - Has its own timeline- Call Stack- Shares Address space (Heap) with other Threads within the same process Performance improvement degrades with more threads than cores.Knowing up front which locks need to be locked Breaks encapsulationAll locks need to be taken before modification - in the correct orderAll locks must be unlocked Thread are expensive and their lifecycle management is error prone Traditional problem: Dining Philosophers
  7. Threads do not compose, or interact using exceptions, they all have their own stacktrace.Communicating between threadgroups is not possible using traditional exceptions. Roll your own.You will need to use concurrent data structures to communicate with the threads, like queues for instance.
  8. Can’t I just get these really smart compiler and runtime guys to do parallelization behind the scenes?Gimme that shiny box!
  9. Event driven – The world is event drivenScalable – use both more cores and nodesAsynchronous – Waiting is a bad way to use processing cycle. Life is too short to block.Resilient – More robust and easier failure handling of concurrent and distributed systems
  10. Single Node, Single ThreadLMAX Disruptor, runs on one thread, achieves 100.000 tpsNode.Js (Javascript is singlethreaded) But what if that one thread blocks, or fails..Scale up by just running more processes, but how do you coordinate concurrency?Processes are heavier than threads, and maybe there is even something lighter…Many Nodes, Single ThreadedCombine the single thread processes with some kind of network communication, Like 0MQ, RabbitMQ, ..MQ. Distributed Coordination can be done with a distributed database, or something like Apache Zookeeper.Which are all technologies that live on a diffferent planet, which you will have to master. If need be OK, but this is getting complex.Single Node, Many ThreadsWhat if we just use java.util.concurrent? Concurrent data structures, directly using Threads, locks, semaphores? How hard can deadlocks, livelocks, thread starvation, race conditions really be to debug?Many Nodes, Many Threads.A combination of even more technologies?
  11. Today we are only going to talk about actors, unless we have time left.
  12. One at a time. Sequential in the small. Concurrent and Async in large numbers.
  13. At Restart the new actor instance gets to handle next messages.There is an option to handle the message that was being processed during the crash.
  14. Today we are only going to talk about actors, unless we have time left.
  15. Today we are only going to talk about actors, unless we have time left.
  16. Today we are only going to talk about actors, unless we have time left.
  17. A Service sends subscription based messages using traditional Network I/O. Async because one consumer must not block others. Below Subscription X type messages are sent to consumers.Threads do not compose, or interact using exceptions, they all have their own stacktrace.Communicating between threadgroups is not possible using traditional exceptions. Roll your own.You will need to use concurrent data structures to communicate with the threads, like queues for instance.You can’t guarantee that a thread will be able to handle all possible errors itself, without knowing information about the bigger system or larger context.(network usage policy, behavior of consumer across subsystems could mean the difference between cutting the consumer off, or restarting transmissions To a different endpoint)
  18. A Service sends subscription based messages using traditional Network I/O. Async because one consumer must not block others. Below Subscription X type messages are sent to consumers.Threads do not compose, or interact using exceptions, they all have their own stacktrace.Communicating between threadgroups is not possible using traditional exceptions. Roll your own.You will need to use concurrent data structures to communicate with the threads, like queues for instance.You can’t guarantee that a thread will be able to handle all possible errors itself, without knowing information about the bigger system or larger context.(network usage policy, behavior of consumer across subsystems could mean the difference between cutting the consumer off, or restarting transmissions To a different endpoint)
  19. A Service sends subscription based messages using traditional Network I/O. Async because one consumer must not block others. Below Subscription X type messages are sent to consumers.Threads do not compose, or interact using exceptions, they all have their own stacktrace.Communicating between threadgroups is not possible using traditional exceptions. Roll your own.You will need to use concurrent data structures to communicate with the threads, like queues for instance.You can’t guarantee that a thread will be able to handle all possible errors itself, without knowing information about the bigger system or larger context.(network usage policy, behavior of consumer across subsystems could mean the difference between cutting the consumer off, or restarting transmissions To a different endpoint)
  20. A Service sends subscription based messages using traditional Network I/O. Async because one consumer must not block others. Below Subscription X type messages are sent to consumers.Threads do not compose, or interact using exceptions, they all have their own stacktrace.Communicating between threadgroups is not possible using traditional exceptions. Roll your own.You will need to use concurrent data structures to communicate with the threads, like queues for instance.You can’t guarantee that a thread will be able to handle all possible errors itself, without knowing information about the bigger system or larger context.(network usage policy, behavior of consumer across subsystems could mean the difference between cutting the consumer off, or restarting transmissions To a different endpoint)