Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Actors, Fault tolerance and OTP


Published on

My talk at Devcamp Pune 2011. Has associated code referred to in the last slide

Published in: Technology
  • Be the first to comment

Actors, Fault tolerance and OTP

  1. 1. Actor Oriented Programming, Fault Tolerance and OTP Dhananjay Nene #devcamp pune April 9 th , 2011
  2. 2. What is the Actor Model ?
  3. 3. “ In computer science, the Actor model is a mathematical model of concurrent computation that treats "actors" as the universal primitives of concurrent digital computation : in response to a message that it receives , an actor can make local decisions, create more actors, send more messages, and determine how to respond to the next message received.” – Wikipedia (Actor Model)
  4. 4. Erlang Process Model
  5. 5. In erlang parlance, each actor is a process
  6. 6. However thats not the same as an operating system process. A single OS process hosts many erlang processes. An erlang process is far lighter than even a thread.
  7. 7. Isolation : Processes are isolated. They do not share any memory between themselves. Garbage collection also works independently per processes
  8. 8. Since processes run concurrently, the inability to share memory between them reduces many of the difficulties associated with conventional multi threaded programming
  9. 9. Messages : Processes interact with each other by sending each other messages asynchronously
  10. 10. For asynchronous messaging to work each process has a mailbox of messages and it processes one message at a time from the mailbox
  11. 11. Introduction : Sleeping Barber Problem
  12. 12. OTP : Open Telecom Platform
  13. 13. OTP plays a somewhat similar role as JEE does for Java
  14. 14. OTP Design Patterns : <ul><li>Application
  15. 15. Server
  16. 16. Supervisor
  17. 17. State Machines
  18. 18. Event Handling </li></ul>
  19. 19. Philosophy : Let it crash
  20. 20. Let it crash actually encouraging higher availability initially seems like an oxymoron
  21. 21. But what it really emphasises is the ensured continued availability of the overall system rather than the robustness of every small piece that forms it.
  22. 22. So what features of erlang help fault tolerance?
  23. 23. Light weight process design allows modeling highly concurrent set of activities
  24. 24. Shared Nothing / Process Isolation allows any process to fail without directly negatively impacting any other process
  25. 25. Code demonstrated : Erlang : Scala – akka
  26. 26. Ability to link processes, and create supervisor and monitor hierarchy allows graceful resumption of failed services