Erlang. Joe Armstrong.

Similar documents
Erlang. Joe Armstrong

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

Robust Erlang (PFP Lecture 11) John Hughes

Concurrency Oriented Programming in Erlang

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

Message Passing. Advanced Operating Systems Tutorial 7

Erlang 101. Google Doc

Erlang and Go (CS262a, Berkeley Fall 2016) Philipp Moritz

<Urban.Boquist. com> Rev PA

concurrent programming XXL

Functional Programming In Real Life

FRANCESCO CESARINI. presents ERLANG/OTP. Francesco Cesarini Erlang

20 Years of Commercial Functional Programming

An Introduction to Erlang

Programming Paradigms

Thinking in a Highly Concurrent, Mostly-functional Language

An Introduction to Erlang

ERLANG EVOLVES FOR MULTI-CORE AND CLOUD ENVIRONMENTS

Java Without the Jitter

Programming Language Impact on the Development of Distributed Systems

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

Programming Paradigms

An Introduction to Erlang

Reminder from last time

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

MODELS OF DISTRIBUTED SYSTEMS

Distributed Programming

Distributed Systems. The main method of distributed object communication is with remote method invocation

6.033 Lecture Fault Tolerant Computing 3/31/2014

Concurrent & Distributed Systems Supervision Exercises

Outline. Definition of a Distributed System Goals of a Distributed System Types of Distributed Systems

2015 Erlang Solutions Ltd

The Golden Trinity of Erlang How Something Simple Has Real Business Value

Distributed Systems. Overview. Distributed Systems September A distributed system is a piece of software that ensures that:

Erlang and Concurrency. André Pang Rising Sun Research

CSE 153 Design of Operating Systems Fall 2018

DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S. TANENBAUM MAARTEN VAN STEEN. Chapter 1. Introduction

Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads.

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

This is a talk given by me to the Northwest C++ Users Group on May 19, 2010.

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

Homework #2 Nathan Balon CIS 578 October 31, 2004

CSE 153 Design of Operating Systems

General Overview of Mozart/Oz

Distributed Systems. Before We Begin. Advantages. What is a Distributed System? CSE 120: Principles of Operating Systems. Lecture 13.

ZooKeeper & Curator. CS 475, Spring 2018 Concurrent & Distributed Systems

Erlang and VoltDB TechPlanet 2012 H. Diedrich

3C05 - Advanced Software Engineering Thursday, April 29, 2004

Beautiful Concurrency with Erlang

The Go Programming Language. Frank Roberts

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2002

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

Operating Systems (ECS 150) Spring 2011

CS 167 Final Exam Solutions

The case for reactive objects

Overview. Rationale Division of labour between script and C++ Choice of language(s) Interfacing to C++

Two Phase Commit Protocol. Distributed Systems. Remote Procedure Calls (RPC) Network & Distributed Operating Systems. Network OS.

Establishing the overall structure of a software system

RMI & RPC. CS 475, Spring 2019 Concurrent & Distributed Systems

Architectural Design. Topics covered. Architectural Design. Software architecture. Recall the design process

MODELS OF DISTRIBUTED SYSTEMS

Distributed Systems Principles and Paradigms. Chapter 01: Introduction. Contents. Distributed System: Definition.

Processor speed. Concurrency Structure and Interpretation of Computer Programs. Multiple processors. Processor speed. Mike Phillips <mpp>

Distributed Systems Principles and Paradigms. Chapter 01: Introduction

Threads. CS-3013 Operating Systems Hugh C. Lauer. CS-3013, C-Term 2012 Threads 1

Performance Matters Scaling Integration Processes to Meet the Needs of Your Business. James Ahlborn, Chief Software Architect, Dell Boomi

Remote Procedure Call. Tom Anderson

Database management system Prof. D. Janakiram Department of Computer Science and Engineering Indian Institute of Technology, Madras

The Google File System

Styling your Architecture in an Evolving Concurrent World

Distributed Systems. 09. State Machine Replication & Virtual Synchrony. Paul Krzyzanowski. Rutgers University. Fall Paul Krzyzanowski

Engineering Robust Server Software

6.830 Lecture Recovery 10/30/2017

MITOCW ocw apr k

Distributed KIDS Labs 1

Distributed Systems. Prof. Dr. Schahram Dustdar Distributed Systems Group Vienna University of Technology. dsg.tuwien.ac.

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 21: Network Protocols (and 2 Phase Commit)

