Presentation is loading. Please wait.

Presentation is loading. Please wait.

Making Fault-Tolerance a Reality `

Similar presentations


Presentation on theme: "Making Fault-Tolerance a Reality `"— Presentation transcript:

1 Making Fault-Tolerance a Reality `
Erlang and the OTP Making Fault-Tolerance a Reality `

2 Before We Begin > dialyzer --build_plt --apps stdlib kernel erts
Slides and code are at git://github.com/bernardd/OTPworkshop.git

3 Who on Earth are you? ShoreTel Sky http://shoretelsky.com
“Enterprise Grade” Hosted VoIP

4 Let's Write a Chat Server
Processes: Main Server Socket Listener Client Processes

5 The OTP Supervision Trees applications gen_server gen_fsm gen_event
It's what makes Erlang's promise of fault tolerance a reality

6 application Coarse grained building blocks Start and stop individually
Reusable e.g.: Mnesia, SNMP, Crypto

7 gen_server Basic long lived “server” process
Responds to synchronous and asynchronous requests

8 gen_fsm Framework for finite state machine process
In reality it's pretty limited and not widely used

9 gen_event Subscribe-notify system
The gen_event module is the subscriber

10 supervisor Watches processes Restarts crashed ones (if needed)
Restart strategies: one_for_one one_for_all rest_for_one simple_one_for_one

11 Supervision Trees Our OTP-ised chat server:
Main supervisor (one-for-one) Client supervisor (simple-one -for-one) Chat server Connection listener Clients …....

12 Supervisor Specification
{ok, {{ one_for_one, % Strategy 4, % Max retries % Max time }, [ % Children { client_sup, % ID {Module, Function, [ArgList]}, % Start spec MFA permanent, % Restart type 1000, % Shutdown timeout worker, % Child type [Module] % Child modules ... % More children here ]}}.

13 Let's Crash Some Processes!
observer:start()

14 gen_event gen_event:start_link({local, EvtMgr})
gen_event:add_handler(EvtMgr, HandlerModule, Args)

15 Hot Code Loading It's so cool

16 Dialyzer

17 Questions?

18 Thanks! The End.


Download ppt "Making Fault-Tolerance a Reality `"

Similar presentations


Ads by Google