erlang patterns matching business needs€¦ · erlang patterns matching business needs! torben...

138
Erlang Patterns Matching Business Needs Torben Hoffmann CTO, Erlang Solutions [email protected] @LeHoff

Upload: others

Post on 11-Sep-2020

6 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang Patterns Matching Business Needs

Torben Hoffmann CTO, Erlang Solutions

[email protected] @LeHoff

Page 2: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang Patterns Matching Business Needs

Torben Hoffmann CTO, Erlang Solutions

[email protected] @LeHoff

& Idioms

Page 3: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Cracks and a Chasm

Technology enthusiasts

Visionaries

PragmatistsConservatives

Laggards

Crack

CrackChasm

To cross the chasm you must talk business value!

Page 4: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Enterprise Software

http://kesseljunkie.files.wordpress.com/2011/06/star_wars_death_star_38200545907pm743.jpg

Page 5: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

What Killed the Death Star?

Page 6: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

What Killed the Death Star?

PowerShieldBreakdownException

Page 7: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

What Killed the Death Star?

PowerShieldBreakdownException

SurfaceWithAlleysDesignException

Page 8: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

What Killed the Death Star?

MissileEnteredUnprotecedVentilationShaftException

PowerShieldBreakdownException

SurfaceWithAlleysDesignException

Page 9: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Expect resistance…

Source: http://2.bp.blogspot.com/-qNM3LGTtUYM/UIFLJGd_MLI/AAAAAAAAAnU/GCtI5SYfbCs/s320/orc-army.jpg

source: http://asset3.cbsistatic.com/cnwk.1d/i/tim2/2013/08/12/Larry_Ellison_Oracle_Open_World_2009_610x407.jpg

source: http://images1.wikia.nocookie.net/__cb20110119125642/villains/images/e/ef/Saruman.jpg

Page 10: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Expect resistance…

Source: http://2.bp.blogspot.com/-qNM3LGTtUYM/UIFLJGd_MLI/AAAAAAAAAnU/GCtI5SYfbCs/s320/orc-army.jpg

source: http://asset3.cbsistatic.com/cnwk.1d/i/tim2/2013/08/12/Larry_Ellison_Oracle_Open_World_2009_610x407.jpg

source: http://images1.wikia.nocookie.net/__cb20110119125642/villains/images/e/ef/Saruman.jpg

Page 11: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Expect resistance…

Source: http://2.bp.blogspot.com/-qNM3LGTtUYM/UIFLJGd_MLI/AAAAAAAAAnU/GCtI5SYfbCs/s320/orc-army.jpg

source: http://www.rottentomatoes.com/m/1014027-mission/

source: http://asset3.cbsistatic.com/cnwk.1d/i/tim2/2013/08/12/Larry_Ellison_Oracle_Open_World_2009_610x407.jpg

source: http://images1.wikia.nocookie.net/__cb20110119125642/villains/images/e/ef/Saruman.jpg

Page 12: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Citius, Altius, Fortius

Page 13: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Citius, Altius, Fortius

Olympic Motto

Page 14: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Citius, Maior, Vilius

Page 15: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Citius, Maior, Vilius

Business Imperative

Page 16: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Everlasting Software Requirements

Page 17: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Everlasting Software Requirements

speed to market

Page 18: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Everlasting Software Requirements

speed to market

reliable

Page 19: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Everlasting Software Requirements

speed to market

reliable

scalable

Page 20: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Everlasting Software Requirements

speed to market

reliable

scalable

maintainable

Page 21: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Agile Manifesto

Page 22: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Agile Manifesto

Individuals and interactions > Processes and tools

Page 23: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Agile Manifesto

Individuals and interactions > Processes and tools

Working software > Comprehensive documentation

Page 24: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Agile Manifesto

Individuals and interactions > Processes and tools

Working software > Comprehensive documentation

Customer collaboration > Contract negotiation

Page 25: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Agile Manifesto

Individuals and interactions > Processes and tools

Working software > Comprehensive documentation

Customer collaboration > Contract negotiation

Responding to change > Following a plan

Page 26: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Software Architecture

Separation of concerns

Quality-driven

Recurring styles

Conceptual integrity

Page 27: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang History

Page 28: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang
Page 29: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

There are two ways of constructing a software design:

Page 30: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies…

Page 31: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies…… and the other way is to make it so complicated that there are no obvious deficiencies.

Page 32: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies…… and the other way is to make it so complicated that there are no obvious deficiencies.

- C.A.R. Hoare

Page 33: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang’s Original Requirements

Page 34: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang’s Original Requirements

Large scale concurrency

Page 35: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang’s Original Requirements

Large scale concurrency

Soft real-time

