SlideShare a Scribd company logo
1 of 73
Download to read offline
Erlang Patterns 
Matching Business 
Needs 
Torben Hoffmann 
CTO @ Erlang Solutions 
torben.hoffmann@erlang-solutions.com 
@LeHoff
Background 
Erlanger since 2006 
Happiness 
Mission critical gateway for Tetra 
Hard work 
Major learnings
Why this talk? 
Encourage you to embrace failure 
Show how The Golden Trinity of Erlang 
delivers business value 
Spread the Erlang love
Dealing with 
disbelievers… 
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://images1.wikia.nocookie.net/__cb20110119125642/villains/images/e/ef/Saruman.jpg 
source: http://asset3.cbsistatic.com/cnwk.1d/i/tim2/2013/08/12/Larry_Ellison_Oracle_Open_World_2009_610x407.jpg
What Does Business 
Need?
wanted 
productivity 
no down-time 
something that always works
wanted 
money 
money 
money 
it’s a rich man’s world! 
Source: http://zapp5.staticworld.net/images/article/2011/10/cash_bag_of_money-5225858.jpg
Distributed Systems 
source: http://www.krug-soft.com/297.html 
How likely is it that 
this will “just work”?
Failure is unavoidable 
Software Errors Cost 
U.S. Economy 
$59.5 
Billion 
Annually 
(NIST 2002*) 
* http://www.abeacha.com/NIST_press_release_bugs_cost.htm
The thinking it took to 
get us into this mess 
is not the same 
thinking that is going to 
get us out of it.
Source: http://www.sustainwellbeing.net/lemmings.html
Why Erlang?
Source: http://zapp5.staticworld.net/images/article/2011/10/cash_bag_of_money-5225858.jpg
Source:http://daynamartin.com/unschooling-blog/truth-in-the-fun-zone/
Polyglot 
is Good™ 
Source: http://www.americanscientist.org/issues/id.3489,y.0,no.,content.true,page.1,css.print/issue.aspx
Erlang not on the map is 
the #1 reason to learn it
Any sufficiently complicated concurrent 
program in another language contains 
an ad hoc informally-specified bug-ridden 
slow implementation of half of 
Erlang.” 
Robert Virding 
First Rule of Programming
Fighting Failures
Defensive Coding 
Data 
Mobility 
component 
breakdown 
Source: 
h*p://www.slideshare.net/ 
JanHenryNystrom/produc;vity-­‐ 
gains-­‐in-­‐erlang 
25% Defensive 
<20% App 
You are loosing money!
Heisenbugs 
Jim Gray - Why Computers Stop 
Heisenbug = goes away when retrying 
Bohrbug = a real bug 
Saw 132 faults - 131 were Heisenbugs 
http://www.hpl.hp.com/techreports/tandem/TR-85.7.pdf
Keys to Fault Tolerance 
Jim Gray - Why Computers Stop 
software modularity through processes and message 
passing 
fault containment through fail-fast software 
process-pairs to tolerate transient hardware & software 
faults 
transaction mechanism to give data and message integrity 
transaction mechanism combined with process-pairs to 
ease exception handling and tolerate software faults 
http://www.hpl.hp.com/techreports/tandem/TR-85.7.pdf
Separation of 
Concerns 
Not embracing failure means you loose 
the ability to handle failures gracefully! 
Golden Path Failure Handling 
GOBAODD!!!!
The Golden Trinity Of Erlang
Share Nothing
To Share Or Not To 
Share 
Memory Corrupt Memory Corrupt 
Memory 
P1 P2 P1 P2
Message Passing 
M 
P1 P2 
P1 sends M to P2. 
Every process has a mailbox 
Messages are received: 
receive {tag, Value} -> Value; N when is_integer(N) -> N + 42 
end
Fail Fast
Failures 
Anything that can go wrong, 
will go wrong. 
Murphy 
Programming errors 
Disk failures 
Network failures 
source: http://www.krug-soft.com/297.html 
Whatever can happen will 
happen. 
De Morgan
Fault In-Tolerance 
Most programming paradigmes are 
fault in-tolerant 
⇒ must deal with all errors or die 
source: http://www.thelmagazine.com/BrooklynAbridged/archives/2013/05/14/ 
should-we-be-worried-about-this-brooklyn-measles-outbreak
Fault Tolerance 
Erlang is fault tolerant by design 
⇒ failures are embraced and managed 
source: http://johnkreng.wordpress.com/tag/jean-claude-van-damme/
. 
Let It Fail 
convert(monday) -> 1; 
convert(tuesday) -> 2; 
convert(wednesday) -> 3; 
convert(thursday) -> 4; 
convert(friday) -> 5; 
convert(saturday) -> 6; 
convert(sunday) -> 7 
; 
convert(_) -> 
{error, unknown_day}. 
Erlang encourages offensive programming
Supervision
Handling Failure 
P1 P2 
P1 monitors P2. 
P1 P2 
P1 and P2 are linked.
PROPAGATING EXIT SIGNALS 
{'EXIT', PidA, Reason} 
PidA PidB 
PidC 
{'EXIT', PidB, Reason}
TRAPPING AN EXIT SIGNAL 
PidA 
{'EXIT', PidA, Reason} 
PidB 
PidC
Supervision Trees 
© 1999-2012 Erlang Solutions Ltd. 
37 
worker worker 
worker worker worker 
The OTP library is 
built on this principle 
supervisor 
supervisor
The OTP Supervisor 
supervisor 
© 1999-2012 Erlang Solutions Ltd. 
38 
worker worker worker 
Specifies a default restart strategy 
one_for_one 
one_for_all 
rest_for_one 
simple_one_for_one 
Child spec for how a child is restarted 
permanent | transient | temporary
Supervision Patterns
Supervisors
Simple Manager/ 
Worker Pattern
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
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
Saving Money
Benefits of let-it-fail 
code that solves 
the problem 
Erlang @ 3x 
Data 
Mobility 
component 
breakdown 
Source: 
h*p://www.slideshare.net/ 
JanHenryNystrom/produc;vity-­‐ 
gains-­‐in-­‐erlang
Productivity with Erlang @ Motorola 
Goal: Development of a mission-critical telecom 
gateway for TETRA 
To be developed from scratch using Erlang and 
some drivers in C 
The gateway translates between proprietary 
protocols and the ISI standard 
Developed using a two – six man team over 
four year
Productivity with Erlang @ Motorola 
Function point analysis 
Language agnostic measurement of problem size 
Internal storage 
input 
input 
input 
input 
output 
output 
output
Show me the money! 
Function Point Analysis of the size of the problem 
Conservative estimation of the number of… 
inputs, 
outputs and 
internal storage 
Includes design, box test, system 
test, project management efforts
Dealing with 
deadlocks 
7 years of coding Erlang 
Time spent on deadlock issues…. 
1 hour (due to lack of experience with OTP)
Realities of software 
development 
Source: http://www.thejournal.ie/readme/lunch-atop-skyscraper-photo-men-irish-shanaglish-518110-Jul2012/ 
Product 
Ow?n?e??r
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
Where To Use Erlang
The Sweet Spot 
GUI 
Middleware 
Coordination 
Control 
Drivers
Erlang History
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
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
General vs Domain 
Specific 
Telecom 
C++/Java 
Erlang 
Smaller gap 
= 
money!
If the glove fits... 
needs/fit 
C 
Erlang 
Telecom 
drivers coordination GUI
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
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. 
@jlouis
Other Erlang Domains 
Messaging - XMPP et al 
ejabberd, MongooseIM 
Webservers 
Yaws, Chicago Boss, Cowboy 
Payment switches & soft switches 
Vocalink, OpenFlow/LINC 
Distributed Databases 
Riak, CouchDB, Scalaris 
Queueing systems 
RabbitMQ (AMQP)
The glove fits! 
Low 
latency 
Stateful 
Massively 
concurrent 
Distributed Fault tolerant 
Messaging 
Webservers 
Soft switches 
Distributed DBs 
Queueing 
systems
Some Customers 
19,000,000,000 reasons to use Erlang
WhatsApp 
Real-time Messaging 
Text and Pictures 
Group chat
WhatsApp Numbers 
10 Erlang engineers 
~500M monthly users 
19B msg/day in / 40B msg/day out 
147M concurrent connections 
peak: 324K msg/s in / 712K msg/s out
WhatsApp Hardware 
~550 servers 
2x2690v2 Ivy Bridge 10-core (40 
threads total) 
64-512 GB RAM 
SSD 
>11,000 cores
Bet365 
Research team re-did a Java system in 
Erlang as a POC 
Results: 
5x connected users in load test 
4x rate of data change 
Better utilisation of CPU resources 
How to convince the developers to 
switch?
Bet365 showed that 
Erlang… 
makes programming fun 
scales and is reliable 
has enough depth to be interesting 
solves difficult problems with simple code 
Results: 
production teams quickly started to 
appreciate the benefits of Erlang 
did not want to go back to Java 
https://www.erlang-solutions.com/resources/webinars/webinar-recording-erlang-gamblingonline-betting
Learning Erlang
Source: http://www.despair.com/mistakes.html
Learning Erlang 
ESL training courses 
Learn You Some Erlang 
http://learnyousomeerlang.com/ 
Use the erlang-questions mailing list 
Do it hands-on 
Give it time to sink in!!!
Elixir 
Built on top of the Erlang VM 
More Ruby-like syntax 
Hygienic macros - easy to do DSLs 
Better support for data handling 
But… you still have to learn the Erlang 
programming model
Cruising with Erlang 
Understand the failure model 
Embrace failure! 
Use supervision patterns to deliver 
business value 
Stay in charge!

