erlang - because s**t happens

87
V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved Erlang because s**t happens Erlang : Because S**t happens Mahesh Paolini-Subramanya (@dieswaytoofast) V.P. R&D, Ubiquiti Networks

Upload: mahesh-paolini-subramanya

Post on 03-Jul-2015

3.377 views

Category:

Technology


0 download

DESCRIPTION

Erlang begins and ends with Fault Tolerance. Fault Tolerance is - formally! - baked into the very genes of Erlang/OTP - something that ends up being amazingly useful when you are building any kind of system.  Remember, your clients (and co-workers!) will find new ways to break things, ways that you could never have imagined in your wildest dreams. This, this is the reason to use Erlang. Once you get it, it completely changes the way you approach development, and you will find yourself writing "erlang" in whatever language you happen to be using  (Mind you, writing tail-recursive code in java is a recipe for disaster, but thats another story…) In this talk, I'll get into this buddha-nature of Erlang/OTP, pointing out how the various features of the language tie together into one seamless Fault Tolerant whole.  It'll probably run 45 minutes or so, not counting questions…

TRANSCRIPT

Page 1: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Erlang :

Because S**t

happensMahesh Paolini-Subramanya (@dieswaytoofast)V.P. R&D, Ubiquiti Networks

Page 2: Erlang - Because S**t Happens
Page 3: Erlang - Because S**t Happens

AGILITY

Page 4: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Horror! The Horror!

Page 5: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Dude! WTF?!?!

Page 6: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Surely you Tested?

Page 7: Erlang - Because S**t Happens
Page 8: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Fault ToleranceFrom

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 9: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 10: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 11: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 12: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 13: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 14: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 15: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

erlang…

Page 16: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 17: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 18: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Processes!

Parallel

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 19: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Processes!

Parallel

Independent

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 20: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Processes!

Parallel

Independent

Asynchronous message passing

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 21: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Processes!

Parallel

Independent

Asynchronous message passing

No shared state

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 22: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Processes!

Parallel

Independent

Asynchronous message passing

No shared state

Immutable data structures

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 23: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 24: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Page 25: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

** exception error: no match of

right hand side value

{error,unhappy}

Page 26: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Page 27: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 28: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

** exception error: no match of

right hand side value

{error,unhappy}

Page 29: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Page 30: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 31: Erlang - Because S**t Happens
Page 32: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Processes!

Let it crash

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 33: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Processes!

Let it crash

(all the co-operating ones , that is)

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 34: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Processes!

Let it crash

(all the co-operating ones , that is)

Supervisors can restart them

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 35: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Processes!

Let it crash

(all the co-operating ones , that is)

Supervisors can restart them

(When necessary!)

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 36: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 37: Erlang - Because S**t Happens
Page 38: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Page 39: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 40: Erlang - Because S**t Happens
Page 41: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

mnesia ‘n stuff

Page 42: Erlang - Because S**t Happens
Page 43: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Fault Tolerant System

Page 44: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 45: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 46: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

LOOSE C

OUPLING

Page 47: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Loose Coupling

Page 48: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Loose Coupling

Breeds Trust

Page 49: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Page 50: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Loose Coupling

Breeds Trust

Devotes Brainpower appropriately

Page 51: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Page 52: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Loose Coupling

Breeds Trust

Devotes Brainpower appropriately

Minimizes bugs

Page 53: Erlang - Because S**t Happens
Page 54: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Page 55: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Fault Tolerance

60 - 90% of all SW projects fail

10 – 25% of all SW projects get abandoned

Page 56: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Page 57: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six - Systems

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

Page 58: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six - Systems

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

MONIT

ORING

Page 59: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Monitoring?

Page 60: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Monitoring?Dashboards

Page 61: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Monitoring?Dashboards

Out of band systems

Page 62: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Monitoring?Dashboards

Out of band systems

Polyglot safety

Page 63: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six - Systems

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

Page 64: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six - Systems

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable StoragePOLYGLO

T

PERSISTENCE

Page 65: Erlang - Because S**t Happens
Page 66: Erlang - Because S**t Happens
Page 67: Erlang - Because S**t Happens
Page 68: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

(The day it all changed)

Friday, June 29th 2012

Page 69: Erlang - Because S**t Happens

• People

• Vendors

• Fraud

Fault Tolerance

Page 70: Erlang - Because S**t Happens

The Business

Beware the Black Swan

Page 71: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Fault Tolerant

Organization

Page 72: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 73: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Concurrency

The Big Six - Organizations

Page 74: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Page 75: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 76: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Page 77: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 78: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Concurrency

Error encapsulation

Fault detection

The Big Six - Organizations

Page 79: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six

Concurrency

Fault detection

Fault Identification

Error Encapsulation

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 80: Erlang - Because S**t Happens
Page 81: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six - Organizations

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 82: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Concurrency

Error encapsulation

Fault detection

Fault identification

Code upgrade

The Big Six - Organizations

Page 83: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

The Big Six - Organizations

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

From

http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 84: Erlang - Because S**t Happens

• Concurrency

• Error encapsulation

• Fault detection

• Fault identification

• Code upgrade

• Stable Storage

The Big Six - Organizations

Page 85: Erlang - Because S**t Happens

Is It Safe?

Page 86: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

Concurrency

Fault detection

Fault Identification

Error Encapsulation

Code upgrade

Stable Storage

EVERYWHERE!!!

Page 87: Erlang - Because S**t Happens

V 1.0 © Ubiquiti Networks, Inc. All Rights Reserved

Erlang – because s**t happens

[email protected]

@dieswaytoofast