building scalable systems: what you can learn from erlang - dotscale 2016
TRANSCRIPT
Building Scalable SystemsWhat you can Learn from Erlang
First Stop: 1973
Actor Model
• Carl Hewitt
Actor Model Principle
• An actor can:
• Send Messages to other Actors
• Create other Actors
• Process Next Message
Share Nothing
“An Island of Sanity in a Sea of Concurrency"
Actor
State
Actor
State
Actor
State
Actor
State
Actor
State
Naturally scalable
Next stop: 1986
Birth of ErlangJoe Armstrong, Robert Virding, Mike Williams, Bjarne Däcker
Share Nothing with Lightweight Processes
Let it Crash
Handle Failures with Process Links and Supervisors
Next stop: 1998
Erlang VM released as Open Source
Erlang strength lies in the VM
Vertical scaling: Multicore and Scheduler
Horizontal scaling: ClusteringTransparent, well almost
Erlang strengths match Server applications properties
• Server apps are most of the time IO bound
• Server apps are often memory bound.
NetworkStack
Accepted connections
Requests processingServer threads
Pool
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
…
ClientRequests
X
X
X
Connections Pooli.e. Apache
NetworkStack
Accepted connections
Requests processingLightweight processes
ClientRequests
…
One Connection per Thread
Erlang webservers i.e. Yaws, Cowboy, etc.
Design comparison
• Number of requests handled in peak time: 1Ks to 10ks
• Throughput: reduce quickly when max concurrency reached
• More complex code
• Number of concurrent requests handle in peak time: 100Ks to 1Ms
• Throughput: Higher for large number of concurrent requests.
• Simple code, no pool to manage
Design with worker thread pools Design with Erlang processes
Back to 2016
Erlang is still the Reference for Scalable Systems
Makes it easier to build Advanced Concurrency Patterns
New languages using the Erlang VM: Elixir, LFE, etc
Inspiration for new languages / Frameworks:
Go, Scala, Akka, Clojure, …
Next Stop ?