More Related Content

What's hot

Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tigerElizabeth Smith
 
ShaREing Is Caring
ShaREing Is CaringShaREing Is Caring
ShaREing Is Caringsporst
 
Measuring Your Code
Measuring Your CodeMeasuring Your Code
Measuring Your CodeNate Abele
 
Php internal architecture
Php internal architecturePhp internal architecture
Php internal architectureElizabeth Smith
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
Learn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshopLearn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshopchartjes
 
C++ Restrictions for Game Programming.
C++ Restrictions for Game Programming.C++ Restrictions for Game Programming.
C++ Restrictions for Game Programming.Richard Taylor
 
PHP Frameworks Review - Mar 19 2015
PHP Frameworks Review - Mar 19 2015PHP Frameworks Review - Mar 19 2015
PHP Frameworks Review - Mar 19 2015kyphpug
 
2009 Eclipse Con
2009 Eclipse Con2009 Eclipse Con
2009 Eclipse Conguest29922
 
Perl6 DBDI YAPC::EU 201008
Perl6 DBDI YAPC::EU 201008Perl6 DBDI YAPC::EU 201008
Perl6 DBDI YAPC::EU 201008Tim Bunce
 
Reverse-engineering: Using GDB on Linux
Reverse-engineering: Using GDB on LinuxReverse-engineering: Using GDB on Linux
Reverse-engineering: Using GDB on LinuxRick Harris
 

