erlang open telecom platform

35
Rev PA1 2003-12-01 1 Erlang Open Telecom Platform EAB/UPD/S Ulf Wiger

Upload: calida

Post on 13-Jan-2016

72 views

Category:

Documents


0 download

DESCRIPTION

Erlang Open Telecom Platform. EAB/UPD/S Ulf Wiger. Contents. Background The Erlang Language OTP The Erlang/OTP Test Server Experiences. History of Erlang. 1998: Open Source Erlang. How to design SW for future telecoms systems?. 1995: Several new projects. 1987: Early Erlang - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Erlang Open Telecom Platform

Rev PA1 2003-12-01 1

Erlang Open Telecom Platform

EAB/UPD/S Ulf Wiger

Page 2: Erlang Open Telecom Platform

Rev PA1 2003-12-01 2

Contents

• Background• The Erlang Language• OTP• The Erlang/OTP Test Server• Experiences

Page 3: Erlang Open Telecom Platform

Rev PA1 2003-12-01 3

History of Erlang

1984-86:ExperimentsprogrammingPOTS with several languages

1998:Open SourceErlang

1987:Early ErlangPrototype projects

1991:First fastimplementation

1993:DistributedErlang

1995:Severalnew projects

1996:Open Telecom PlatformAXD and GPRS started

How to design SW for futuretelecoms systems?

Page 4: Erlang Open Telecom Platform

Rev PA1 2003-12-01 4

Downloads since Open Source Launch ’98

0

20000

40000

60000

80000

100000

120000

140000

160000

180000

19

99

Q1

-2

19

99

Q3

-4

20

00

Q1

-2

20

00

Q3

-4

20

01

Q1

-2

20

01

Q3

-4

20

02

Q1

-2

20

02

Q3

-4

20

03

Q1

-2

20

03

Q3

-4

20

04

Q1

-2

Windows

Unix

Total (just OTP)

OTP+Wings

Overall

Linear (Total (just OTP))

Grouping: 6 months

Page 5: Erlang Open Telecom Platform

Rev PA1 2003-12-01 5

Erlang-based Products as of today

• Ericsson: AXD 301, GPRS, (NetSim), LCS

• Nortel: SSL Accelerator, SSL VPN gateway + others

• TMobile: IN applications• Vail Systems: Computer

Telephony Apps Service Prov.• Erlang Financial Systems:

Banking & Lottery systems• Mobile Arts: Presence &

Messaging for GSM/UMTS

• Synap.se: Billing & device configuration

• Blue Position: Bluetooth Location Information System

• Motivity: Answer Supervision Generator, Signalling Gateway

• Telia: CTI Platform• Corelatus: Signalling gateways

& cross-connects• Bluetail/TeleNordia: Robust

SMTP Mail Server• Univ. of Coruña: VoD Cluster

Page 6: Erlang Open Telecom Platform

Rev PA1 2003-12-01 6

Erlang Highlights

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

Functional programming languageHigh abstraction level

Pattern matchingConcise readable programs

Page 7: Erlang Open Telecom Platform

Rev PA1 2003-12-01 7

Erlang Highlights

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

Solid concurrency modelScales to handle complex

concurrencySimple abstractions

Examples...

Page 8: Erlang Open Telecom Platform

Rev PA1 2003-12-01 8

Erlang Example

Creating a new process using spawn

-module(ex3).-export([activity/3]).

activity(Name,Pos,Size) -> …………

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

Page 9: Erlang Open Telecom Platform

Rev PA1 2003-12-01 9

Erlang Example

Processes communicate by asynchronous message passing

Pid ! {data,12,13} receive {start} -> ……… {stop} -> ……… {data,X,Y} -> ………end

receive {start} -> ……… {stop} -> ……… {data,X,Y} -> ………end

Page 10: Erlang Open Telecom Platform

Rev PA1 2003-12-01 10

Erlang Examples 4

Concurrency - Finite State Machine

