concurrent functional programming with erlang and otp open telecom platform l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Concurrent Functional Programming with Erlang and OTP ( Open Telecom Platform ) PowerPoint Presentation
Download Presentation
Concurrent Functional Programming with Erlang and OTP ( Open Telecom Platform )

Loading in 2 Seconds...

play fullscreen
1 / 49

Concurrent Functional Programming with Erlang and OTP ( Open Telecom Platform ) - PowerPoint PPT Presentation


  • 311 Views
  • Uploaded on

Concurrent Functional Programming with Erlang and OTP ( Open Telecom Platform ). Bjarne Däcker <bjarne@erix.ericsson.se> Computer Science Laboratory Ericsson Utvecklings AB Acknowledgements Thomas Arts <thomas@erix.ericsson.se> Hans Nilsson <hans@erix.ericsson.se>

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Concurrent Functional Programming with Erlang and OTP ( Open Telecom Platform )' - Albert_Lan


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
concurrent functional programming with erlang and otp open telecom platform

Concurrent Functional Programming with Erlang and OTP (Open Telecom Platform)

Bjarne Däcker <bjarne@erix.ericsson.se>Computer Science Laboratory

Ericsson Utvecklings AB

Acknowledgements

Thomas Arts <thomas@erix.ericsson.se>

Hans Nilsson <hans@erix.ericsson.se>

Torbjörn Keisu <torbjorn.keisu@ericsson.com>

Ulf Wiger <ulf.wiger@ericsson.com>

the setting
The setting
  • 1995 PC Week Study of software projects:
    • 16% successful
    • 53% operational (but less than successful)
    • 31% cancelled
  • Butler Group 1997 on large software projects
    • 5 out of 6 large projects fail
    • In >$300M companies, 9 out of 10 large projects fail
  • How to approach this?
    • Use high-level modeling tools & generate code?
    • Raise the level of programming language?
    • Fight all causes for project failure!
telecom industry

Telecom industry

Switches, routers,

base-stations

Networks

Mobile telephones

slide4

Requirements on a Programming Technology for Telecommunication Switching Systems

Massive concurrency

Soft realtime

Distribution

Interaction with hardware

Very large software systems

Complex functionality

Continuous operation for many years

Software maintenance without stopping the system

Stringent quality and reliability requirements

Fault tolerance errors

history of erlang
History of Erlang

No language well suited

for telecom systems

development

1984:

Ericsson

Computer

Science Lab

formed

1998:

Open Source

Erlang

1991:

First fast

implementation

1987:

Early Erlang

Prototype projects

1984-86:

Experiments

programming

POTS with

several languages

1996:

Open Telecom Platform

(research on verification...)

1995:

Several

new projects

1993:

Distributed

Erlang

the ancestry of erlang

Concurrent systems programming languages like Ada, Modula or Chill

Functional programming languages like ML or Miranda

The Ancestry of Erlang

Concurrent functional programming language Erlang

erlang highlights
Erlang Highlights

Functional programming language

High abstraction level

Pattern matching

Concise readable programs

  • Declarative
  • Concurrency
  • Soft real-time
  • Robustness
  • Distribution
  • Hot code loading
  • External interfaces
  • Portability
erlang example

Definition

Implementation

-module(ex1).

-export([factorial/1]).

factorial(0) ->

1;

factorial(N) when N >= 1 ->

N * factorial(N-1).

1

n*(n-1)!

n = 0

n 1

n! =

Eshell V5.0.1 (abort with ^G)

1> c(ex1).

{ok,ex1}

2> ex1:factorial(6).

720

Erlang Example

Basics - Factorial function

erlang example9

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]

Erlang Example

A few very high-level constructs - QuickSort

-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([]) ->

[].

"all objects Y

taken from the list Tail,

where Y > Head"

erlang highlights10
Erlang Highlights

Either transparent or

explicit concurrency

Light-weight processes

Highly scalable

  • Declarative
  • Concurrency
  • Soft real-time
  • Robustness
  • Distribution
  • Hot code loading
  • External interfaces
  • Portability
erlang example11

activity(Joe,75,1024)

Erlang Example

Creating a new process using spawn

-module(ex3).

-export([activity/3]).

activity(Name,Pos,Size) ->

…………

Pid = spawn(ex3,activity,[Joe,75,1024])

erlang example12
Erlang Example

Processes communicate by asynchronous

message passing

receive

{start} -> ………

{stop} -> ………

{data,X,Y} -> ………

end

receive

{start} -> ………

{stop} -> ………

{data,X,Y} -> ………

end

Pid ! {data,12,13}

erlang example13
Erlang Example

Concurrency - Finite State Machine

Selective receive

ringing_a(A, B) ->

receive

{A, on_hook} ->

back_to_idle(A, B);

{B, answered} ->

A ! {stop_tone, ring},

switch ! {connect, A, B},

conversation_a(A, B)