What's hot (19)

Protocol buffers
Protocol buffersProtocol buffers
Protocol buffers
 
Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tiger
 
Protocol Buffer.ppt
Protocol Buffer.pptProtocol Buffer.ppt
Protocol Buffer.ppt
 
ShaREing Is Caring
ShaREing Is CaringShaREing Is Caring
ShaREing Is Caring
 
Measuring Your Code
Measuring Your CodeMeasuring Your Code
Measuring Your Code
 
Php internal architecture
Php internal architecturePhp internal architecture
Php internal architecture
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Learn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshopLearn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshop
 
Variety of automated tests
Variety of automated testsVariety of automated tests
Variety of automated tests
 
C++ Restrictions for Game Programming.
C++ Restrictions for Game Programming.C++ Restrictions for Game Programming.
C++ Restrictions for Game Programming.
 
Php Vs Phyton
Php Vs PhytonPhp Vs Phyton
Php Vs Phyton
 
PHP Frameworks Review - Mar 19 2015
PHP Frameworks Review - Mar 19 2015PHP Frameworks Review - Mar 19 2015
PHP Frameworks Review - Mar 19 2015
 
2009 Eclipse Con
2009 Eclipse Con2009 Eclipse Con
2009 Eclipse Con
 
Xmpp and java
Xmpp and javaXmpp and java
Xmpp and java
 
