Title: Erlang Open Telecom Platform
1Erlang Open Telecom Platform
2Contents
- Background
- The Erlang Language
- OTP
- The Erlang/OTP Test Server
- Experiences
3History of Erlang
1998 Open Source Erlang
How to design SW for futuretelecoms systems?
1995 Several new projects
1987 Early Erlang Prototype projects
1996 Open Telecom Platform AXD and GPRS started
1984-86 Experiments programming POTS with
several languages
1993 Distributed Erlang
1991 First fast implementation
4Downloads since Open Source Launch 98
Grouping 6 months
5Erlang-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
6Erlang 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
7Erlang Highlights
Solid concurrency modelScales to handle
complexconcurrencySimple abstractions
- Declarative
- Concurrency
- Soft real-time
- Robustness
- Distribution
- Hot code loading
- External interfaces
- Portability
8Erlang Example
Creating a new process using spawn
-module(ex3). -export(activity/3). activity(Nam
e,Pos,Size) -gt
Pid spawn(ex3,activity,Joe,75,1024)
9Erlang Example
Processes communicate by asynchronous message
passing
receive start -gt stop -gt
data,X,Y -gt end
receive start -gt stop -gt
data,X,Y -gt end
Pid ! data,12,13
10Erlang Examples 4
Concurrency - Finite State Machine
Selective receive
ringing_B_side(PidA) -gt receive lim,
offhook -gt limstop_ringing(), PidA !
hc, connect, self(), speech(PidA) hc,
cancel, PidA -gt cancel(PidA) lim,
digit, _Digit -gt ringing_B_side(PidA) h
c, request_connection, Pid -gt Pid ! hc,
reject, self(), ringing_B_side(PidA) afte
r 30000 -gt cancel(PidA) end.
True encapsulationof sub-states
Asynchronoussend
Optional timeout
11Erlang Highlights
Lightweight processesFast message
passingResponse times in the order of
milliseconds efficient garbage collection
- Declarative
- Concurrency
- Soft real-time
- Robustness
- Distribution
- Hot code loading
- External interfaces
- Portability
12Process creation times (LOG/LOG scale)
gt 200,000processes
Source Joe Armstrong SICS
13Message passing times (LOG/LOG scale)
gt 200,000processes
Source Joe Armstrong SICS
14Erlang 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
15Erlang Example
Cooperating processes may be linked together
using spawn_link(,,) or link(Pid)
16Erlang Example
When a process terminates, an exit signal is sent
to all linked processes
and the termination is propagated
17Erlang Example
Exit signals can be trapped and received as
messages
process_flag(trap_exit,true),...
receive EXIT,Pid,... -gt ... end
18Erlang Example
Robust systems can be built by layering
Supervisors
Workers
19Error-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!
20Debugging 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
21Erlang Highlights
Explicit or transparent distribution Network-aware
runtime system
- Declarative
- Concurrency
- Soft real-time
- Robustness
- Distribution
- Hot code loading
- External interfaces
- Portability
22Transparent Distribution
B ! Msg
C ! Msg
Erlang Run-Time System
Erlang Run-Time System
network
Message passing between processes in different
computer is just as easy as between processes in
the same computer
23Simple RPC
rex, Node ! self(), apply, M, F,
A, receive rex, Node, What -gt What end
rex, Node ! self(), apply, M, F,
A, receive rex, Node, What -gt What end
rex, Node ! self(), apply, M, F,
A, receive rex, Node, What -gt What end
loop() -gt receive From, apply, M,
F, A -gt Answer (catch apply(M, F,
A)), From ! rex, node(), Answer
loop() _Other -gt loop() end.
loop() -gt receive From, apply, M,
F, A -gt Answer (catch apply(M, F,
A)), From ! rex, node(), Answer
loop() _Other -gt loop() end.
loop() -gt receive From, apply, M,
F, A -gt Answer (catch apply(M, F,
A)), From ! rex, node(), Answer
loop() _Other -gt loop() end.
loop() -gt receive From, apply, M,
F, A -gt Answer (catch apply(M, F,
A)), From ! rex, node(), Answer
loop() _Other -gt loop() end.
24Erlang 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
25Erlang Example
Version 1
Version 2
26Erlang Highlights
"Ports" to the outside world behave as Erlang
processes(c.f. UML ports)
- Declarative
- Concurrency
- Soft real-time
- Robustness
- Distribution
- Hot code loading
- External interfaces
- Portability
27Erlang Example
External process
Port
Port ! self(), command, 1,2,3
28Erlang Example
A port can use e.g. a TCP, UDP, SSL socket,UNIX
pipe, or customtransport (e.g. SAAL)
External process
Port
receive Port, data, Info -gtend
29Erlang Highlights
Erlang runs on any UNIX, Windows, VxWorks, OSE
Delta Supports heterogeneous networks
- Declarative
- Concurrency
- Soft real-time
- Robustness
- Distribution
- Hot code loading
- External interfaces
- Portability
30Systems Overview
Applications written in Erlang
OTP Components
Applications written in C, C or Java
Standard Libraries
Erlang Run-Time System
Hardware and Operating System
31Erlang/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
- ...
32OTP 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_server for writing client-server applications
- gen_event for writing event handlers
- gen_fsm for finite state machine programming
33Principles of the OTP Test Server
34Using Erlang as a Test Tool Language
- Declarative style
- Program for the correct case
- Pattern matching used for compact "assertions"
- EXIT indicates test case failure
- Easy to spawn worker threads to test concurrency
patterns - Test case cleanup is easy due to local variables,
process linking and cascading EXITs
35Experiences 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
36Questions?