akka
play

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. Akka Building Distributed Systems for Concurrent, Fault-tolerant and Scalable Java Applications 1 Thursday, November 21, 13 1

  2. Problems with Multithreaded Programming Shared Mutable Objects Thread 2 Thread 1 Solution: Synchronized Access Shared Objects (guarded by locks) 2 Thursday, November 21, 13 2

  3. Problems with Multithreaded Programming Shared Mutable Objects Thread 2 Thread 1 Solution: Synchronized Access Shared Objects (guarded by locks) Change in one part of the system may break it in another part. 2 Thursday, November 21, 13 2

  4. Problems with Multithreaded Programming Shared Mutable Objects Thread 2 Thread 1 Solution: Synchronized Access Shared Objects (guarded by locks) Change in one part of the system may break it in another part. 1. Operations may occur serially -> poor performance 2. Locks -- do not compose -> hard to design applications -- do not scale well -> block the execution -- hard to get in right order and error recovery is complicated 2 Thursday, November 21, 13 2

  5. Problems with Multithreaded Programming Deadlocks Thread 1 Thread 2 Synchronized Shared block 1 Shared block 2 Thread 1 has obtained the lock to synchronized block 1 and Thread 2 has obtained the lock to synchronized block 2 3 Thursday, November 21, 13 3

  6. Problems with Multithreaded Programming Scalability Managing multiple threads in a single JVM Challenging Scaling the application across multiple JVMs? 4 Thursday, November 21, 13 4

  7. Problems with Multithreaded Programming Scalability 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 4

  8. Akka: A Solution for Concurrency, Fault-tolerance and Scalability Open source toolkit and runtime that runs on JVM Written in Scala May use Scala or Java to call libraries and features High level abstraction for concurrency: Actors combined with software transaction memory (SMT) to implement atomic message-passing 5 Thursday, November 21, 13 5

  9. Actors in Akka Actors (lightweight processes) Provide Support Asynchronous, non- Simple and high-level blocking, and high- abstraction for concurrency performance event-driven and parallelism programming Implement share nothing architecture and encapsulate state and behavior state change is local 6 Thursday, November 21, 13 6

  10. “Let it Crash” Model for Fault-tolerance standard java application critically important state is guarded by try/catch blocks try { } catch (ExceptionType name) { } catch (ExceptionType name) { } 7 Thursday, November 21, 13 7

  11. “Let it Crash” Model for Fault-tolerance standard java application Akka supervisor of actor C critically important state is guarded by try/catch blocks actor P actor C try { } catch (ExceptionType name) { } catch (ExceptionType name) { } supervisor hierarchy 7 Thursday, November 21, 13 7

  12. “Let it Crash” Model for Fault-tolerance standard java application Akka supervisor of actor C critically important state is guarded by try/catch blocks actor P Notify actor C try { Crash } catch (ExceptionType name) { } catch (ExceptionType name) { } supervisor hierarchy 7 Thursday, November 21, 13 7

  13. The Actor Model 8 Thursday, November 21, 13 8

  14. The Actor Model Creates ActorSystem ActorRef Dispatch Publishes Message MessageDispatcher Runs Message Queue Mailbox Actor Retrieves Invokes Message 8 Thursday, November 21, 13 8

  15. Some More Advantages -- can maintain a thread pool having MessageDispatcher limited number of threads. -- can be configured with one-to-one Load balancing mapping of threads to actors. 9 Thursday, November 21, 13 9

  16. Some More Advantages -- can maintain a thread pool having MessageDispatcher limited number of threads. -- can be configured with one-to-one Load balancing mapping of threads to actors. Local ActorRef ActorRef Remote ActorRef Horizontal scalability 9 Thursday, November 21, 13 9

  17. Actor Hierarchies ActorSystem.Actors system hierarchy user hierarchy root actor: Guardian top-level actors child actors Actor hierarchy 10 Thursday, November 21, 13 10

  18. Example: Computing Prime Numbers Create a master actor Create a round-robin router to distribute work across multiple worker actors Communicate between worker actors and the master actor Communicate between the master actor and a listner 11 Thursday, November 21, 13 11

  19. 12 Thursday, November 21, 13 12

  20. 13 Thursday, November 21, 13 13

  21. 14 Thursday, November 21, 13 14

  22. 15 Thursday, November 21, 13 15

  23. 15 Thursday, November 21, 13 15

  24. 16 Thursday, November 21, 13 16

  25. 17 Thursday, November 21, 13 17

  26. Exercise Find GCD for a given set of numbers by creating 2 worker_actors and dividing the load among them equally. Report the time for computation taken by each worker_actor. Use Akka release 2.2.1 18 Thursday, November 21, 13 18

  27. 19 Thursday, November 21, 13 19

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend