Slide 1

Slide 1 text

Lessons    From    Erlang Michał  Ślaski        @michalslaski   ! ! !      PolyConf,  Poznań,  31.10.2014

Slide 2

Slide 2 text

Erlang  timeline  and  my  background

Slide 3

Slide 3 text

Erlang  timeline  and  my  background Started  out  in  the  Ericsson  software  lab  1987  (!)

Slide 4

Slide 4 text

Erlang  timeline  and  my  background Started  out  in  the  Ericsson  software  lab  1987  (!) • I  was  six  years  old


Slide 5

Slide 5 text

Erlang  timeline  and  my  background Started  out  in  the  Ericsson  software  lab  1987  (!) • I  was  six  years  old
 Released  as  open  source  in  1998

Slide 6

Slide 6 text

Erlang  timeline  and  my  background Started  out  in  the  Ericsson  software  lab  1987  (!) • I  was  six  years  old
 Released  as  open  source  in  1998 • I  started  computer  science  at  AGH  2  years  later


Slide 7

Slide 7 text

Erlang  timeline  and  my  background Started  out  in  the  Ericsson  software  lab  1987  (!) • I  was  six  years  old
 Released  as  open  source  in  1998 • I  started  computer  science  at  AGH  2  years  later
 Gains  SMP  support  in  2005

Slide 8

Slide 8 text

Erlang  timeline  and  my  background Started  out  in  the  Ericsson  software  lab  1987  (!) • I  was  six  years  old
 Released  as  open  source  in  1998 • I  started  computer  science  at  AGH  2  years  later
 Gains  SMP  support  in  2005 • I  just  graduated  and  joined  Erlang  Solutions

Slide 9

Slide 9 text

Maintenance  vs.  Development

Slide 10

Slide 10 text

Maintenance  vs.  Development Maintenance  may  span  for  20  years,
 whereas  development  may  be  1-­‐2  years.     ! ! ! ! ! ! ! ! ! Schach,  R.,  Software  Engineering
 Fourth  Edition,  McGraw-­‐Hill,  Boston,  MA  1999


Slide 11

Slide 11 text

Erlang  properties

Slide 12

Slide 12 text

Erlang  properties OTP  behaviours   • set  of  design  patterns   • client-­‐server,  fsm,  supervisor   • application,  release


Slide 13

Slide 13 text

Erlang  properties OTP  behaviours   • set  of  design  patterns   • client-­‐server,  fsm,  supervisor   • application,  release
 What  for?   • consistent  maintenance  procedures   • one  tar  ball  artefact

Slide 14

Slide 14 text

Erlang  OTP  releases $ ls -l ../abacus.tar -rw-r--r-- 1 ms staff 12331520 Oct 31 12:01 abacus.tar ! $ ls -1 bin erts-6.1 lib releases ! $ ./bin/abacus Erlang/OTP 17 [erts-6.1] [smp:4:4] 
 [async-threads:10] [kernel-poll:false] ! Eshell V6.1 (abort with ^G) (abacus@127.0.0.1)1> github.com/michalslaski/erlang-­‐workshop

Slide 15

Slide 15 text

Erlang  properties

Slide 16

Slide 16 text

Erlang  properties Robustness   • simple  and  consistent  error  recovery   • supervision  hierarchies   • program  for  the  correct  case   • let  it  crash


Slide 17

Slide 17 text

Erlang  properties Robustness   • simple  and  consistent  error  recovery   • supervision  hierarchies   • program  for  the  correct  case   • let  it  crash
 What  for?   • resilient  to  bugs  and  failures

Slide 18

Slide 18 text

Erlang  properties  -­‐  supervision  tree

Slide 19

Slide 19 text

Erlang  properties  -­‐  supervision  tree

Slide 20

Slide 20 text

Erlang  properties  -­‐  supervision  tree

Slide 21

Slide 21 text

Erlang  properties  -­‐  supervision  tree supervisor

Slide 22

Slide 22 text

Erlang  properties  -­‐  supervision  tree supervisor worker

Slide 23

Slide 23 text

Erlang  properties  -­‐  supervision  tree supervisor worker

Slide 24

Slide 24 text

Erlang  properties  -­‐  supervision  tree supervisor worker

Slide 25

Slide 25 text

Erlang  properties  -­‐  supervision  tree supervisor worker

Slide 26

Slide 26 text

Erlang  properties

Slide 27

Slide 27 text

Erlang  properties Distribution   • explicit  or  transparent  distribution   • network-­‐aware  runtime  system


Slide 28

Slide 28 text

Erlang  properties Distribution   • explicit  or  transparent  distribution   • network-­‐aware  runtime  system
 What  for?   • remote  Erlang  shell  (REPL)   • remote  observing  tools

Slide 29

Slide 29 text

Erlang  properties  -­‐  distribution

Slide 30

Slide 30 text

Erlang  properties  -­‐  distribution cat

Slide 31

Slide 31 text

Erlang  properties  -­‐  distribution cat flea

Slide 32

Slide 32 text

Erlang  properties  -­‐  distribution cat flea nodes() = [cat@home, flea@home]

Slide 33

Slide 33 text

