Post on 19-Jun-2015
description
ActorsAn introduction to
Johan Andrén johan.andren@mejsla.se | @apnylle
Akka with
Moores law
1971 today19902300
2,6 billions
1 million
Oh, No Problems!
Oh No, Problems!
• Race conditions
• Data corruption
• Deadlocks
• Thread contention
• Livelocks
• Priority Inversion
Concurrency is HARD• To write
• To test
• To debug
• To reason about
We need a better model!
A
B C
D
EF
ACTORSevent drivensystems with
Inbox
Behaviour
State
The only way to interact from
outside
• Single execution flow model
• No shared _mutable_ state
• Lightweight
• Loose coupling
• Easy to test
Actor A Actor B
Actor A Actor B
One way communication
Actor A Actor B
React, don’t wait
Actor AActor B1
Load balancing
Actor B2
router
Actor A Actor F (filter)
Pipe/Filter
Actor B
Actor A Actor B (chef)
ParallellizeActor C1
Actor C2
Actor C2
• No work, no thread used!
• Async - never actively wait
• Loose coupling
A
B C
D
EF
JVM
A
B C
D
EF
JVM 1 JVM 2
• Two actors on one core
• Two actors on separate cores
• Two actors on separate servers
The same same
Error handlingin Actor systems
• Leaking information between tiers
• Impossible to detect simultaneous errors
• The receiver does not know how to handle the errors!
Traditional model
Actor X
(parent)
Actor A
Actor Z
Error handling with Actors
Actor X
(parent)
Actor A
Actor Z
Error handling with Actors
Actor X
Actor A
Actor Z
Error handling with Actors
• Compartmentilization
• What goes back is explicit
• Separating error handling and business logic
• Can detect simultaneous errors
”Supervision”
• STM
• Remoting
• Clustring with no SPoF
• MQs integration
• Eventbus
Wait, there is more!
akka.ioWebsite:
But
• Simple but powerful model
• Lightweight and fast
• Loose coupling
• Resiliency
Recap
Johan Andrén johan.andren@mejsla.se | @apnylle