Академический Документы
Профессиональный Документы
Культура Документы
Erlang/OTP
@jvalduvieco
@jordillonch
Problem domain
Lots of users
Lots of users
24x7x365
24x7x365
Hardware or software
breaks
Hardware or software
breaks
Unscalable
Unmaintainable
code
Unscalable
Unmaintainable
code
Maintenance/Debug
in
production system
Maintenance/Debug
in
production system
Simplicity...
Minimize defensive
programming
Typeless variables
Develop by contract
t-shirt function
size
If
a
function
does
not
fit
on
your
t-shirt
it
is
too
long!
Single responsibility
principle
No shared state
between entities
High Concurrency
High
High Concurrency
concurrency
Light threads
Light threads
Light threads
Lt
Lt
Lt
Message passing
Lt
Lt
Lt
Message passing
A shared nothing architecture that
communicates through message passing
Lt
Lt
Lt
Message passing
A shared nothing architecture that
communicates through message passing
Lt
Lt
Lt
Process Mailbox
Lt
Lt
Lt
Process Mailbox
Every process has a mailbox with incoming
messages, process take on convenience
Lt
Lt
Lt
No shared state
Lt
S
Lt
S
Lt
S
No shared state
Every process its own internal state stored in
a variable avoiding lock contention
Lt
S
Lt
S
Lt
S
Soft realtime
Soft realtime
You have no strict guarantees on
latency but language is designed
to have low latency
High availability
High
availability
High availability
Supervised processes
Pa
Pb
Supervised processes
processes can be monitored by other
processes, handling its termination
Pa
Pb
Fail early
Pa
Pb
S
Fail early
Pb
S
Fail early
Pb2
S
Pb
Pa v1
S
Pc
Pb
Pa v1
S
Pc
Pb
Pa v2
v1
S
Pc
Distribution
Node
Node
Distribution
Processes run on nodes and can be located
wherever they are
Node
Node
Demo 1
Hands on
The shell
Variables
Variables start
Uppercase
1> Foo = 1.
1
2> Foo = 2.
** exception error: no match of right hand
side value 2
Foo
is
bounded
to
1
1> Foo = 1.
1
2> Foo = 2.
** exception error: no match of right hand
side value 2
Foo
is
bounded
to
1
1> Foo = 1.
1
Foo
=
=
2