SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Downloaden Sie, um offline zu lesen
Erlang

“Software for a concurrent world”

        CWI Amsterdam

      Arjan Scherpenisse
      14 december 2012

    arjan@miraclethings.nl
Agenda
●   Intro
●   Language essentials
●   Concurrency / failure
●   OTP
●   VM / GC / optimisations / pitfalls
Erlang Philosophy
●   The world is concurrent
●   Things in the world dont share data
●   Things communicate with messages
●   Things fail


    - Joe Armstrong
Language essentials
Data types
●   Integer / float
●   Atoms
●   Tuples
●   Lists
●   Binaries

    … so where are strings?
Datatypes (cont)
●   Functions
●   Pids
●   Ports
Concurrency / failure
Concurrency
●   spawn, spawn_link
●   !, receive
Fundamental pieces
OTP: Open Telecom Platform
OTP
●   application
    –   Contains independent code, multiple applications
        per Erlang node
●   supervisor
    –   Supervises worker processes and supervisors
●   gen_server
    –   Basic work unit
GC / optimisation / pitfalls
Performance
●   Processes are cheap
●   Data copying is expensive
●   Handle much of request in single process
●   Cache locally in process dict
●   Reduce size of messages
●   Bigger binaries (> 64 bytes) are shared and reference
     counted, make use of them.
●   String processing is expensive
●   Keep eye on process inboxes
Garbage Collection
●   per process, no global gc sweep = no locking
     of vm
●   can specify per-process initial heap size
●   prevent big GCs
    ●   keep big data outside process
    ●   or in process dict
    ●   large binaries = external, use refcounting
Common Pitfalls
●   Message inbox overflowing
●   Atom table injection / crash
●   VM tweaks needed for
    –   nr of open file descriptors
    –   nr of processes
    –   heap size
Outro
What I mainly use it for
●   Full-stack web development
    –   http://zotonic.com/
●   HA backend systems


Preventing stuff like this →
:-)
Sources of Inspiration
●   Erlang - the ghetto
●   Intro to erlang (slideshare)
●   Erlang - message passing concurrency (slideshare)
●   Erlang concepts (slideshare)
●   Concurrency and Paralellism in Erlang (hopkins univ)
Thanks!


   Arjan Scherpenisse
 arjan@miraclethings.nl

http://twitter.com/acscherp
  http://miraclethings.nl/

Weitere ähnliche Inhalte

Andere mochten auch

Concurrent paradigms - Paralelism approaches
Concurrent paradigms - Paralelism approachesConcurrent paradigms - Paralelism approaches
Concurrent paradigms - Paralelism approachesJoel Corrêa
 
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency ProgrammingConcurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency ProgrammingSachintha Gunasena
 
Scalable Networking
Scalable NetworkingScalable Networking
Scalable Networkingl xf
 
Intro To Erlang
Intro To ErlangIntro To Erlang
Intro To Erlangasceth
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to ErlangRaymond Tay
 
Erlang Message Passing Concurrency, For The Win
Erlang  Message  Passing  Concurrency,  For  The  WinErlang  Message  Passing  Concurrency,  For  The  Win
Erlang Message Passing Concurrency, For The Winl xf
 
Erlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldErlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldZvi Avraham
 
Concurrent Open Source Software Development
Concurrent Open Source Software DevelopmentConcurrent Open Source Software Development
Concurrent Open Source Software Developmentartfulgeek
 
13 concurrency
13 concurrency13 concurrency
13 concurrencyjigeno
 
Intro to Erlang
Intro to ErlangIntro to Erlang
Intro to ErlangKen Pratt
 

Andere mochten auch (11)

Concurrent paradigms - Paralelism approaches
Concurrent paradigms - Paralelism approachesConcurrent paradigms - Paralelism approaches
Concurrent paradigms - Paralelism approaches
 
RubyOnRails
RubyOnRailsRubyOnRails
RubyOnRails
 
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency ProgrammingConcurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
 
Scalable Networking
Scalable NetworkingScalable Networking
Scalable Networking
 
Intro To Erlang
Intro To ErlangIntro To Erlang
Intro To Erlang
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to Erlang
 
Erlang Message Passing Concurrency, For The Win
Erlang  Message  Passing  Concurrency,  For  The  WinErlang  Message  Passing  Concurrency,  For  The  Win
Erlang Message Passing Concurrency, For The Win
 
Erlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldErlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent World
 
Concurrent Open Source Software Development
Concurrent Open Source Software DevelopmentConcurrent Open Source Software Development
Concurrent Open Source Software Development
 
13 concurrency
13 concurrency13 concurrency
13 concurrency
 
Intro to Erlang
Intro to ErlangIntro to Erlang
Intro to Erlang
 

Ähnlich wie Erlang: Software for a Concurrent world

NDC London 2014: Erlang Patterns Matching Business Needs
NDC London 2014: Erlang Patterns Matching Business NeedsNDC London 2014: Erlang Patterns Matching Business Needs
NDC London 2014: Erlang Patterns Matching Business NeedsTorben Hoffmann
 
