An Introduction to Erlang

Similar documents
An Introduction to Erlang

An Introduction to Erlang

Thinking in a Highly Concurrent, Mostly-functional Language

2015 Erlang Solutions Ltd

Erlang 101. Google Doc

Programming Language Impact on the Development of Distributed Systems

FRANCESCO CESARINI. presents ERLANG/OTP. Francesco Cesarini Erlang

Implementing Riak in Erlang: Benefits and Challenges

Erlang. Joe Armstrong.

ERLANG EVOLVES FOR MULTI-CORE AND CLOUD ENVIRONMENTS

All you need is fun. Cons T Åhs Keeper of The Code

Erlang. Joe Armstrong

concurrent programming XXL

Erlang: distributed programming

Styling your Architecture in an Evolving Concurrent World

The do s and don ts of error handling. Joe Armstrong

Functional Programming In Real Life

CCNA 1 Chapter 7 v5.0 Exam Answers 2013

Robust Erlang (PFP Lecture 11) John Hughes

Polling Sucks. So what should we do instead?

The Actor Model applied to the Raspberry Pi and the Embedded Domain. The Erlang Embedded Project. Omer

Francesco Cesarini. Concurrency + Distribution = Availability + Scalability.

Programming Paradigms

The Actor Model applied to the Raspberry Pi and the Embedded Domain. Omer

Parallel Programming in Erlang (PFP Lecture 10) John Hughes

Erlang: An Overview. Part 2 Concurrency and Distribution. Thanks to Richard Carlsson for most of the slides in this part

An Introduction to Erlang

Profiling with Percept2. Huiqing Li and Simon Thompson EUC 2013

Programming Paradigms

Potential new case studies for behavioural types: Switching software systems

Lecture 8. Linda and Erlang

Scaling Erlang to 10,000 cores.!!! Simon Thompson, University of Kent

Experiments in OTP-Compliant Dataflow Programming

<Urban.Boquist. com> Rev PA

Erlang. An introduction. Paolo Baldan Linguaggi e Modelli per il Global Computing AA 2016/2017

Detecting and Visualising Process Relationships in Erlang

BEAMJIT: An LLVM based just-in-time compiler for Erlang. Frej Drejhammar

Erlang. Functional Concurrent Distributed Soft real-time OTP (fault-tolerance, hot code update ) Open. Check the source code of generic behaviours

Message-Passing Concurrency in Erlang

Erlang Programming Francesco Cesarini and Simon Thompson Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo

An Introduction to Erlang

Message Passing. Advanced Operating Systems Tutorial 7

Lecture 9. Part I. Overview of Message Passing. Communication Coupling. Decoupling Blackboard. Decoupling Broadcast. Linda and Erlang.

Erlang. Functional Concurrent Distributed Soft real-time OTP (fault-tolerance, hot code update ) Open. Check the source code of generic behaviours

Module : ServerIron ADX Packet Capture

MapReduce in Erlang. Tom Van Cutsem

20 Years of Commercial Functional Programming

Beautiful Concurrency with Erlang

Erlang and VoltDB TechPlanet 2012 H. Diedrich

An Introduction to Erlang. Richard Carlsson

Static rules of variable scoping in Erlang

Introduction to Erlang. Franck Petit / Sebastien Tixeuil

Erlang Programming for Multi-core

Starting the System & Basic Erlang Exercises

Chapter 7. The Transport Layer

The GSN node - a design example

BUILDING MICROSERVICES ON AZURE. ~ Vaibhav

Erlang and Concurrency. André Pang Rising Sun Research

Erlang. Types, Abstract Form & Core. Salvador Tamarit Muñoz. Universitat Politècnica de València

TCP /IP Fundamentals Mr. Cantu

Software Architecture

A Status Update of BEAMJIT, the Just-in-Time Compiling Abstract Machine. Frej Drejhammar and Lars Rasmusson

TRANSMISSION CONTROL PROTOCOL. ETI 2506 TELECOMMUNICATION SYSTEMS Monday, 7 November 2016