Page 36: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang’s Original Requirements

Large scale concurrency

Soft real-time

Distributed systems

Page 37: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang’s Original Requirements

Large scale concurrency

Soft real-time

Distributed systems

Hardware interaction

Page 38: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang’s Original Requirements

Large scale concurrency

Soft real-time

Distributed systems

Hardware interaction

Very large software systems

Page 39: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang’s Original Requirements

Large scale concurrency

Soft real-time

Distributed systems

Hardware interaction

Very large software systems

Complex functionality

Page 40: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang’s Original Requirements

Large scale concurrency

Soft real-time

Distributed systems

Hardware interaction

Very large software systems

Complex functionality

Continuous operation for many years

Page 41: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang’s Original Requirements

Large scale concurrency

Soft real-time

Distributed systems

Hardware interaction

Very large software systems

Complex functionality

Continuous operation for many years

Software maintenance on-the-fly

Page 42: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang’s Original Requirements

Large scale concurrency

Soft real-time

Distributed systems

Hardware interaction

Very large software systems

Complex functionality

Continuous operation for many years

Software maintenance on-the-fly

High quality and reliability

Page 43: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Erlang’s Original Requirements

Large scale concurrency

Soft real-time

Distributed systems

Hardware interaction

Very large software systems

Complex functionality

Continuous operation for many years

Software maintenance on-the-fly

High quality and reliability

Fault tolerance Bjarne Däcker’s Licentiate Thesis: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.88.1957

Page 44: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

wanted

Page 45: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

wantedproductivity

Page 46: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

wantedproductivity

no down-time

Page 47: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

wantedproductivity

no down-time

something that always works

Page 48: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

wanted

Page 49: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

wanted

money

Page 50: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

wanted

money

money

Page 51: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

wanted

money

money

money

Page 52: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

wanted

money

money

money

it’s a rich man’s world!

Page 53: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

wanted

money

money

money

it’s a rich man’s world!

Page 54: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

If our basic tool, the language in which we design and code our programs, is also complicated, the language itself becomes part of the problem rather than part of its solution. !

- C.A.R. Hoare

Page 55: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Good Erlang Domains

Page 56: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Good Erlang Domains

Low latency over throughput

Page 57: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Good Erlang Domains

Low latency over throughput

Stateful (in contrast to being stateless)

Page 58: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Good Erlang Domains

Low latency over throughput

Stateful (in contrast to being stateless)

Massively concurrent

Page 59: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Good Erlang Domains

Low latency over throughput

Stateful (in contrast to being stateless)

Massively concurrent

Distributed

Page 60: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Good Erlang Domains

Low latency over throughput

Stateful (in contrast to being stateless)

Massively concurrent

Distributed

Fault tolerant

Page 61: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Good Erlang Domains

Low latency over throughput

Stateful (in contrast to being stateless)

Massively concurrent

Distributed

Fault tolerant

Uses OTP

Page 62: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Good Erlang Domains

Low latency over throughput

Stateful (in contrast to being stateless)

Massively concurrent

Distributed

Fault tolerant

Uses OTP

Non-stop operation

Page 63: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Good Erlang Domains

Low latency over throughput

Stateful (in contrast to being stateless)

Massively concurrent

Distributed

Fault tolerant

Uses OTP

Non-stop operation

Under load, Erlang programs usually performs as well as programs in other languages, often way better.

Jesper Louis Andersen

Page 64: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

The glove fits!

Low latency Stateful Massively

concurrent Distributed Fault tolerant

Messaging

Webservers

Soft switches

Distributed DBs

Queueing systems

Page 65: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

The Golden Trinity Of Erlang

Page 66: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

To Share Or Not To Share

Page 67: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

To Share Or Not To Share

Memory

Page 68: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

To Share Or Not To Share

Memory

P1

Page 69: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

To Share Or Not To Share

Memory

P1 P2

Page 70: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

To Share Or Not To Share

Memory

P2

Corrupt

Page 71: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

To Share Or Not To Share

MemoryCorrupt

Page 72: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

To Share Or Not To Share

Memory MemoryCorrupt

Page 73: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

To Share Or Not To Share

Memory Memory

P1

Corrupt

Page 74: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

To Share Or Not To Share

Memory Memory Memory

P1

Corrupt

Page 75: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

To Share Or Not To Share

Memory Memory Memory

P1 P2

Corrupt

Page 76: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

To Share Or Not To Share

Memory Memory

P2

Corrupt Corrupt

Page 77: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

To Share Or Not To Share

Memory Memory

P2

Corrupt

Page 78: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

FailuresAnything that can go wrong, will go wrong

Murphy

Page 79: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

FailuresAnything that can go wrong, will go wrong

MurphyProgramming errors

