Slide 1

Slide 1 text

Microservices and Erlang/OTP Christoph Iserlohn

Slide 2

Slide 2 text

About me Senior Consultant @ innoQ MacPorts Team member

Slide 3

Slide 3 text

Agenda >  Microservices >  Erlang / OTP >  How they fit together

Slide 4

Slide 4 text

Microservices

Slide 5

Slide 5 text

Attempt of definition >  A system consisting of small, self- contained services. All running isolated from each other, communicating only over the network.

Slide 6

Slide 6 text

Monoliths old and busted “Old Step Van_MG_3279“ by Kool Cats Photgraphy over 3 Million Views. Licensed under CC BY 2.0 !

Slide 7

Slide 7 text

Microservices the new hotness “Hot Hot Hot" by flattop341. Licensed under CC BY 2.0 !

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

VS.

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

cognitive dimension “Pinky & The Brain" by JD Hancock. Licensed under CC BY 2.0 !

Slide 12

Slide 12 text

on the service level: more comprehensible "Nasa earth" by NASA ESA - http://www.nasa.gov/. Licensed under Public Domain via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Nasa_earth.jpg#mediaviewer/File:Nasa_earth.jpg!

Slide 13

Slide 13 text

on the system level: unable to see the big picture "Infant Stars in Orion" by NASA/JPL-Caltech/D. Barrado y Navascués (LAEFF-INTA) - http://www.spitzer.caltech.edu/images/2131-sig07-006-Young-Stars-Emerge-from-Orion-s-Head. Licensed under Public Domain via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Infant_Stars_in_Orion.jpg#mediaviewer/File:Infant_Stars_in_Orion.jpg!

Slide 14

Slide 14 text

organisational dimension „Model of graphene structure“ by CORE-MATERIALS. Licensed under CC BY-SA 2.0 !

Slide 15

Slide 15 text

organized around business capabilities „The Market Economy “ by Baer Tierkel. Licensed under CC BY 2.0 !

Slide 16

Slide 16 text

cross-functional teams „Storm Squad “ by JD Hancock. Licensed under CC BY 2.0 !

Slide 17

Slide 17 text

„you build it, you run it“ „_DJM7077“ by nubigena. Licensed under CC BY-ND 2.0 !

Slide 18

Slide 18 text

technological dimension „Microchip e microciop“ by Fabrizio Sciami. Licensed under CC BY-SA 2.0 !

Slide 19

Slide 19 text

fault tolerance resilience „broken macbook home key“ by Doctor Rose. Licensed under CC BY-ND 2.0 !

Slide 20

Slide 20 text

asynchronous communication „Sept 25/10 Old German postbox“ by Judith Doyle. Licensed under CC BY-ND 2.0 !

Slide 21

Slide 21 text

coarse-grained interfaces „phone“ by raindog808. Licensed under CC BY 2.0 !

Slide 22

Slide 22 text

sophisticated monitoring "Mission control center" by NASAOriginal uploader was Cjosefy at en.wikipediaLater version(s) were uploaded by TheDJ at en.wikipedia. - http://spaceflight.nasa.gov/gallery/images/shuttle/sts-114/html/jsc2005e09159.htmlTransferred from en.wikipedia. Licensed under Public Domain via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Mission_control_center.jpg#mediaviewer/File:Mission_control_center.jpg!

Slide 23

Slide 23 text

infrastructure automation „Tesla Robot Dance“ by Steve Jurvetson. Licensed under CC BY 2.0 !

Slide 24

Slide 24 text

Advantages >  fast development cycle >  it‘s easy to scale >  flexibility of implementation >  easy to get started for new developers >  parts of the system can be replaced

Slide 25

Slide 25 text

Prerequisites >  monitoring the whole system >  central logging >  tracing across service boundaries >  automatic deployment >  automatic provisioning

Slide 26

Slide 26 text

Challenges >  service boundaries >  contracts and governance >  testing and refactoring >  fallacies of distributed systems >  support for a dozen technology stacks

Slide 27

Slide 27 text

Open questions >  how big? >  isn‘t this just SOA?

Slide 28

Slide 28 text

Summary >  it‘s a promising approach, >  but don‘t start with it mindlessly

Slide 29

Slide 29 text

Where are we now? "Gartner Hype Cycle" by Jeremykemp at en.wikipedia. Licensed under CC BY-SA 3.0 via Wikimedia Commons" http://commons.wikimedia.org/wiki/File:Gartner_Hype_Cycle.svg#mediaviewer/File:Gartner_Hype_Cycle.svg!

Slide 30

Slide 30 text

Erlang / OTP

Slide 31

Slide 31 text