6.830 Lecture Recovery 10/30/2017

Distributed Systems. Lec 10: Distributed File Systems GFS. Slide acks: Sanjay Ghemawat, Howard Gobioff, and Shun-Tak Leung

1/10/16. RPC and Clocks. Tom Anderson. Last Time. Synchroniza>on RPC. Lab 1 RPC

(Refer Slide Time: 1:26)

Introduction. Distributed Systems IT332

Scala Actors. Scalable Multithreading on the JVM. Philipp Haller. Ph.D. candidate Programming Methods Lab EPFL, Lausanne, Switzerland

CA464 Distributed Programming

The Actor Model, Part Two. CSCI 5828: Foundations of Software Engineering Lecture 18 10/23/2014

Erlang: distributed programming

Mei Nagappan. How the programmer wrote it. How the project leader understood it. How the customer explained it. How the project leader understood it

CS October 2017

PROCESSES AND THREADS

The HALFWORD HEAP EMULATOR

A Reliable Broadcast System

Understanding Hardware Transactional Memory

Lecture 21 Concurrent Programming

Introduction to Distributed Data Systems

Distributed Transaction Management 2003

A History of the Erlang VM

Creating User-Friendly Exploits

Multithreading and Interactive Programs

6.001 Notes: Section 1.1

Overview. Rationale Division of labour between script and C++ Choice of language(s) Interfacing to C++ Performance, memory

Transcription:

Erlang Joe Armstrong joe.armstrong@ericsson.com 1

Who is Joe? Inventor of Erlang, UBF, Open Floppy Grid Chief designer of OTP Founder of the company Bluetail Currently Software Architect Ericsson Current Interests Concurrency oriented programming Peer-to-peer architectures Grid computing Functional programming 2

The world is concurrent but we program in sequential languages 3

This is AMAZINGLY DIFFICULT 4

but if we program in a concurrent language it becomes 5

Really Easy 6

Concurrency Oriented programming A style of programming where concurrency is used to structure the application Large numbers of processes Complete isolation of processes No sharing of data Location transparency Pure message passing My first message is that concurrency is best regarded as a program structuring principle. Structured concurrent programming - Tony Hoare Redmond July 2001 7

What is COP? Machine Process Message Large number of processes Complete isolation between processes Location transparency No Sharing of data Pure message passing systems 8

Why is COP nice? We intuitively understand concurrency The world is parallel The world is distributed Making a real-world application is based on observation of the concurrency patterns and message channels in the application Easy to make scalable, distributed applications 9

What is Erlang/OTP? Erlang = Concurrent Programming Language with a functional core OTP = a set of library routines callable by Erlang for writing fault-tolerant distributed applications 10

What is Erlang good for? Programming distributed applications Programming fault-tolerant applications Programming applications with large numbers of parallel processes 11

Web server Plot of throughput (in 100 Kbytes/Sec) vs. # parallel connections in simulated denial of service attack Red = YAWS (NFS) Green = Apache (NFS); Blue=Apache(local disk) Apache dies at 4000 parallel sessions See http://www.sics.se/~joe/apachevsyaws.html 12