ringing_B_side(PidA) -> receive

{lim, offhook} -> lim:stop_ringing(), PidA ! {hc, {connect, self()}}, speech(PidA);{hc, {cancel, PidA}} -> cancel(PidA);{lim, {digit, _Digit}} -> ringing_B_side(PidA);{hc, {request_connection, Pid}} -> Pid ! {hc, {reject, self()}}, ringing_B_side(PidA)after 30000 -> cancel(PidA)

end.

Selective receive

True encapsulationof sub-states

Optional timeout

Asynchronoussend

Page 11: Erlang Open Telecom Platform

Rev PA1 2003-12-01 11

Erlang Highlights

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

Lightweight processesFast message passingResponse times in theorder of milliseconds

efficient garbage collection

Numbers...

Page 12: Erlang Open Telecom Platform

Rev PA1 2003-12-01 12

Process creation times (LOG/LOG scale)

10 100 1,000 10,000 100,000

Number of processes

1

10

100

1,000

Mic

rose

con

ds/

pro

cess

erlangjava

C#

Source:Joe ArmstrongSICS

> 200,000processes

Page 13: Erlang Open Telecom Platform

Rev PA1 2003-12-01 13

Message passing times (LOG/LOG scale)

10 100 1,000 10,000 100,000

Number of processes

1

10

1,000

100,000

Mic

rose

con

ds/

mes

sage

erlangjava

C#10,000

100

1Source:Joe ArmstrongSICS

> 200,000processes

Page 14: Erlang Open Telecom Platform

Rev PA1 2003-12-01 14

Erlang Highlights

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

Simple and consistenterror recovery

Supervision hierarchies"Program for the correct case"

Examples...

Page 15: Erlang Open Telecom Platform

Rev PA1 2003-12-01 15

Erlang Example

Cooperating processes may be linked together

usingspawn_link(…,…,…)orlink(Pid)

Page 16: Erlang Open Telecom Platform

Rev PA1 2003-12-01 16

Erlang Example

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

… and the termination is propagated

Page 17: Erlang Open Telecom Platform

Rev PA1 2003-12-01 17

Erlang Example

Exit signals can be trapped and received as messages

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

process_flag(trap_exit,true),...

Page 18: Erlang Open Telecom Platform

Rev PA1 2003-12-01 18

Erlang Example

Robust systems can be built by layering “Supervisors”

“Workers”

Page 19: Erlang Open Telecom Platform

Rev PA1 2003-12-01 19

Error-handling -- Language Safety

• No global variables -- fewer side-effects• No direct memory access -- no pointer errors• No malloc/free bugs• Solid concurrency model -- reduces synchronization

problems, reduces the state space (simpler programs)• Fault isolation -- memory-protected lightweight processes• Built-in error recovery support -- more consistency

Concurrency & Fault Tolerance were designedinto the language from the start!

Page 20: Erlang Open Telecom Platform

Rev PA1 2003-12-01 20

Debugging and Profiling Support

• Symbolic crash reports– Usually sufficient info to locate bugs within minutes

• Built-in trace support– Function calls (ability to filter on module name, function and args)– Messages (+ sequence trace)– Process events (context switch, spawn, link, exit)– Garbage collections– Optionally with timestamps (can be used for profiling, benchmarks)– Trace to process, file, or port (network socket)– Also available on live systems

Page 21: Erlang Open Telecom Platform

Rev PA1 2003-12-01 21

Erlang Highlights

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

Explicit or transparent distributionNetwork-aware runtime system

Examples...

Page 22: Erlang Open Telecom Platform

Rev PA1 2003-12-01 22

Transparent Distribution

Erlang Run-Time SystemErlang Run-Time System Erlang Run-Time SystemErlang Run-Time System

B ! Msg

network

C ! Msg

Message passing between processes in different computer is just as easy as between processes in the same computer

Page 23: Erlang Open Telecom Platform

Rev PA1 2003-12-01 23

Simple RPC