soa
soasoa
soa
 
Core java day1
Core java day1Core java day1
Core java day1
 
Perl6 DBDI YAPC::EU 201008
Perl6 DBDI YAPC::EU 201008Perl6 DBDI YAPC::EU 201008
Perl6 DBDI YAPC::EU 201008
 
Bottom-Line Web Services
Bottom-Line Web ServicesBottom-Line Web Services
Bottom-Line Web Services
 
Reverse-engineering: Using GDB on Linux
Reverse-engineering: Using GDB on LinuxReverse-engineering: Using GDB on Linux
Reverse-engineering: Using GDB on Linux
 

Viewers also liked

Erlang - Because s**t Happens by Mahesh Paolini-Subramanya
Erlang - Because s**t Happens by Mahesh Paolini-SubramanyaErlang - Because s**t Happens by Mahesh Paolini-Subramanya
Erlang - Because s**t Happens by Mahesh Paolini-SubramanyaHakka Labs
 
Winning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleWinning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleRusty Klophaus
 
20 reasons why we don't need architects (@pavlobaron)
20 reasons why we don't need architects (@pavlobaron)20 reasons why we don't need architects (@pavlobaron)
20 reasons why we don't need architects (@pavlobaron)Pavlo Baron
 
Messaging With Erlang And Jabber
Messaging With  Erlang And  JabberMessaging With  Erlang And  Jabber
Messaging With Erlang And Jabberl xf
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John StevensonJAX London
 
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)Howard Lewis Ship
 
VoltDB and Erlang - Tech planet 2012
VoltDB and Erlang - Tech planet 2012VoltDB and Erlang - Tech planet 2012
VoltDB and Erlang - Tech planet 2012Eonblast
 
Introduction to Erlang for Python Programmers
Introduction to Erlang for Python ProgrammersIntroduction to Erlang for Python Programmers
Introduction to Erlang for Python ProgrammersPython Ireland
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Introthnetos
 
Elixir for aspiring Erlang developers
Elixir for aspiring Erlang developersElixir for aspiring Erlang developers
Elixir for aspiring Erlang developersTorben Dohrn
 
Clojure: Towards The Essence of Programming
Clojure: Towards The Essence of ProgrammingClojure: Towards The Essence of Programming
Clojure: Towards The Essence of ProgrammingHoward Lewis Ship
 
Elixir Into Production
Elixir Into ProductionElixir Into Production
Elixir Into ProductionJamie Winsor
 
Clojure, Plain and Simple
Clojure, Plain and SimpleClojure, Plain and Simple
Clojure, Plain and SimpleBen Mabey
 

Viewers also liked (20)

Clojure values
Clojure valuesClojure values
Clojure values
 
Elixir talk
Elixir talkElixir talk
Elixir talk
 
Erlang - Because s**t Happens by Mahesh Paolini-Subramanya
Erlang - Because s**t Happens by Mahesh Paolini-SubramanyaErlang - Because s**t Happens by Mahesh Paolini-Subramanya
Erlang - Because s**t Happens by Mahesh Paolini-Subramanya
 
Winning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleWinning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test Cycle
 
20 reasons why we don't need architects (@pavlobaron)
20 reasons why we don't need architects (@pavlobaron)20 reasons why we don't need architects (@pavlobaron)
20 reasons why we don't need architects (@pavlobaron)
 