Page 80: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

FailuresAnything that can go wrong, will go wrong

MurphyProgramming errorsDisk failures

Page 81: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

FailuresAnything that can go wrong, will go wrong

MurphyProgramming errorsDisk failuresNetwork failures

Page 82: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Failures

Most programming paradigmes are fault in-tolerant

Anything that can go wrong, will go wrong

MurphyProgramming errorsDisk failuresNetwork failures

Page 83: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Failures

Most programming paradigmes are fault in-tolerant ⇒ must deal with all errors or die

Anything that can go wrong, will go wrong

MurphyProgramming errorsDisk failuresNetwork failures

Page 84: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Failures

Most programming paradigmes are fault in-tolerant ⇒ must deal with all errors or die

Anything that can go wrong, will go wrong

MurphyProgramming errorsDisk failuresNetwork failures

Page 85: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Failures

Most programming paradigmes are fault in-tolerant ⇒ must deal with all errors or die

Anything that can go wrong, will go wrong

MurphyProgramming errorsDisk failuresNetwork failures

Erlang is fault tolerant by design

Page 86: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Failures

Most programming paradigmes are fault in-tolerant ⇒ must deal with all errors or die

Anything that can go wrong, will go wrong

MurphyProgramming errorsDisk failuresNetwork failures

Erlang is fault tolerant by design ⇒ failures are embraced and

managed

Page 87: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Failures

Most programming paradigmes are fault in-tolerant ⇒ must deal with all errors or die

Anything that can go wrong, will go wrong

MurphyProgramming errorsDisk failuresNetwork failures

Erlang is fault tolerant by design ⇒ failures are embraced and

managed

source: http://johnkreng.wordpress.com/tag/jean-claude-van-damme/source: http://www.thelmagazine.com/BrooklynAbridged/archives/2013/05/14/should-we-be-worried-about-this-brooklyn-measles-outbreak

Page 88: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Let It Failconvert(monday) -> 1;!convert(tuesday) -> 2;!convert(wednesday) -> 3;!convert(thursday) -> 4;!convert(friday) -> 5; !convert(saturday) -> 6;!convert(sunday) -> 7! ;!convert(_) ->! {error, unknown_day}.!

Page 89: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Let It Failconvert(monday) -> 1;!convert(tuesday) -> 2;!convert(wednesday) -> 3;!convert(thursday) -> 4;!convert(friday) -> 5; !convert(saturday) -> 6;!convert(sunday) -> 7! .!!

Page 90: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Let It Failconvert(monday) -> 1;!convert(tuesday) -> 2;!convert(wednesday) -> 3;!convert(thursday) -> 4;!convert(friday) -> 5; !convert(saturday) -> 6;!convert(sunday) -> 7!

Erlang encourages offensive programming

.!!

Page 91: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Intentional Programming

a style of programming where the reader of a program can easily see what the programmer intended by their code. [1]

[1] http://www.erlang.org/download/armstrong_thesis_2003.pdf

Page 92: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Intentional Dictionary data retrieval - dict:fetch(Key, Dict) = Val | EXIT

the programmer knows a specific key should be in the dictionary and it is an error if it is not.

search - dict:find(Key, Dict) = {ok, Val} | error.

it is unknown if the key is there or not and both cases must be dealt with.

test - dict:is_key(Key, Dict) = Boolean

knowing if a key is present is enough.

Page 93: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Benefits of let-it-fail

Source:  h*p://www.slideshare.net/JanHenryNystrom/produc;vity-­‐gains-­‐in-­‐erlang

Data  Mobility  component  breakdown

Page 94: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Benefits of let-it-fail

code  that  solves    the  problem

Source:  h*p://www.slideshare.net/JanHenryNystrom/produc;vity-­‐gains-­‐in-­‐erlang

Data  Mobility  component  breakdown

Page 95: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Benefits of let-it-fail

code  that  solves    the  problem

Source:  h*p://www.slideshare.net/JanHenryNystrom/produc;vity-­‐gains-­‐in-­‐erlang

Data  Mobility  component  breakdown

Page 96: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Benefits of let-it-fail

code  that  solves    the  problem

Source:  h*p://www.slideshare.net/JanHenryNystrom/produc;vity-­‐gains-­‐in-­‐erlang

Data  Mobility  component  breakdown

Page 97: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Benefits of let-it-fail

code  that  solves    the  problem

Source:  h*p://www.slideshare.net/JanHenryNystrom/produc;vity-­‐gains-­‐in-­‐erlang

Data  Mobility  component  breakdown

Page 98: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Benefits of let-it-fail

code  that  solves    the  problem

Source:  h*p://www.slideshare.net/JanHenryNystrom/produc;vity-­‐gains-­‐in-­‐erlang