Once upon a time... 1986 Pots Erlang (in Prolog) 1987 ACS/Dunder 1988 Erlang -> Strand (fails) 1989 JAM (Joe's abstract machine) 1990 Erlang syntax changes (70x faster) 1991 Distribution 1992 Mobility Server 1993 Erlang Systems AB 1995 AXE-N collapses. AXD starts 1996 OTP starts 1998 AXD deployed. Erlang Banned. Open Source Erlang. Bluetail formed 1999 BMR sold 2000 Alteon buys Blutail. Nortel buys Alteon 2002 UBF. Concurrency Oriented Programming 2003 Ph.D. Thesis - Making reliable systems 13

History Erlang is an Ericsson secret Erlang is too slow Erlang is banned Erlang escapes (Open source) Erlang infects Nortel... Erlang controls the world 14

Why should I learn yet another programming language? Because it's fun... Because we can write beautiful program in it Because my boss told me to Because we can develop products quicker in it Because it solves certain technical problems 15

If Erlang is the solution what is the problem? How do we make reliable systems from components which fail? 16

How do we correct hardware failures? Replicate the hardware How do we correct software errors? Having two identical copies of the software won't work both will fail at the same time and for the same reason Why does your computer crash? Which fails more often, hardware or software? 17

Problem domain Highly concurrent (hundreds of thousands of parallel activities) Real time Distributed High Availability (down times of minutes/year never down) Complex software (million of lines of code) Continuous operation (years) Continuous evolution In service upgrade 18

How do we make systems? Systems are made of black boxes (components) Black boxes execute concurrently Black boxes communicate How the black box works internally is irrelevant Failures inside one black box should not crash another black box 19

System requirements R1. Concurrency processes R2. Error encapsulation isolation R3. Fault detection what failed R4. Fault identification why it failed R5. Live code upgrade evolving systems R6. Stable storage crash recovery 20

Isolation. Hardware components operate concurrently are isolated and communicate by message passing 21

Consequences of Isolation Processes have share nothing semantics and data must be copied Message passing is the only way to exchange data Message passing is asynchronous 22

GOOD STUFF Processes Copying Message passing 23

BAD STUFF Threads Sharing Mutexes Synchronized methods 24

Language My program should not be able to crash your program Need strong isolation and concurrency Processes are OK threads are not (threads have shared resources) Can't use OS processes (Heavy semantics depends on OS) 25

Isolation My program should not be able to crash your program. This is the single most important property that a system component must have All things are not equally important 26

Java doesn't work...the only safe way to execute multiple applications, written in the Java programming language, on the same computer is to use a separate JVM for each of them, and to execute each JVM in a separate OS process. This introduces various inefficiencies in resource utilization, which downgrades performance, scalability, and application startup time. The benefits the language can offer are thus reduced mainly to portability and improved programmer productivity. Granted these are important, but the full potential of language-provided safety is not realized. Instead there exists a curious distinction between ``language safety,'' and ``real safety''.... tasks cannot directly share objects, and that the only way for tasks to communicate is to use standard, copying communication mechanisms - Czajkowski, and Daynes,Sun Microsystems 27

Nor does C and C++ No processes (OS has processes but not C or C++) Terrible isolation pointers etc. Non-portable (word sizes,big-/little-endian problems) No GC 28

But Erlang works Lightweight processes (lighter than OS threads) Good isolation (not perfect yet...) Programs never loose control Error detection primitives Reason for failure is known Exceptions Garbage collected memory Lots of processes Functional Agner Krarup Erlang (1878-1929) 29

Erlang You can create a parallel process Pid = spawn(fun() ->... end). then send it a message Pid! Msg It typically takes 1 microsecond to create a process or send a message and then wait for a reply receive {Pid, Rely} -> Actions end Processes are isolated 30

Programming for Failure Let it crash If you can't do what you are supposed to do crash as soon as possible don't make matters worse by trying to fix the errors. Let some other process fix the error 31

Let some other process fix the error To do fault-tolerant computing you need at least TWO computers Error Computer1 Computer2 {'EXIT', Computer2, Reason} Computer1 Which means you can't share data 32

Programming for errors If you can't do what you want to do try and do something simpler Links Supervisor Workers The supervisor monitors the workers and restarts them if they fail 33

A supervision hierarchy Links Supervisor Supervisor and worker Links Workers Workers 34

OTP behaviours Generic libraries for building components of a real-time system. Includes Client-server Finite State machine Supervisor Event Handler Applications Systems 35

Following or leading? How can we make world class exciting innovative products using exactly the same technology as everybody else? You can't you must do something different If you use the same techniques as everybody else (Java, C, C++, UML) you should achieve the same results as everybody else) Doing something different involves risk. But You either win or you loose Either way, you learn and you have fun If you loose you try again 36

Erlang success stories Ericsson AXD301 Ericsson GPRS system Alteon (Nortel) SSL accelerator Alteon (Nortel) SSL VPN Teba Bank (credit card system South Africa) T-mobile SMS system (UK) Open Poker - 27K Games, 137K Players, 800K processes on one laptop 37

AXD301 ATM switch 11% of world market 99.9999999 % reliability (9 nines) 30-40 Million calls/week World's larges telephony over ATM network 1.7 million lines of Erlang 38

39

40 31 ms. / year

SSL Accelerator Market leader 48% of world market (2002) 41

Projects 28 projects at sourceforge YAWS (Yet another web server) Eddie (Cluster/load balancer) WAP gateway Wings (3-D graphics modelling) 3D gameing 72 Projects in Jungerl 42