after 30000 ->

back_to_idle(A, B)

end.

back_to_idle(A, B) ->

A ! {stop_tone, ring},

B ! terminate,

idle(A).

Asynchronous send

Optional timeout

erlang highlights14
Erlang Highlights

Response times in the

order of milliseconds

Per-process garbage collection

  • Declarative
  • Concurrency
  • Soft real-time
  • Robustness
  • Distribution
  • Hot code loading
  • External interfaces
  • Portability
erlang highlights15
Erlang Highlights

Simple and consistent

error recovery

Supervision hierarchies

"Program for the correct case"

  • Declarative
  • Concurrency
  • Soft real-time
  • Robustness
  • Distribution
  • Hot code loading
  • External interfaces
  • Portability
erlang example16
Erlang Example

Cooperating processes may be linked together

using

spawn_link(…,…,…)

or

link(Pid)

erlang example17
Erlang Example

When a process terminates, an exit signal is sent to all linked processes

… and the termination is propagated

erlang example18
Erlang Example

Exit signals can be trapped and received as messages

receive

{‘EXIT’,Pid,...} -> ...

end

erlang example19
Erlang Example

Robust systems can be built by layering

“Supervisors”

“Workers”

erlang highlights20
Erlang Highlights

Explicit or transparent distribution

Network-aware runtime system

  • Declarative
  • Concurrency
  • Soft real-time
  • Robustness
  • Distribution
  • Hot code loading
  • External interfaces
  • Portability
transparent distribution
Transparent Distribution

B ! Msg

C ! Msg

Erlang Run-Time System

Erlang Run-Time System

network

simple rpc
Simple RPC

{rex, Node} ! {self(), {apply, M, F, A}},

receive

{rex, Node, What} -> What

end

{rex, Node} ! {self(), {apply, M, F, A}},

receive

{rex, Node, What} -> What

end