COSC441. Lecture 8 Introduction to Erlang

Layer 4: UDP, TCP, and others. based on Chapter 9 of CompTIA Network+ Exam Guide, 4th ed., Mike Meyers

Scenes From the Language Struggle in Toronto, Ontario. Mike Nolta

1. Introduction: Key Features of Erlang

ECE 650 Systems Programming & Engineering. Spring 2018

OSI Transport Layer. objectives

Virtual Security Gateway Overview

Distributed Object-Based Systems The WWW Architecture Web Services Handout 11 Part(a) EECS 591 Farnam Jahanian University of Michigan.

UNIT V. Computer Networks [10MCA32] 1

Cisco Nexus 1000V Switch for Microsoft Hyper-V

Distributed Systems Question Bank UNIT 1 Chapter 1 1. Define distributed systems. What are the significant issues of the distributed systems?

Cisco Unified Presence 8.0

DEMYSTIFYING BIG DATA WITH RIAK USE CASES. Martin Schneider Basho Technologies!

Introduction to Information Science and Technology 2017 Networking II. Sören Schwertfeger 师泽仁

Flexy Industrial IoT Router & Data gateway. Unlock your remote data. Think Flexy!

Tsig TSG3200 Data Sheet

Introduction to Distributed Systems

Scalable Streaming Analytics

ECE 358 Project 3 Encapsulation and Network Utilities

Cato Networks. Network Security as a Service

CCNA Exploration Network Fundamentals. Chapter 04 OSI Transport Layer

Lecture 7: February 10

Why Microsoft Azure is the right choice for your Public Cloud, a Consultants view by Simon Conyard

Carrier Ethernet Services Delivery

Designing for Scalability. Patrick Linskey EJB Team Lead BEA Systems

VMware Join the Virtual Revolution! Brian McNeil VMware National Partner Business Manager

Computer Security and Privacy

Cato Cloud. Software-defined and cloud-based secure enterprise network. Solution Brief

CAS 703 Software Design

ON-LINE EXPERT SUPPORT THROUGH VPN ACCESS

DISTRIBUTED SYSTEMS [COMP9243] Lecture 8a: Cloud Computing WHAT IS CLOUD COMPUTING? 2. Slide 3. Slide 1. Why is it called Cloud?

Transport Layer. <protocol, local-addr,local-port,foreign-addr,foreign-port> ϒ Client uses ephemeral ports /10 Joseph Cordina 2005

Sentinet for BizTalk Server SENTINET

MongooseIM - Messaging that Scales

System Wide Tracing User Need

Erlang functional programming in a concurrent world

Erlang functional programming in a concurrent world Johan Montelius and Vladimir Vlassov

Transcription:

Erlang Solutions Ltd An Introduction to Erlang From behind the trenches Erlang Factory Lite Zurich, April 23 rd 2012 Francesco Cesarini Founder, Technical Director @FrancescoC francesco@erlang-solutions.com

So Here I Am.

Telecom Applications: Issues Complex No down time Past Single-service networks Present Multiservice networks/client server Content Content Scalable Maintainable Distributed vs Cellular PLMN PSTN/ ISDN Services Data/ IP Networks CATV Communication applications Backbone Network Control Media Gateways Access Access Access Time to Market Access transport and switching networks Clients/applications

The Ancestors Languages like SmallTalk, Ada, Modula or Chill Functional languages like ML or Miranda Logical languages like Prolog

Erlang Highlights Declarative Concurrent Robust Distributed Hot code loading Functional programming language High abstraction level Pattern matching Concise readable programs Multicore Support OTP

Erlang Highlights: Factorial Factorial using Recursion Definition Implementation n! = 1 n*(n-1)! n = 0 n 1 -module(ex1). -export([factorial/1]). factorial(0) -> 1; factorial(n) when N >= 1 -> N * factorial(n-1). Eshell V5.0.1 (abort with ^G) 1> c(ex1). {ok,ex1} 2> ex1:factorial(6). 720

