actors, fault tolerance and otp

Download Actors, Fault tolerance and OTP

If you can't read please download the document

Upload: dhananjay-nene

Post on 16-Apr-2017

4.215 views

Category:

Technology


0 download

TRANSCRIPT

Actor Oriented Programming,Fault Tolerance and OTP

Dhananjay Nene#devcamp pune April 9th, 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.

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?

Light weight process design allows modeling highly concurrent set of activities

Shared Nothing / Process Isolation allows any process to fail without directly negatively impacting any other process

Code demonstrated :

Erlang :

https://github.com/dnene/sleeping-barber/tree/34616b7c692b8b18eac71d34a7b30b65b2d94e20

Scala akka

https://github.com/dnene/sleeping-barber/tree/34616b7c692b8b18eac71d34a7b30b65b2d94e20

Ability to link processes, and create supervisor and monitor hierarchy allows graceful resumption of failed services

Muokkaa otsikon tekstimuotoa napsauttamalla

Muokkaa jsennyksen tekstimuotoa napsauttamallaToinen jsennystasoKolmas jsennystasoNeljs jsennystasoViides jsennystasoKuudes jsennystasoSeitsems jsennystasoKahdeksas jsennystasoYhdekss jsennystaso