Erlang  properties  -­‐  distribution cat dog flea bird nodes() = [cat@home, flea@home]

Slide 34

Slide 34 text

Erlang  properties  -­‐  distribution cat dog flea bird nodes() = [cat@home, flea@home] nodes() = [dog@home, bird@home]

Slide 35

Slide 35 text

Erlang  properties  -­‐  distribution cat dog flea bird nodes() = [cat@home, flea@home] nodes() = [dog@home, bird@home]

Slide 36

Slide 36 text

Erlang  properties  -­‐  distribution cat dog flea bird nodes() = [cat@home, flea@home, dog@work, bird@work]

Slide 37

Slide 37 text

entop  vs.  top

Slide 38

Slide 38 text

entop  vs.  top

Slide 39

Slide 39 text

entop  vs.  top https://github.com/mazenharake/entop

Slide 40

Slide 40 text

Erlang  properties

Slide 41

Slide 41 text

Erlang  properties Hot  code  loading   • easily  change  code  in  a  running  system   • enables  non-­‐stop  operation   • simplifies  testing


Slide 42

Slide 42 text

Erlang  properties Hot  code  loading   • easily  change  code  in  a  running  system   • enables  non-­‐stop  operation   • simplifies  testing
 What  for?   • shorter  development  cycle   • non-­‐stop  operations

Slide 43

Slide 43 text

Erlang  properties

Slide 44

Slide 44 text

Erlang  properties Tracing  in  Erlang  VM   • Tracing  is  turned  on/off  per  process   • function  calls,  message  passing,  GC,  scheduler


Slide 45

Slide 45 text

Erlang  properties Tracing  in  Erlang  VM   • Tracing  is  turned  on/off  per  process   • function  calls,  message  passing,  GC,  scheduler
 What  for?   • live  debugging   • no  need  to  instrument  code  and  recompile

Slide 46

Slide 46 text

Erlang  tracing courtesy  of  Mats  Cronqvist

Slide 47

Slide 47 text

Erlang  tracing  calls

Slide 48

Slide 48 text

Erlang  tracing  calls redbug  -­‐  github.com/massemanet/eper   • tracing  tool  built  on  top  of  erlang:trace/3

Slide 49

Slide 49 text

Erlang  tracing  calls redbug  -­‐  github.com/massemanet/eper   • tracing  tool  built  on  top  of  erlang:trace/3 1> redbug:start("lists:seq(X,Y) -> return"). {30,1}! 2> lists:seq(1,5).! [1,2,3,4,5]! ! % 12:32:17 <0.32.0>({erlang,apply,2})! % lists:seq(1, 5)! ! % 12:32:17 <0.32.0>({erlang,apply,2})! % lists:seq/2 -> [1,2,3,4,5]

Slide 50

Slide 50 text

Flame  Graphs  for  Erlang  -­‐  eflame

Slide 51

Slide 51 text

Flame  Graphs  for  Erlang  -­‐  eflame github.com/proger/eflame   • as  stacks  are  collected  through  tracing,
 blocking  calls  are  noticed  and  are  drawn  in  blue

Slide 52

Slide 52 text

Flame  Graphs  for  Erlang  -­‐  eflame github.com/proger/eflame   • as  stacks  are  collected  through  tracing,
 blocking  calls  are  noticed  and  are  drawn  in  blue

Slide 53

Slide 53 text

What’s  next?

Slide 54

Slide 54 text

Erlang  the  Movie

Slide 55

Slide 55 text

Erlang  the  Movie

Slide 56

Slide 56 text

Erlang  the  Movie  II

Slide 57

Slide 57 text

Erlang  the  Movie  II

Slide 58

Slide 58 text

Open  source  projects

Slide 59

Slide 59 text

Open  source  projects • RabbitMQ  message  broker  


Slide 60

Slide 60 text

Open  source  projects • RabbitMQ  message  broker  
 • MongooseIM  XMPP  server


Slide 61

Slide 61 text

Open  source  projects • RabbitMQ  message  broker  
 • MongooseIM  XMPP  server
 • Riak  database


Slide 62

Slide 62 text

Open  source  projects • RabbitMQ  message  broker  
 • MongooseIM  XMPP  server
 • Riak  database
 • CouchDB  database

Slide 63

Slide 63 text

Erlang  Community

Slide 64

Slide 64 text

Erlang  Community Erlang  Central   • www.erlangcentral.org


Slide 65

Slide 65 text

Erlang  Community Erlang  Central   • www.erlangcentral.org
 Erlang  Factory   • Berlin,  December  4   • San  Francisco,  March  26-­‐27


Slide 66

Slide 66 text

Erlang  Community Erlang  Central   • www.erlangcentral.org
 Erlang  Factory   • Berlin,  December  4   • San  Francisco,  March  26-­‐27
 Lambda  Days   • Kraków,  February  26-­‐27

Slide 67

Slide 67 text

Lambda  Days  Call  for  Papers

Slide 68

Slide 68 text

Lambda  Days  Call  for  Papers SUBMIT  YOUR  TALK

Slide 69

Slide 69 text

Questions? ! Michał  Ślaski          @michalslaski