{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.

loop() ->

receive

{From, {apply, M, F, A}} ->

Answer = apply(M, F, A),

From ! {rex, node(), Answer}

loop();

_Other -> loop()

end.

loop() ->

receive

{From, {apply, M, F, A}} ->

Answer = apply(M, F, A),

From ! {rex, node(), Answer}

loop();

_Other -> loop()

end.

loop() ->

receive

{From, {apply, M, F, A}} ->

Answer = apply(M, F, A),

From ! {rex, node(), Answer}

loop();

_Other -> loop()

end.

erlang highlights23
Erlang Highlights

Easily change code in a

running system

Enables non-stop operation

Simplifies testing

  • Declarative
  • Concurrency
  • Soft real-time
  • Robustness
  • Distribution
  • Hot code loading
  • External interfaces
  • Portability
erlang example24
Erlang Example

Version 1

Version 2

erlang highlights25
Erlang Highlights

"Ports" to the outside world

behave as Erlang processes

  • Declarative
  • Concurrency
  • Soft real-time
  • Robustness
  • Distribution
  • Hot code loading
  • External interfaces
  • Portability
erlang example26
Erlang Example

External

process

Port

Port ! {self(), {command, [1,2,3]}}

erlang example27
Erlang Example

External

process

Port

receive{Port, {data, Info}} ->end

erlang highlights28
Erlang Highlights

Erlang runs on any UNIX,

Windows, VxWorks, ...

Supports heterogeneous

networks

  • Declarative
  • Concurrency
  • Soft real-time
  • Robustness
  • Distribution
  • Hot code loading
  • External interfaces
  • Portability
systems overview
Systems Overview

Applications written

in Erlang

Applications

written in C,

C++ or Java

OTP Components

Standard Libraries

Erlang Run-Time System

Hardware and Operating System

erlang otp
Erlang/OTP
  • Open Telecom Platform
  • Middleware for Erlang development
  • Designed for fault tolerance and portability
  • Behaviors: A formalization of design patterns
  • Components
    • Error handling, reporting and logging
    • Mnesia, distributed real-time database management system
    • CORBA
    • IDL Compiler, Java & C Interface Support
    • HTTP Server
    • SNMP Agent
    • ...
otp behaviors
OTP Behaviors
  • "A formalization of design patterns"
    • A behavior is a framework + generic code to solve a common problem
    • Each behavior has built-in support fordebugging and software upgrade
    • Makes it easier to reason about the behavior of a program
  • Examples of OTP behaviors
    • application defines how an application is implemented
    • supervisor used to write fault-tolerant supervision trees
    • gen_server for writing client-server applications
    • gen_event for writing event handlers
    • gen_fsm for finite state machine programming
the standard textbook
The standard textbook

Joe Armstrong, Robert Virding, Claes Wikström and Mike Williams, Concurrent Programming in Erlang, Prentice Hall, 1996,2nd edition, ISBN 0-13-508301-X

interesting web pages
Interesting web pages

Open source Erlang

www.erlang.org

Commercial Erlang

www.erlang.se

French Erlang site

www.erlang-fr.org

slide37
AXD 301: A Telephony-Class, scalable (10-160 GBps) ATM switchdesigned from scratch in less than 3 years
  • AXD 301 Success factors:
    • Highly pragmatic, holistic approach
    • Competent organisation
    • Efficient process
    • Excellent technology (e.g. Erlang/OTP)
  • More than just technology...
    • Consider all factors together from the start
    • Erlang was a perfect match for our approach
axd 301 in the marketplace
AXD 301 in the marketplace

ENGINE:

Migrating today's vertical networks

into a single multi-service backbone

  • Central component in Ericsson's ENGINE offering
  • Several major operators
    • British Telecom
    • Vodaphone
    • Worldcom
    • Telia
    • Diveo
    • ...
briefly about the term carrier class
Briefly about the term Carrier-Class
  • To us, "Carrier-Class", "Telephony-Class" and"Telecom Profile" are synonymous
  • The quality we've come to expectfrom public telephony networks
  • The trend towards multimedia servicesrequires Carrier-Class in more systems
  • More than just duplication of hardware:
    • Fault-tolerant software
    • In-service hardware expansion
    • In-service software upgrade
    • Load tolerance
    • Flexibility (frequent changes + long service life)
  • Target: 99,999% ("five nines") availability, including planned outages

There's no such thing

as "almost Carrier-Class"!

telecom class system architecture

simple wire-speed logic

complex soft-real-time logic

ATB

ATB

ATB

ATB

Telecom-Class System Architecture

Control Processors

LineTermination

ATM Termination

CP

IO

ATM

Mandatory Mated Processor Pair

Switch Core

CP

IO

CE

FR

IO

CP

Optional Processors

Server Device

L3F

CP

IO

Clock &

Synchronization

Device Processor

on Each Board

programming languages control system
Programming languages (control system)
  • Erlang: ca 1 million lines of code
    • Nearly all the complex control logic
    • Operation & Maintenance
    • Web server and runtime HTML/JavaScript generation
  • C/C++: ca 500k lines of code
    • Third party software
    • Low-level protocol drivers
    • Device drivers
  • Java: ca 13k lines of code
    • Operator GUI applets
experiences from axd 301 sw design
Experiences from AXD 301 SW Design
  • Using Erlang in Complex Systems
    • Fits very well with the incremental design method
    • High programmer satisfaction
    • Outstanding support for robustness and concurrency
    • Very few side-effects  easier to add/change single components
    • Small directed teams can achieve impressive results
  • Productivity estimates
    • Similar line/hour programmer productivity
    • 4-10 fewer lines of source code (compared to C/C++, Java, PLEX)
      • 4-10x higher programmer productivity
    • Similar number of faults per 1000 lines of source code
      • 4-10x higher quality
slide43
Functional Requirements
    • Use cases (in telecom “traffic cases”)
    • User interfaces
    • ...
  • Non-functional Requirements
    • Code updating without interrupting the service
    • Distribution over several processors
    • Automatic handover upon error
    • Limited restart time
    • ...
  • The non-functional requirements are often much trickier to handle and require technology bottom-up rather than analysis top-down.
efficient program development
Efficient Program Development

Requirements

  • Interaction with the real environment
  • Powerful and appropriate abstraction mechanisms
  • Efficient implementation
  • Useful tools

Ideas

Prototyping

Productification

a simple erlang xml document

Erlang

{‘home.page’, [{title, “My Home Page”}],

[{title, “Welcome to My Home Page”},

{text,

[{para,

“Sorry, this home page is still under ”

“construction. Please come back soon!”}

]}

]}.

A Simple Erlang-XML Document

XML

<?xml version=“1.0”?>

<home.page title=“My Home Page”>

<title>

Welcome to My Home Page

</title>

<text>

<para>

Sorry, this home page is still under

construction. Please come back soon!

</para>

</text>

</home.page>

Almost equivalent

erlang summary
Erlang Summary
  • Declarative
    • Compact code
  • Concurrency
    • Light-weight processes
    • Message passing
  • Soft real-time
  • Robustness
    • Process supervision
    • Error trapping
  • Distribution
  • Hot code loading
  • External interfaces
    • To hardware and other languages
  • Portability

www.erlang.org

www.erlang.se

the research continues
The Research Continues ...
  • HiPE - High Performance Erlang (Uppsala, Astec)
  • ETOS - Erlang to Scheme (Montréal)
  • Erlang Verification (SICS, Astec)
  • Type System (Glasgow)
  • “Safe” Erlang (Canberra)
  • Specification Techniques (Aachen)
  • Erlang Processor (Ericsson CADLab)
  • ...
slide49

Welcome to the next EUC

September 27, 2001

Älvsjö. Stockholm

www.erlang.se

Combined with IFL - International

Workshop on the Implementation

of Functional Languages

September 24-26, 2001

Älvsjö. Stockholm