building scalable systems: what you can learn from erlang - dotscale 2016

29
Building Scalable Systems What you can Learn from Erlang

Upload: mickael-remond

Post on 14-Apr-2017

556 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Building Scalable SystemsWhat you can Learn from Erlang

Page 2: Building Scalable Systems: What you can learn from Erlang - DotScale 2016
Page 3: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

First Stop: 1973

Page 4: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Actor Model

• Carl Hewitt

Page 5: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Actor Model Principle

• An actor can:

• Send Messages to other Actors

• Create other Actors

• Process Next Message

Page 6: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Share Nothing

Page 7: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

“An Island of Sanity in a Sea of Concurrency"

Actor

State

Actor

State

Actor

State

Actor

State

Actor

State

Page 8: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Naturally scalable

Page 9: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Next stop: 1986

Page 10: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Birth of ErlangJoe Armstrong, Robert Virding, Mike Williams, Bjarne Däcker

Page 11: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Share Nothing with Lightweight Processes

Page 12: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Let it Crash

Page 13: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Handle Failures with Process Links and Supervisors

Page 14: Building Scalable Systems: What you can learn from Erlang - DotScale 2016
Page 15: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Next stop: 1998

Page 16: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Erlang VM released as Open Source

Page 17: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Erlang strength lies in the VM

Page 18: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Vertical scaling: Multicore and Scheduler

Page 19: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Horizontal scaling: ClusteringTransparent, well almost

Page 20: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Erlang strengths match Server applications properties

• Server apps are most of the time IO bound

• Server apps are often memory bound.

Page 21: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

NetworkStack

Accepted connections

Requests processingServer threads

Pool

Thread

Thread

Thread

Thread

Thread

Thread

Thread

Thread

Thread

ClientRequests

X

X

X

Connections Pooli.e. Apache

Page 22: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

NetworkStack

Accepted connections

Requests processingLightweight processes

ClientRequests

One Connection per Thread

Erlang webservers i.e. Yaws, Cowboy, etc.

Page 23: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

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

Page 24: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Back to 2016

Page 25: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Erlang is still the Reference for Scalable Systems

Page 26: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Makes it easier to build Advanced Concurrency Patterns

Page 27: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

New languages using the Erlang VM: Elixir, LFE, etc

Page 28: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Inspiration for new languages / Frameworks:

Go, Scala, Akka, Clojure, …

Page 29: Building Scalable Systems: What you can learn from Erlang - DotScale 2016

Next Stop ?