All Aboard The Stateful Train
All Aboard The Stateful TrainAll Aboard The Stateful Train
All Aboard The Stateful TrainSmartLogic
 
Performance optimization techniques for Java code
Performance optimization techniques for Java codePerformance optimization techniques for Java code
Performance optimization techniques for Java codeAttila Balazs
 
Distributed systems and consistency
Distributed systems and consistencyDistributed systems and consistency
Distributed systems and consistencyseldo
 
A sip of elixir
A sip of elixirA sip of elixir
A sip of elixirUttam Kini
 
Distributed Erlang Systems In Operation
Distributed Erlang Systems In OperationDistributed Erlang Systems In Operation
Distributed Erlang Systems In OperationAndy Gross
 
Osdc 2011 michael_neale
Osdc 2011 michael_nealeOsdc 2011 michael_neale
Osdc 2011 michael_nealeMichael Neale
 
Benchmarks, performance, scalability, and capacity what's behind the numbers
Benchmarks, performance, scalability, and capacity what's behind the numbersBenchmarks, performance, scalability, and capacity what's behind the numbers
Benchmarks, performance, scalability, and capacity what's behind the numbersJustin Dorfman
 
Benchmarks, performance, scalability, and capacity what s behind the numbers...
Benchmarks, performance, scalability, and capacity  what s behind the numbers...Benchmarks, performance, scalability, and capacity  what s behind the numbers...
Benchmarks, performance, scalability, and capacity what s behind the numbers...james tong
 
Linux multiplexing
Linux multiplexingLinux multiplexing
Linux multiplexingMark Veltzer
 
Speeding up Page Load Times by Using Starling
Speeding up Page Load Times by Using StarlingSpeeding up Page Load Times by Using Starling
Speeding up Page Load Times by Using StarlingErik Osterman
 
Architecture of web servers
Architecture of web serversArchitecture of web servers
Architecture of web serversNicolas Vanhoren
 

Ähnlich wie Erlang: Software for a Concurrent world (20)

Introdução à Elixir
Introdução à ElixirIntrodução à Elixir
Introdução à Elixir
 
NDC London 2014: Erlang Patterns Matching Business Needs
NDC London 2014: Erlang Patterns Matching Business NeedsNDC London 2014: Erlang Patterns Matching Business Needs
NDC London 2014: Erlang Patterns Matching Business Needs
 
erlang 101
erlang 101erlang 101
erlang 101
 
All Aboard The Stateful Train
All Aboard The Stateful TrainAll Aboard The Stateful Train
All Aboard The Stateful Train
 
Cloud accounting software uk
Cloud accounting software ukCloud accounting software uk
Cloud accounting software uk
 
Web Scraping Basics
Web Scraping BasicsWeb Scraping Basics
Web Scraping Basics
 
Go fundamentals
Go fundamentalsGo fundamentals
Go fundamentals
 
Performance optimization techniques for Java code
Performance optimization techniques for Java codePerformance optimization techniques for Java code
Performance optimization techniques for Java code
 
Distributed systems and consistency
Distributed systems and consistencyDistributed systems and consistency
Distributed systems and consistency
 
A sip of elixir
A sip of elixirA sip of elixir
A sip of elixir
 
Threads and processes
Threads and processesThreads and processes
Threads and processes
 
Distributed Erlang Systems In Operation
Distributed Erlang Systems In OperationDistributed Erlang Systems In Operation
Distributed Erlang Systems In Operation
 
Osdc 2011 michael_neale
Osdc 2011 michael_nealeOsdc 2011 michael_neale
Osdc 2011 michael_neale
 
Concurrent programming
Concurrent programmingConcurrent programming
Concurrent programming
 
Benchmarks, performance, scalability, and capacity what's behind the numbers
Benchmarks, performance, scalability, and capacity what's behind the numbersBenchmarks, performance, scalability, and capacity what's behind the numbers
Benchmarks, performance, scalability, and capacity what's behind the numbers
 
Benchmarks, performance, scalability, and capacity what s behind the numbers...
Benchmarks, performance, scalability, and capacity  what s behind the numbers...Benchmarks, performance, scalability, and capacity  what s behind the numbers...
Benchmarks, performance, scalability, and capacity what s behind the numbers...
 
Linux multiplexing
Linux multiplexingLinux multiplexing
Linux multiplexing
 
Speeding up Page Load Times by Using Starling
Speeding up Page Load Times by Using StarlingSpeeding up Page Load Times by Using Starling
Speeding up Page Load Times by Using Starling
 
Architecture of web servers
Architecture of web serversArchitecture of web servers
Architecture of web servers
 
A Sip Of Elixir
A Sip Of ElixirA Sip Of Elixir
A Sip Of Elixir
 

Mehr von Arjan

Duo Disco - doing the Erlang dance
Duo Disco - doing the Erlang danceDuo Disco - doing the Erlang dance
Duo Disco - doing the Erlang danceArjan
 