Erlang Highlights: High-level Constructs QuickSort using List Comprehensions -module(ex2). -export([qsort/1]). qsort([head Tail]) -> First = qsort([x X <- Tail, X =< Head]), Last = qsort([y Y <- Tail, Y > Head]), First ++ [Head] ++ Last; qsort([]) -> []. Eshell V5.0.1 (abort with ^G) 1> c(ex2). {ok,ex2} 2> ex2:qsort([7,5,3,8,1]). [1,3,5,7,8] "all objects Y taken from the list Tail, where Y > Head"

Erlang Highlights: High-level Constructs Parsing a TCP packet using the Bit Syntax << SourcePort:16, DestinationPort:16, SequenceNumber:32, AckNumber:32, DataOffset:4, _Reserved:4, Flags:8, WindowSize:16, Checksum:16, UrgentPointer:16, Payload/binary>> = Segment, OptSize = (DataOffset - 5)*32, << Options:OptSize, Message/binary >> = Payload, << CWR:1, ECE:1, URG:1, ACK:1, PSH:1, RST:1, SYN:1, FIN:1>> = <<Flags:8>>, %% Can now process the Message according to the %% Options (if any) and the flags CWR,..., FIN etc

Erlang Highlights Declarative Concurrent Robust Distributed Either transparent or explicit concurrency Light-weight processes Highly scalable Hot code loading Multicore Support OTP

Erlang Highlights: Concurrency Creating a new process using spawn -module(ex3). -export([activity/3]). activity(name,pos,size) -> activity(joe,75,1024) Pid = spawn(ex3,activity,[joe,75,1024])

Erlang Highlights: Concurrency Process creation time Microseconds/process 1,000 100 10 erlang java C# Source: Joe Armstrong SICS Number of processes 1 10 100 1,000 10,000 100,000

Erlang Highlights: Concurrency Processes communicate by asynchronous message passing Pid! {data,12,13} receive {start} -> {stop} -> {data,x,y} -> end

Erlang Highlights: Concurrency Message passing times Microseconds/message 100,000 10,000 1,000 100 10 erlang java C# Source: Joe Armstrong SICS Number of processes 1 1 10 100 1,000 10,000 100,000

Erlang Highlights Declarative Concurrent Robust Distributed Hot code loading Multicore Support OTP Simple and consistent error recovery Supervision hierarchies "Program for the correct case"

Erlang Highlights: Robustness Cooperating processes may be linked together using spawn_link(,, ) or link(pid)

Erlang Highlights: Robustness When a process terminates, an exit signal is sent to all linked processes and the termination is propagated

Erlang Highlights: Robustness Exit signals can be trapped and received as messages receive { EXIT,Pid,...} ->... end

Erlang Highlights: Robustness Robust systems can be built by layering Supervisors Workers

Erlang Highlights Declarative Concurrent Robust Distributed Explicit or transparent distribution Network-aware runtime system Hot code loading Multicore Support OTP

Erlang Highlights: Distribution C! Msg B! Msg Erlang Run-Time System Erlang Run-Time System network

Erlang Highlights: Distribution Simple Remote Procedure Call {rex, Node}! {self(), {apply, M, F, A}}, receive {rex, Node, What} -> What end loop() -> receive {From, {apply, M, F, A}} -> Answer = apply(m, F, A), From! {rex, node(), Answer} loop(); _Other -> loop() end.

Erlang Highlights Declarative Concurrent Robust Distributed Easily change code in a running system Enables non-stop operation Simplifies testing Hot code loading Multicore Support OTP

Erlang Highlights: Hot Code Swap Version 1 Version 2

Erlang Highlights Declarative Concurrent Robust Distributed Hot code loading SMP support provides linear scalability out of the box thanks to its no shared memory approach to concurrency. Multicore Support OTP

Ericsson s strategy with SMP Make it work -> measure -> optimize Hide the problems and awareness of SMP from the programmer Programmed in the normal style using processes for encapsulation and parallelisation

