Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Microservices and Erlang/OTP

Microservices and Erlang/OTP

Talk by Christoph Iserlohn at BOB conference, Berlin, 23 January 2015

innoQ Deutschland GmbH

February 17, 2015
Tweet

More Decks by innoQ Deutschland GmbH

Other Decks in Programming

Transcript

  1. Attempt of definition >  A system consisting of small, self-

    contained services. All running isolated from each other, communicating only over the network.
  2. Monoliths old and busted “Old Step Van_MG_3279“ by Kool Cats

    Photgraphy over 3 Million Views. Licensed under CC BY 2.0 !
  3. VS.

  4. 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!
  5. 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!
  6. 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!
  7. 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
  8. Prerequisites >  monitoring the whole system >  central logging > 

    tracing across service boundaries >  automatic deployment >  automatic provisioning
  9. Challenges >  service boundaries >  contracts and governance >  testing

    and refactoring >  fallacies of distributed systems >  support for a dozen technology stacks
  10. 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!
  11. 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
  12. 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!
  13. 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!
  14. 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!
  15. Principles >  lightweight concurrency >  asynchronous communication >  isolation > 

    error handling >  simple high-level language >  tools not solutions or products
  16. Erlang – the language >  high-level functional language >  prolog

    inspired syntax >  dynamically typed / safe >  pattern matching everywhere >  recursion >  immutable data and variables
  17. -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).!
  18. Concurrency >  millions of processes on one machine >  processes

    are isolated >  processes are used for everything: >  concurrency >  managing state >  parallelism >  no global data
  19. Message passing >  asynchronous >  primitives: >  fire & forget

    send >  selective receive >  more complex interactions can be built on top of these primitives
  20. -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. !
  21. Error handling >  avoid error checking code everywhere >  let

    it crash >  process based: >  link - bidirectional >  monitor - unidirectional >  supervision trees
  22. OTP >  helps creating: >  servers >  finites state machines

    >  event handler >  supervisors >  releases and upgrades
  23. Hot code loading >  module is unit of code handling

    >  exists in two variants: old and current >  controlled take over
  24. Instrumentation >  can trace almost everything: process events, send &

    receive messages, function calls >  process introspection: memory, mailbox, links, cur. function... >  interactive shell >  SNMP based OAM
  25. Summary >  everything you need for building highly concurrent, distributed,

    robust systems >  but not well suited for number crunching or maximum perfomance requirements
  26. 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!
  27. How they fit together >  Erlang / OTP has everything

    you need to build production-ready Microservices
  28. How they fit together >  fault tolerance / resilience > 

    async communication is the default >  amazing monitoring capabilites >  tools for upgrading / downgrading running systems