11. • Behavior
• State
• Parallel
• Asynchronous Messages Mailboxes
• No Shared State
The Actor
Model
Carl Hewitt
1973
12. • Data + Code + Process
• Self-Contained Machines
• Stronger Encapsulation
• Less Inheritance
• Type Inference
• Hot Code Upgrades
Actor
structure
Behavior way
• Inheritance of Behavior only.
• Usually only one level deep.
• Usually one of the standard OTP behaviors:
• Generic Server
• Event
• State Machine
• Supervisor.
13. Actor vs. OO workflow
Synchronous Calls
Asynchronous Messages
14.
15. Actor Model: Benefits
• More true to the real world
• Better suited for parallel hardware
• Better suited for distributed architectures
• Scaling garbage collection (gc/actor)
• Less Magic
17. Erlang benefits
Functional nature
Pattern matching on steroids
Concurrency
Fault Tolerance
Let it crash
Distributed Computation
Debugging and profiling
Hot upgrades
21. Erlang benefits
Functional nature
Pattern matching on steroids
Concurrency
Fault Tolerance
Let it crash
Distributed Computation
Debugging and profiling
Hot upgrades
28. Remote shells
(salad@ferdmbp)1>
User switch command
--> h
c [nn] - connect to job
i [nn] - interrupt job
k [nn] - kill job
j - list all jobs
s [shell] - start local shell
r [node [shell]] - start remote shell
q - quit erlang
? | h - this message
--> r mustard@ferdmbp
--> j
1 {shell,start,[init]}
2* {mustard@ferdmbp,shell,start,[]}
--> c
Eshell V5.8.4 (abort with ^G)
(mustard@ferdmbp)1> node().
mustard@ferdmbp
29. Debugger and profilers
Tool Results
Size of
Result
Effects on Program
Execution Time
Records
Number of
Calls
Records
Execution
Time
Records
Called by
Records
Garbage
Collection
fprof
Per process to
screen/file
Large Significant slowdown Yes
Total and
own
Yes Yes
eprof
Per process/function
to screen/file
Medium Small slowdown Yes Only total No No
cover
Per module to
screen/file
Small Moderate slowdown Yes, per line No No No
cprof Per module to caller Small Small slowdown Yes No No No
dbg Text based tracer Large Small slowdonw No No Yes No
Communit
y
• recon
• redbug
• lager
• xprof
More
introspection
• etop
• pman
• os_mon
• debugger
34. Measurements
Activity
• millions active users
• fast processes for handling
Stability
• developers and operations sleeps fine
• no emergencies for a couple of years
Performance
• compatible to C,
• VM memory management
• lightweight concurrency
• scalability from a box
Issues
• concurrent bottlenecks
• Net splits
• Networks security
• Hot upgrades
35. Top 5 lines of code
46292
11703
7328
2784
1479