Data  Mobility  component  breakdown

Page 99: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Benefits of let-it-fail

code  that  solves    the  problem

Source:  h*p://www.slideshare.net/JanHenryNystrom/produc;vity-­‐gains-­‐in-­‐erlang

Data  Mobility  component  breakdown

Page 100: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Benefits of let-it-fail

code  that  solves    the  problem

Erlang  @  3xSource:  h*p://www.slideshare.net/JanHenryNystrom/produc;vity-­‐gains-­‐in-­‐erlang

Data  Mobility  component  breakdown

Page 101: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Show me the money!

Conservative estimation of the number of inputs, outputs and internal storage

Includes design, box test, system test, project management efforts

Function Point Analysis of the size of the problem

Page 102: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Intermezzo

Page 103: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang
Page 104: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Language and Models

How many trains on one piece of track?

Page 105: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Language and Models

How many trains on one piece of track?

0..1

Page 106: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Language and Models

How many trains on one piece of track?

0..1 0..N

Page 107: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Language and Models

How many trains on one piece of track?

0..N

Page 108: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Language and Models

How many trains on one piece of track?

0..N

Without a language for something you cannot talk about it!

Page 109: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Visual Erlang

Page 110: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Visual Erlang Objectives

Page 111: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Visual Erlang Objectives

Detailed enough to capture important aspects

Page 112: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Visual Erlang Objectives

Detailed enough to capture important aspects

Not suited for 100% explanation of Erlang

Page 113: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Visual Erlang Objectives

Detailed enough to capture important aspects

Not suited for 100% explanation of Erlang

Standardise on how we show Erlang architecture

Page 114: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Visual Erlang Objectives

Detailed enough to capture important aspects

Not suited for 100% explanation of Erlang

Standardise on how we show Erlang architecture

https://github.com/esl/visual_erlang

Page 115: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Processes in Visual Erlang

Page 116: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Functions and Statedata

Page 117: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Visual Erlang Patterns

Adds vocabulary about architecture

Share insights

Consider failures while designing

Page 118: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Tuple Space Storage Pattern

Page 119: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Manager/Worker Pattern

Page 120: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Supervisor Pattern

Page 121: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Why Document Erlang Patterns?

source: http://christianaaddison.wordpress.com/2011/04/19/week-four-ux-boot-camp-co-design/

Concept from R. Martin “The Design of Business”

Page 122: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Realities of software development

Source: http://www.thejournal.ie/readme/lunch-atop-skyscraper-photo-men-irish-shanaglish-518110-Jul2012/

????

Page 123: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Realities of software development

Source: http://www.thejournal.ie/readme/lunch-atop-skyscraper-photo-men-irish-shanaglish-518110-Jul2012/

Product Owner

Page 124: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Business benefits of supervisors

Page 125: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Business benefits of supervisors

Only one process dies

Page 126: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Business benefits of supervisors

Only one process dies

isolation gives continuous service

Page 127: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Business benefits of supervisors

Only one process dies

isolation gives continuous service

Everything is logged

Page 128: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Business benefits of supervisors

Only one process dies

isolation gives continuous service

Everything is logged

you know what is wrong

Page 129: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Business benefits of supervisors

Only one process dies

isolation gives continuous service

Everything is logged

you know what is wrong

Corner cases can be fixed at leisure

Page 130: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Business benefits of supervisors

Only one process dies

isolation gives continuous service

Everything is logged

you know what is wrong

Corner cases can be fixed at leisure

Product owner in charge!

Page 131: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Business benefits of supervisors

Only one process dies

isolation gives continuous service

Everything is logged

you know what is wrong

Corner cases can be fixed at leisure

Product owner in charge!

Not the software!

Page 132: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Business benefits of supervisors

Only one process dies

isolation gives continuous service

Everything is logged

you know what is wrong

Corner cases can be fixed at leisure

Product owner in charge!

Not the software!

Software architecture that supports

iterative development

Page 133: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Cruising with Erlang

Page 134: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Cruising with Erlang

Understand the failure model

Page 135: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Cruising with Erlang

Understand the failure model

Embrace failure!

Page 136: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Cruising with Erlang

Understand the failure model

Embrace failure!

Use patterns to deliver business value

Page 137: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Cruising with Erlang

Understand the failure model

Embrace failure!

Use patterns to deliver business value

Stay in charge!

Page 138: Erlang Patterns Matching Business Needs€¦ · Erlang Patterns Matching Business Needs! Torben Hoffmann! CTO, Erlang Solutions! torben.hoffmann@erlang-solutions.com! @LeHoff. Erlang

Cruising with Erlang

Understand the failure model

Embrace failure!

Use patterns to deliver business value

Stay in charge!