De Naakte Noorderlingen
De Naakte NoorderlingenDe Naakte Noorderlingen
De Naakte NoorderlingenArjan
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceArjan
 
Zotonic tutorial EUC 2013
Zotonic tutorial EUC 2013Zotonic tutorial EUC 2013
Zotonic tutorial EUC 2013Arjan
 
Android workshop
Android workshopAndroid workshop
Android workshopArjan
 
Physical Computing with Android and IOIO
Physical Computing with Android and IOIOPhysical Computing with Android and IOIO
Physical Computing with Android and IOIOArjan
 
Zotonic presentation Erlang Camp Boston, august 2011
Zotonic presentation Erlang Camp Boston, august 2011Zotonic presentation Erlang Camp Boston, august 2011
Zotonic presentation Erlang Camp Boston, august 2011Arjan
 
Hello, world
Hello, worldHello, world
Hello, worldArjan
 
Mediamatic Night Lab #2
Mediamatic Night Lab #2Mediamatic Night Lab #2
Mediamatic Night Lab #2Arjan
 
Open-CI for beginners
Open-CI for beginnersOpen-CI for beginners
Open-CI for beginnersArjan
 
OBG Presentatie Mediamatic Salon
OBG Presentatie Mediamatic SalonOBG Presentatie Mediamatic Salon
OBG Presentatie Mediamatic SalonArjan
 

Mehr von Arjan (11)

Duo Disco - doing the Erlang dance
Duo Disco - doing the Erlang danceDuo Disco - doing the Erlang dance
Duo Disco - doing the Erlang dance
 
De Naakte Noorderlingen
De Naakte NoorderlingenDe Naakte Noorderlingen
De Naakte Noorderlingen
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & Performance
 
Zotonic tutorial EUC 2013
Zotonic tutorial EUC 2013Zotonic tutorial EUC 2013
Zotonic tutorial EUC 2013
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Physical Computing with Android and IOIO
Physical Computing with Android and IOIOPhysical Computing with Android and IOIO
Physical Computing with Android and IOIO
 
Zotonic presentation Erlang Camp Boston, august 2011
Zotonic presentation Erlang Camp Boston, august 2011Zotonic presentation Erlang Camp Boston, august 2011
Zotonic presentation Erlang Camp Boston, august 2011
 
Hello, world
Hello, worldHello, world
Hello, world
 
Mediamatic Night Lab #2
Mediamatic Night Lab #2Mediamatic Night Lab #2
Mediamatic Night Lab #2
 
Open-CI for beginners
Open-CI for beginnersOpen-CI for beginners
Open-CI for beginners
 
OBG Presentatie Mediamatic Salon
OBG Presentatie Mediamatic SalonOBG Presentatie Mediamatic Salon
OBG Presentatie Mediamatic Salon
 

Erlang: Software for a Concurrent world

  • 1. Erlang “Software for a concurrent world” CWI Amsterdam Arjan Scherpenisse 14 december 2012 arjan@miraclethings.nl
  • 2. Agenda ● Intro ● Language essentials ● Concurrency / failure ● OTP ● VM / GC / optimisations / pitfalls
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. Erlang Philosophy ● The world is concurrent ● Things in the world dont share data ● Things communicate with messages ● Things fail - Joe Armstrong
  • 9.
  • 10. Data types ● Integer / float ● Atoms ● Tuples ● Lists ● Binaries … so where are strings?
  • 11. Datatypes (cont) ● Functions ● Pids ● Ports
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 22. Concurrency ● spawn, spawn_link ● !, receive
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 34. OTP: Open Telecom Platform
  • 35.
  • 36. OTP ● application – Contains independent code, multiple applications per Erlang node ● supervisor – Supervises worker processes and supervisors ● gen_server – Basic work unit
  • 37. GC / optimisation / pitfalls
  • 38. Performance ● Processes are cheap ● Data copying is expensive ● Handle much of request in single process ● Cache locally in process dict ● Reduce size of messages ● Bigger binaries (> 64 bytes) are shared and reference counted, make use of them. ● String processing is expensive ● Keep eye on process inboxes
  • 39. Garbage Collection ● per process, no global gc sweep = no locking of vm ● can specify per-process initial heap size ● prevent big GCs ● keep big data outside process ● or in process dict ● large binaries = external, use refcounting
  • 40. Common Pitfalls ● Message inbox overflowing ● Atom table injection / crash ● VM tweaks needed for – nr of open file descriptors – nr of processes – heap size
  • 41.
  • 42.
  • 43. Outro
  • 44. What I mainly use it for ● Full-stack web development – http://zotonic.com/ ● HA backend systems Preventing stuff like this → :-)
  • 45.
  • 46.
  • 47. Sources of Inspiration ● Erlang - the ghetto ● Intro to erlang (slideshare) ● Erlang - message passing concurrency (slideshare) ● Erlang concepts (slideshare) ● Concurrency and Paralellism in Erlang (hopkins univ)
  • 48. Thanks! Arjan Scherpenisse arjan@miraclethings.nl http://twitter.com/acscherp http://miraclethings.nl/