What is Erlang / OTP? >  a general purpose programming language >  runtime environment and VM >  Open Telecom Platform: libraries, tools and design patterns for building highly concurrent, distributed, fault tolerant systems

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

fault tolerant to software and hardware errors "BSoD in Windows 8" by Microsoft - Transferred from en.wikipedia to Commons.. Licensed under Public Domain via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:BSoD_in_Windows_8.png#mediaviewer/File:BSoD_in_Windows_8.png!

Slide 34

Slide 34 text

distributed systems "BalticServers data center" by Fleshas - I took this photo. Licensed under CC BY-SA 3.0 via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:BalticServers_data_center.jpg#mediaviewer/File:BalticServers_data_center.jpg!

Slide 35

Slide 35 text

non-stop running - continous operation over years "CEV-ISS" by NASA - http://www.nasa.gov/mission_pages/exploration/spacecraft/cev_hi_res.html. Licensed under Public Domain via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:CEV-ISS.jpg#mediaviewer/File:CEV-ISS.jpg!

Slide 36

Slide 36 text

Principles >  lightweight concurrency >  asynchronous communication >  isolation >  error handling >  simple high-level language >  tools not solutions or products

Slide 37

Slide 37 text

Erlang – the language >  high-level functional language >  prolog inspired syntax >  dynamically typed / safe >  pattern matching everywhere >  recursion >  immutable data and variables

Slide 38

Slide 38 text

-module(factorial).! -export([factorial/1]).! ! factorial(N) when N >= 0 -> factorial(N,1).! ! factorial(0,Acc) -> Acc;! factorial(N,Acc) -> factorial(N-1,N*Acc).!

Slide 39

Slide 39 text

Concurrency >  millions of processes on one machine >  processes are isolated >  processes are used for everything: >  concurrency >  managing state >  parallelism >  no global data

Slide 40

Slide 40 text

Message passing >  asynchronous >  primitives: >  fire & forget send >  selective receive >  more complex interactions can be built on top of these primitives

Slide 41

Slide 41 text

-module(pingpong). -export([start/1]). start(N) when N > 0 -> Pong = spawn(fun pong/0), ping(N, Pong). ping(0,Pong) -> Pong ! exit, ok; ping(N, Pong) -> Pong ! {self(), ping}, receive pong -> io:format("Pid ~p: got pong. ~p pings left~n", [self(), N-1]) end, ping(N - 1, Pong). pong() -> receive {From, ping} -> io:format("Pid ~p: got ping from ~p~n", [self(), From]), From ! pong, pong(); exit -> ok end. !

Slide 42

Slide 42 text

Error handling >  avoid error checking code everywhere >  let it crash >  process based: >  link - bidirectional >  monitor - unidirectional >  supervision trees

Slide 43

Slide 43 text

Supervision trees

Slide 44

Slide 44 text

Supervision trees

Slide 45

Slide 45 text

Supervision trees

Slide 46

Slide 46 text

Supervision trees

Slide 47

Slide 47 text

Distribution >  loosely coupled nodes >  mostly transparent >  TCP/IP based

Slide 48

Slide 48 text

OTP >  helps creating: >  servers >  finites state machines >  event handler >  supervisors >  releases and upgrades

Slide 49

Slide 49 text

Hot code loading >  module is unit of code handling >  exists in two variants: old and current >  controlled take over

Slide 50

Slide 50 text

Instrumentation >  can trace almost everything: process events, send & receive messages, function calls >  process introspection: memory, mailbox, links, cur. function... >  interactive shell >  SNMP based OAM

Slide 51

Slide 51 text

Summary >  everything you need for building highly concurrent, distributed, robust systems >  but not well suited for number crunching or maximum perfomance requirements

Slide 52

Slide 52 text

Where are we now? "Gartner Hype Cycle" by Jeremykemp at en.wikipedia. Licensed under CC BY-SA 3.0 via Wikimedia Commons" http://commons.wikimedia.org/wiki/File:Gartner_Hype_Cycle.svg#mediaviewer/File:Gartner_Hype_Cycle.svg!

Slide 53

Slide 53 text

Microservices & Erlang/OTP: how they fit together

Slide 54

Slide 54 text

How they fit together >  Erlang / OTP has everything you need to build production-ready Microservices

Slide 55

Slide 55 text

How they fit together >  fault tolerance / resilience >  async communication is the default >  amazing monitoring capabilites >  tools for upgrading / downgrading running systems

Slide 56

Slide 56 text

„Green Day 2010 Tour“ by Daniel D‘Auria. Licensed under CC BY-SA 2.0 !

Slide 57

Slide 57 text

Thank you! >  Questions ? >  Comments ? Christoph Iserlohn [email protected]