Multicore Erlang Erlang VM Scheduler #1 run queue Scheduler #2 run queue migration logic Scheduler #N run queue

Telephony Gateway Controller Traffic scenario IS/GCP 1slot/board IS/GEP Dual core One core running 2slots/board IS/GEP Dual core Two cores running 2slots/board AXD CPB5 AXD CPB6 POTS-POTS / AGW X call/sec 2.3X call/sec One core used 4.3X call/sec OTP R11_3 beta +patches 0.4X call/sec 2.1X call/sec ISUP-ISUP /Inter MGW 3.6X call/sec 7.7X call/sec One core used 13X call/sec OTP R11_3 beta +patches 1.55X call/sec 7.6X call/sec ISUP-ISUP /Intra MGW 5.5X call/sec 26X call/sec 3.17X call/sec 14X call/sec

Tilera Tile64 Chatty 500 processes created Each process randomly sends messages and receives a response from all other processes

Multicore Benchmark Big Bang Big_bang benchmark, 500 processes chatting Bound schedulers Default (unbound) (No Tilera-specific optimizations!) ca 0.4x @ 48 cores Erlang/OTP R13B on Tilera Pro 64-core

Erlang Highlights Declarative Concurrent Robust Distributed Hot code loading Provides the design patterns, libraries and tools to develop distributed fault tolerant systems. Multicore Support OTP

OTP Middleware Applications & Libraries System Design Principles T P

OTP: System Design Principles A set of abstract principles and design rules. They describe the software architecture of an Erlang System Needed so existing tools will be compatible with them Facilitate understanding of the system among teams A set of generic behaviours. Each behaviour is a formalisation of a design pattern Contains frameworks with generic code Solve a common problem Have built in support for debugging and software upgrade Facilitate understanding of the sub blocks in the system

Erlang Highlights Declarative Concurrent Robust Distributed Hot code loading Multicore Support OTP

I wrote my Erlang system in 4 weeks!

The Myths of Erlang. Is it Documented? Is the developer supporting it? What visibility does support staff have into what is going on? SNMP Live Tracing Audit Trails Statistics CLI / HTTP Interface How much new code was actually written?

Upgrades during runtime are Easy!

The Myths of Erlang. Yes, it is easy for Simple patches Adding functionality without changing the state Non backwards compatible changes need time time Database schema changes State changes in your processes Upgrades in distributed environments Test, Test, Test A great feature when you have the manpower!

We achieved 99.9999999 availability!

The Myths of Erlang. As a matter of fact, the network performance has been so reliable that there is almost a risk that our field engineers do not learn maintenance skills Bert Nilsson, Director NGS-Programs Ericsson Ericsson Contact, Issue 19 2002

The Myths of Erlang. 99,999 (Five Nines) is a more like it! Achieved at a fraction of the effort of Java & C++ Upgrades are risky! Non Software related issues Power Outages Network Failures, Firewall Configurations Hardware Faults

Who is using Erlang?

Erlang: It s Happening! CouchDB Distributed Robust document database Riak Distributed, partition tolerant and scalable database YAWS Yet Another Web Server RabbitMQ High performance enterprise messaging Ejabberd XMPP instant messaging server

erlang.org site usage (Unique visits, 30 days) 1 USA 19,483 2 Sweden 8,465 3 United Kingdom 4,984 4 China 4,897 5 Germany 4,745 6 Russia 4,465 7 France 2,722 8 Canada 2,647 9 India 2,299 10 Japan 2,261

Books

More Information Programming Erlang Software for a Concurrent World by Joe Armstrong Erlang Programming A Concurrent Approach to Software Development by Francesco Cesarini & Simon Thompson Erlang and OTP in Action Large-scale software design with OTP by Richard Carlsson, Martin Logan & Eric Merrit

2012 Erlang User Conference

Questions

Thank You! @FrancescoC on Twitter or francesco@erlang-solutions.com