erlang open telecom platform

Post on 13-Jan-2016

72 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

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

Rev PA1 2003-12-01 1

Erlang Open Telecom Platform

EAB/UPD/S Ulf Wiger

Rev PA1 2003-12-01 2

Contents

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

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?

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

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

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

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

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)

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

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

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

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

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

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

Rev PA1 2003-12-01 15

Erlang Example

Cooperating processes may be linked together

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

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

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),...

Rev PA1 2003-12-01 18

Erlang Example

Robust systems can be built by layering “Supervisors”

“Workers”

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!

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

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

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

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.

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

Rev PA1 2003-12-01 25

Erlang Example

Version 1 Version 2

change_code

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

Rev PA1 2003-12-01 27

Erlang Example

PortPort Externalprocess

Externalprocess

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

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)

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

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

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

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

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

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

Rev PA1 2003-12-01 36

Questions?

top related