ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Actor Oriented Programming, Fault Tolerance and OTP Dhananjay Nene #devcamp pune  April 9 th , 2011
What is the Actor Model ?
¡° 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.¡± ¨C  Wikipedia (Actor Model)
Erlang Process Model
In erlang parlance, each actor is a process
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.
Isolation : Processes are isolated. They do not share any memory between themselves. Garbage collection also works independently per processes
Since processes run concurrently, the inability to share memory between them reduces many of the difficulties associated with conventional multi threaded programming
Messages : Processes interact with each other by sending each other messages asynchronously
For asynchronous messaging to work each process has a mailbox of messages and it processes one message at a time from the mailbox
Introduction : Sleeping Barber Problem
OTP : Open Telecom Platform
OTP plays a somewhat similar role as JEE does for Java
OTP Design Patterns : Application
Server
Supervisor
State Machines
Event Handling
Philosophy : Let it crash
Let it crash actually encouraging higher availability initially seems like an oxymoron
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.
So what features of erlang help fault tolerance?

More Related Content

Actors, Fault tolerance and OTP

  • 1. Actor Oriented Programming, Fault Tolerance and OTP Dhananjay Nene #devcamp pune April 9 th , 2011
  • 2. What is the Actor Model ?
  • 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.¡± ¨C Wikipedia (Actor Model)
  • 5. In erlang parlance, each actor is a process
  • 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. Isolation : Processes are isolated. They do not share any memory between themselves. Garbage collection also works independently per processes
  • 8. Since processes run concurrently, the inability to share memory between them reduces many of the difficulties associated with conventional multi threaded programming
  • 9. Messages : Processes interact with each other by sending each other messages asynchronously
  • 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. Introduction : Sleeping Barber Problem
  • 12. OTP : Open Telecom Platform
  • 13. OTP plays a somewhat similar role as JEE does for Java
  • 14. OTP Design Patterns : Application
  • 19. Philosophy : Let it crash
  • 20. Let it crash actually encouraging higher availability initially seems like an oxymoron
  • 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. So what features of erlang help fault tolerance?
  • 23. Light weight process design allows modeling highly concurrent set of activities
  • 24. Shared Nothing / Process Isolation allows any process to fail without directly negatively impacting any other process
  • 25. Code demonstrated : Erlang : https://github.com/dnene/sleeping-barber/tree/34616b7c692b8b18eac71d34a7b30b65b2d94e20 Scala ¨C akka https://github.com/dnene/sleeping-barber/tree/34616b7c692b8b18eac71d34a7b30b65b2d94e20
  • 26. Ability to link processes, and create supervisor and monitor hierarchy allows graceful resumption of failed services