High Performance Erlang
High  Performance  ErlangHigh  Performance  Erlang
High Performance Erlang
 
Messaging With Erlang And Jabber
Messaging With  Erlang And  JabberMessaging With  Erlang And  Jabber
Messaging With Erlang And Jabber
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
Clojure class
Clojure classClojure class
Clojure class
 
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)
 
From Perl To Elixir
From Perl To ElixirFrom Perl To Elixir
From Perl To Elixir
 
VoltDB and Erlang - Tech planet 2012
VoltDB and Erlang - Tech planet 2012VoltDB and Erlang - Tech planet 2012
VoltDB and Erlang - Tech planet 2012
 
Introduction to Erlang for Python Programmers
Introduction to Erlang for Python ProgrammersIntroduction to Erlang for Python Programmers
Introduction to Erlang for Python Programmers
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Intro
 
Elixir for aspiring Erlang developers
Elixir for aspiring Erlang developersElixir for aspiring Erlang developers
Elixir for aspiring Erlang developers
 
Clojure: Towards The Essence of Programming
Clojure: Towards The Essence of ProgrammingClojure: Towards The Essence of Programming
Clojure: Towards The Essence of Programming
 
Erlang - Because S**t Happens
Erlang - Because S**t HappensErlang - Because S**t Happens
Erlang - Because S**t Happens
 
Elixir Into Production
Elixir Into ProductionElixir Into Production
Elixir Into Production
 
Clojure, Plain and Simple
Clojure, Plain and SimpleClojure, Plain and Simple
Clojure, Plain and Simple
 

Similar to NDC London 2014: Erlang Patterns Matching Business Needs

Joe armstrong erlanga_languageforprogrammingreliablesystems
Joe armstrong erlanga_languageforprogrammingreliablesystemsJoe armstrong erlanga_languageforprogrammingreliablesystems
Joe armstrong erlanga_languageforprogrammingreliablesystemsSentifi
 
Erlang
ErlangErlang
ErlangESUG
 
How to Manage the Risk of your Polyglot Environments
How to Manage the Risk of your Polyglot EnvironmentsHow to Manage the Risk of your Polyglot Environments
How to Manage the Risk of your Polyglot EnvironmentsDevOps.com
 
The Migration From Erlang To Otp A Case Study Of A Heavy Duty Tcpip Clients...
The Migration From Erlang To Otp   A Case Study Of A Heavy Duty Tcpip Clients...The Migration From Erlang To Otp   A Case Study Of A Heavy Duty Tcpip Clients...
The Migration From Erlang To Otp A Case Study Of A Heavy Duty Tcpip Clients...l xf
 
An introduction to erlang
An introduction to erlangAn introduction to erlang
An introduction to erlangMirko Bonadei
 
Python for Data Logistics
Python for Data LogisticsPython for Data Logistics
Python for Data LogisticsKen Farmer
 
DevOps Days Vancouver 2014 Slides
DevOps Days Vancouver 2014 SlidesDevOps Days Vancouver 2014 Slides
DevOps Days Vancouver 2014 SlidesAlex Cruise
 
Dev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and FlickrDev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and FlickrJohn Allspaw
 
5 Keys to Oracle GoldenGate Implemenations
5 Keys to Oracle GoldenGate Implemenations5 Keys to Oracle GoldenGate Implemenations
5 Keys to Oracle GoldenGate ImplemenationsBobby Curtis
 
XPDays Ukraine: Legacy
XPDays Ukraine: LegacyXPDays Ukraine: Legacy
XPDays Ukraine: LegacyVictor_Cr
 
Product! - The road to production deployment
Product! - The road to production deploymentProduct! - The road to production deployment
Product! - The road to production deploymentFilippo Zanella
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...Joe Ferguson
 
Java Memory Hogs.pdf
Java Memory Hogs.pdfJava Memory Hogs.pdf
Java Memory Hogs.pdfGurbinder3
 
