Akka
Building Distributed Systems for Concurrent, Fault-tolerant and Scalable Java Applications
1
1 Thursday, November 21, 13
Akka Building Distributed Systems for Concurrent, Fault-tolerant - - PowerPoint PPT Presentation
Akka Building Distributed Systems for Concurrent, Fault-tolerant and Scalable Java Applications 1 Thursday, November 21, 13 1 Problems with Multithreaded Programming Shared Mutable Objects Thread 2 Thread 1 Solution: Synchronized Access
1
1 Thursday, November 21, 13
Shared Objects
Thread 2 Thread 1
Solution: Synchronized Access (guarded by locks) 2
2 Thursday, November 21, 13
Shared Objects
Thread 2 Thread 1
Solution: Synchronized Access (guarded by locks) 2 Change in one part of the system may break it in another part.
2 Thursday, November 21, 13
Shared Objects
Thread 2 Thread 1
Solution: Synchronized Access (guarded by locks)
2 Change in one part of the system may break it in another part.
2 Thursday, November 21, 13
3
Shared block 1
Thread 2 Thread 1
Thread 1 has obtained the lock to synchronized block 1 and Thread 2 has obtained the lock to synchronized block 2
Shared block 2
Synchronized
3 Thursday, November 21, 13
4
Managing multiple threads in a single JVM Challenging Scaling the application across multiple JVMs?
4 Thursday, November 21, 13
4
Managing multiple threads in a single JVM Challenging Scaling the application across multiple JVMs? Shared state stored in database and Relying on database to manage the concurrent access
4 Thursday, November 21, 13
5
Open source toolkit and runtime that runs on JVM May use Scala or Java to call libraries and features Written in Scala High level abstraction for concurrency: Actors combined with software transaction memory (SMT) to implement atomic message-passing
5 Thursday, November 21, 13
6
(lightweight processes) Simple and high-level abstraction for concurrency and parallelism Asynchronous, non- blocking, and high- performance event-driven programming Provide Support Implement share nothing architecture and encapsulate state and behavior state change is local
6 Thursday, November 21, 13
7
try { } catch (ExceptionType name) { } catch (ExceptionType name) { } critically important state is guarded by try/catch blocks
7 Thursday, November 21, 13
7
try { } catch (ExceptionType name) { } catch (ExceptionType name) { } critically important state is guarded by try/catch blocks
actor P actor C supervisor of actor C
7 Thursday, November 21, 13
7
try { } catch (ExceptionType name) { } catch (ExceptionType name) { } critically important state is guarded by try/catch blocks
actor P actor C supervisor of actor C
7 Thursday, November 21, 13
8
8 Thursday, November 21, 13
8
ActorSystem ActorRef
MessageDispatcher
Mailbox Actor Message Queue
Creates Dispatch Runs Publishes Message Invokes Retrieves Message
8 Thursday, November 21, 13
9
limited number of threads.
mapping of threads to actors.
MessageDispatcher
Load balancing
9 Thursday, November 21, 13
9
limited number of threads.
mapping of threads to actors.
MessageDispatcher
Load balancing
ActorRef
Horizontal scalability
Local ActorRef Remote ActorRef
9 Thursday, November 21, 13
10
system hierarchy
user hierarchy
root actor: Guardian top-level actors child actors
10 Thursday, November 21, 13
11
11 Thursday, November 21, 13
12
12 Thursday, November 21, 13
13
13 Thursday, November 21, 13
14
14 Thursday, November 21, 13
15
15 Thursday, November 21, 13
15
15 Thursday, November 21, 13
16
16 Thursday, November 21, 13
17
17 Thursday, November 21, 13
18
18 Thursday, November 21, 13
19
19 Thursday, November 21, 13