loop() -> receive {From, {apply, M, F, A}} -> Answer = (catch apply(M, F, A)), From ! {rex, node(), Answer} loop(); _Other -> loop() end.

{rex, Node} ! {self(), {apply, M, F, A}},receive {rex, Node, What} -> Whatend

{rex, Node} ! {self(), {apply, M, F, A}},receive {rex, Node, What} -> Whatend

{rex, Node} ! {self(), {apply, M, F, A}},receive {rex, Node, What} -> Whatend

loop() -> receive {From, {apply, M, F, A}} -> Answer = (catch apply(M, F, A)), From ! {rex, node(), Answer} loop(); _Other -> loop() end.

loop() -> receive {From, {apply, M, F, A}} -> Answer = (catch apply(M, F, A)), From ! {rex, node(), Answer} loop(); _Other -> loop() end.

loop() -> receive {From, {apply, M, F, A}} -> Answer = (catch apply(M, F, A)), From ! {rex, node(), Answer} loop(); _Other -> loop() end.

Page 24: Erlang Open Telecom Platform

Rev PA1 2003-12-01 24

Erlang Highlights

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

Easily change code in a running system

Enables non-stop operationSimplifies testing

Examples...

Page 25: Erlang Open Telecom Platform

Rev PA1 2003-12-01 25

Erlang Example

Version 1 Version 2

change_code

Page 26: Erlang Open Telecom Platform

Rev PA1 2003-12-01 26

Erlang Highlights

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

"Ports" to the outside worldbehave as Erlang processes

(c.f. UML ports)

Examples...

Page 27: Erlang Open Telecom Platform

Rev PA1 2003-12-01 27

Erlang Example

PortPort Externalprocess

Externalprocess

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

Page 28: Erlang Open Telecom Platform

Rev PA1 2003-12-01 28

Erlang Example

PortPort Externalprocess

Externalprocess

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

A port can use e.g. a TCP, UDP, SSL socket,UNIX pipe, or customtransport (e.g. SAAL)

Page 29: Erlang Open Telecom Platform

Rev PA1 2003-12-01 29

Erlang Highlights

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

Erlang runs on any UNIX,Windows, VxWorks, OSE Delta

Supports heterogeneousnetworks

Illustration...

Page 30: Erlang Open Telecom Platform

Rev PA1 2003-12-01 30

OTP ComponentsOTP Components

Standard LibrariesStandard Libraries

Erlang Run-Time SystemErlang Run-Time System

Hardware and Operating SystemHardware and Operating System

Applications written in Erlang

Applicationswritten in C,C++ or Java

Systems Overview

Page 31: Erlang Open Telecom Platform

Rev PA1 2003-12-01 31

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 + Client, FTP Client– SNMP Agent + ASN.1 Compiler– H.248– XML– ...

Page 32: Erlang Open Telecom Platform

Rev PA1 2003-12-01 32

OTP Behaviors

• "A formalization of design patterns"– A framework + generic code to solve a common problem– Built-in support for debugging 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_serverfor writing client-server applications– gen_event for writing event handlers– gen_fsm for finite state machine programming

Page 33: Erlang Open Telecom Platform

Rev PA1 2003-12-01 33

Principles of the OTP Test Server

Test server library

Adaptation library

Test suite

Erlang VM

Applicationbeing tested

erl

Applicationbeing tested

erl

erl

Applicationbeing tested

Corba, SNMP, ...

erlErlang rpc,"socket rpc",Corba, ...

Page 34: Erlang Open Telecom Platform

Rev PA1 2003-12-01 35

Experiences from Erlang in Large Projects

• Easy to build a first runnable application• Easy to debug• Easy to maintain• Very strong support for fault tolerance• Suitable for large systems/projects• Great for prototyping• Impressive performance/scalability in real applications• Outstanding tool for test automation• High programmer satisfaction

Page 35: Erlang Open Telecom Platform

Rev PA1 2003-12-01 36

Questions?