Succeeding with Functional-first Programming in Enterprise
Succeeding with Functional-first Programming in EnterpriseSucceeding with Functional-first Programming in Enterprise
Succeeding with Functional-first Programming in Enterprisedsyme
 

Similar to NDC London 2014: Erlang Patterns Matching Business Needs (20)

Joe armstrong erlanga_languageforprogrammingreliablesystems
Joe armstrong erlanga_languageforprogrammingreliablesystemsJoe armstrong erlanga_languageforprogrammingreliablesystems
Joe armstrong erlanga_languageforprogrammingreliablesystems
 
WoMakersCode 2016 - Shit Happens
WoMakersCode 2016 -  Shit HappensWoMakersCode 2016 -  Shit Happens
WoMakersCode 2016 - Shit Happens
 
Erlang
ErlangErlang
Erlang
 
How to Manage the Risk of your Polyglot Environments
How to Manage the Risk of your Polyglot EnvironmentsHow to Manage the Risk of your Polyglot Environments
How to Manage the Risk of your Polyglot Environments
 
Narayana
NarayanaNarayana
Narayana
 
The Migration From Erlang To Otp A Case Study Of A Heavy Duty Tcpip Clients...
The Migration From Erlang To Otp   A Case Study Of A Heavy Duty Tcpip Clients...The Migration From Erlang To Otp   A Case Study Of A Heavy Duty Tcpip Clients...
The Migration From Erlang To Otp A Case Study Of A Heavy Duty Tcpip Clients...
 
An introduction to erlang
An introduction to erlangAn introduction to erlang
An introduction to erlang
 
Python for Data Logistics
Python for Data LogisticsPython for Data Logistics
Python for Data Logistics
 
DevOps Days Vancouver 2014 Slides
DevOps Days Vancouver 2014 SlidesDevOps Days Vancouver 2014 Slides
DevOps Days Vancouver 2014 Slides
 
Dev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and FlickrDev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and Flickr
 
5 Keys to Oracle GoldenGate Implemenations
5 Keys to Oracle GoldenGate Implemenations5 Keys to Oracle GoldenGate Implemenations
5 Keys to Oracle GoldenGate Implemenations
 
Erlang os
Erlang osErlang os
Erlang os
 
XPDays Ukraine: Legacy
XPDays Ukraine: LegacyXPDays Ukraine: Legacy
XPDays Ukraine: Legacy
 
Technical Recruitment Overview & Tips
Technical Recruitment Overview & TipsTechnical Recruitment Overview & Tips
Technical Recruitment Overview & Tips
 
Product! - The road to production deployment
Product! - The road to production deploymentProduct! - The road to production deployment
Product! - The road to production deployment
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...
 
Intro To AOP
Intro To AOPIntro To AOP
Intro To AOP
 
Java Memory Hogs.pdf
Java Memory Hogs.pdfJava Memory Hogs.pdf
Java Memory Hogs.pdf
 
Teamwork Presentation
Teamwork PresentationTeamwork Presentation
Teamwork Presentation
 
Succeeding with Functional-first Programming in Enterprise
Succeeding with Functional-first Programming in EnterpriseSucceeding with Functional-first Programming in Enterprise
Succeeding with Functional-first Programming in Enterprise
 

Recently uploaded

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 

Recently uploaded (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 

NDC London 2014: Erlang Patterns Matching Business Needs

  • 1. Erlang Patterns Matching Business Needs Torben Hoffmann CTO @ Erlang Solutions torben.hoffmann@erlang-solutions.com @LeHoff
  • 2.
  • 3. Background Erlanger since 2006 Happiness Mission critical gateway for Tetra Hard work Major learnings
  • 4. Why this talk? Encourage you to embrace failure Show how The Golden Trinity of Erlang delivers business value Spread the Erlang love
  • 5. Dealing with disbelievers… 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://images1.wikia.nocookie.net/__cb20110119125642/villains/images/e/ef/Saruman.jpg source: http://asset3.cbsistatic.com/cnwk.1d/i/tim2/2013/08/12/Larry_Ellison_Oracle_Open_World_2009_610x407.jpg
  • 7. wanted productivity no down-time something that always works
  • 8. wanted money money money it’s a rich man’s world! Source: http://zapp5.staticworld.net/images/article/2011/10/cash_bag_of_money-5225858.jpg
  • 9. Distributed Systems source: http://www.krug-soft.com/297.html How likely is it that this will “just work”?
  • 10. Failure is unavoidable Software Errors Cost U.S. Economy $59.5 Billion Annually (NIST 2002*) * http://www.abeacha.com/NIST_press_release_bugs_cost.htm
  • 11. The thinking it took to get us into this mess is not the same thinking that is going to get us out of it.
  • 16. Polyglot is Good™ Source: http://www.americanscientist.org/issues/id.3489,y.0,no.,content.true,page.1,css.print/issue.aspx
  • 17. Erlang not on the map is the #1 reason to learn it
  • 18. Any sufficiently complicated concurrent program in another language contains an ad hoc informally-specified bug-ridden slow implementation of half of Erlang.” Robert Virding First Rule of Programming
  • 20. Defensive Coding Data Mobility component breakdown Source: h*p://www.slideshare.net/ JanHenryNystrom/produc;vity-­‐ gains-­‐in-­‐erlang 25% Defensive <20% App You are loosing money!
  • 21. Heisenbugs Jim Gray - Why Computers Stop Heisenbug = goes away when retrying Bohrbug = a real bug Saw 132 faults - 131 were Heisenbugs http://www.hpl.hp.com/techreports/tandem/TR-85.7.pdf
  • 22. Keys to Fault Tolerance Jim Gray - Why Computers Stop software modularity through processes and message passing fault containment through fail-fast software process-pairs to tolerate transient hardware & software faults transaction mechanism to give data and message integrity transaction mechanism combined with process-pairs to ease exception handling and tolerate software faults http://www.hpl.hp.com/techreports/tandem/TR-85.7.pdf
  • 23. Separation of Concerns Not embracing failure means you loose the ability to handle failures gracefully! Golden Path Failure Handling GOBAODD!!!!
  • 24. The Golden Trinity Of Erlang
  • 26. To Share Or Not To Share Memory Corrupt Memory Corrupt Memory P1 P2 P1 P2
  • 27. Message Passing M P1 P2 P1 sends M to P2. Every process has a mailbox Messages are received: receive {tag, Value} -> Value; N when is_integer(N) -> N + 42 end
  • 29. Failures Anything that can go wrong, will go wrong. Murphy Programming errors Disk failures Network failures source: http://www.krug-soft.com/297.html Whatever can happen will happen. De Morgan
  • 30. Fault In-Tolerance Most programming paradigmes are fault in-tolerant ⇒ must deal with all errors or die source: http://www.thelmagazine.com/BrooklynAbridged/archives/2013/05/14/ should-we-be-worried-about-this-brooklyn-measles-outbreak
  • 31. Fault Tolerance Erlang is fault tolerant by design ⇒ failures are embraced and managed source: http://johnkreng.wordpress.com/tag/jean-claude-van-damme/
  • 32. . Let It Fail convert(monday) -> 1; convert(tuesday) -> 2; convert(wednesday) -> 3; convert(thursday) -> 4; convert(friday) -> 5; convert(saturday) -> 6; convert(sunday) -> 7 ; convert(_) -> {error, unknown_day}. Erlang encourages offensive programming
  • 34. Handling Failure P1 P2 P1 monitors P2. P1 P2 P1 and P2 are linked.
  • 35. PROPAGATING EXIT SIGNALS {'EXIT', PidA, Reason} PidA PidB PidC {'EXIT', PidB, Reason}
  • 36. TRAPPING AN EXIT SIGNAL PidA {'EXIT', PidA, Reason} PidB PidC
  • 37. Supervision Trees © 1999-2012 Erlang Solutions Ltd. 37 worker worker worker worker worker The OTP library is built on this principle supervisor supervisor
  • 38. The OTP Supervisor supervisor © 1999-2012 Erlang Solutions Ltd. 38 worker worker worker Specifies a default restart strategy one_for_one one_for_all rest_for_one simple_one_for_one Child spec for how a child is restarted permanent | transient | temporary
  • 42. 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
  • 43. 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
  • 45. Benefits of let-it-fail code that solves the problem Erlang @ 3x Data Mobility component breakdown Source: h*p://www.slideshare.net/ JanHenryNystrom/produc;vity-­‐ gains-­‐in-­‐erlang
  • 46. Productivity with Erlang @ Motorola Goal: Development of a mission-critical telecom gateway for TETRA To be developed from scratch using Erlang and some drivers in C The gateway translates between proprietary protocols and the ISI standard Developed using a two – six man team over four year
  • 47. Productivity with Erlang @ Motorola Function point analysis Language agnostic measurement of problem size Internal storage input input input input output output output
  • 48. Show me the money! Function Point Analysis of the size of the problem Conservative estimation of the number of… inputs, outputs and internal storage Includes design, box test, system test, project management efforts
  • 49. Dealing with deadlocks 7 years of coding Erlang Time spent on deadlock issues…. 1 hour (due to lack of experience with OTP)
  • 50. Realities of software development Source: http://www.thejournal.ie/readme/lunch-atop-skyscraper-photo-men-irish-shanaglish-518110-Jul2012/ Product Ow?n?e??r
  • 51. 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
  • 52. Where To Use Erlang
  • 53. The Sweet Spot GUI Middleware Coordination Control Drivers
  • 55. 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
  • 56. 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
  • 57. General vs Domain Specific Telecom C++/Java Erlang Smaller gap = money!
  • 58. If the glove fits... needs/fit C Erlang Telecom drivers coordination GUI
  • 59. 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
  • 60. 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. @jlouis
  • 61. Other Erlang Domains Messaging - XMPP et al ejabberd, MongooseIM Webservers Yaws, Chicago Boss, Cowboy Payment switches & soft switches Vocalink, OpenFlow/LINC Distributed Databases Riak, CouchDB, Scalaris Queueing systems RabbitMQ (AMQP)
  • 62. The glove fits! Low latency Stateful Massively concurrent Distributed Fault tolerant Messaging Webservers Soft switches Distributed DBs Queueing systems
  • 63. Some Customers 19,000,000,000 reasons to use Erlang
  • 64. WhatsApp Real-time Messaging Text and Pictures Group chat
  • 65. WhatsApp Numbers 10 Erlang engineers ~500M monthly users 19B msg/day in / 40B msg/day out 147M concurrent connections peak: 324K msg/s in / 712K msg/s out
  • 66. WhatsApp Hardware ~550 servers 2x2690v2 Ivy Bridge 10-core (40 threads total) 64-512 GB RAM SSD >11,000 cores
  • 67. Bet365 Research team re-did a Java system in Erlang as a POC Results: 5x connected users in load test 4x rate of data change Better utilisation of CPU resources How to convince the developers to switch?
  • 68. Bet365 showed that Erlang… makes programming fun scales and is reliable has enough depth to be interesting solves difficult problems with simple code Results: production teams quickly started to appreciate the benefits of Erlang did not want to go back to Java https://www.erlang-solutions.com/resources/webinars/webinar-recording-erlang-gamblingonline-betting
  • 71. Learning Erlang ESL training courses Learn You Some Erlang http://learnyousomeerlang.com/ Use the erlang-questions mailing list Do it hands-on Give it time to sink in!!!
  • 72. Elixir Built on top of the Erlang VM More Ruby-like syntax Hygienic macros - easy to do DSLs Better support for data handling But… you still have to learn the Erlang programming model
  • 73. Cruising with Erlang Understand the failure model Embrace failure! Use supervision patterns to deliver business value Stay in charge!