Erlang OTP

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Notes on slide 1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1 This is the essential loop needed for an RPC server. The server receives requests from clients, uses apply to evaluate the requests and then returns the answer to the originator. This is a simplified solution where no error handling is done. The BIF node/0 returns the node name.

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    2003-12-01 Rev PA1

    3 Favorites

    Erlang OTP - Presentation Transcript

    1. Erlang Open Telecom Platform EAB/UPD/S Ulf Wiger
    2. Contents
      • Background
      • The Erlang Language
      • OTP
      • The Erlang/OTP Test Server
      • Experiences
    3. History of Erlang 1984-86: Experiments programming POTS with several languages 1998: Open Source Erlang 1987: Early Erlang Prototype projects 1991: First fast implementation 1993: Distributed Erlang 1995: Several new projects 1996: Open Telecom Platform AXD and GPRS started How to design SW for future telecoms systems?
    4. Erlang “Hello World” program
      • io:format(“Hello, World~n”).
      • Hello, World
      • ok
      • io:format(“Hello, ~s!~n”, [“Zvi”]).
      • Hello, Zvi
      • ok
      • NOTE: “~s” instead of “%s”, like in printf in C.
      • and “~n” instead of “ ”.
    5. Erlang Data Types
      • Atoms:
        • true, false, inject_slice, zvi@home, ‘EXIT’, ‘+’
      • Integers ( only big integers allocated on the heap )
        • 10, -100, 1234567890999999999999999999999
        • 2#101 = 5
        • 16#FF = 255
        • $A = 65 (i.e. ASCII code of character ‘A’)
      • Floats ( floats allocated on the heap – bad for HPC)
        • 3.1415, 1.0, -1.7e-9
      • Tuples:
        • {{1,2,3}, {a,b,c}, {{1,2,{a,b,c},{}}
      • Lists:
        • [[1,2,3], [a,b,c], [[1,2,[a,b,c],[]]
    6. Erlang Data Types (2)
      • String is a list of ASCII codes:
        • “ hello” = [$h,$e,$l,$l,$o] = [104,101,108,108,111]
      • Binaries (sequence of bytes):
        • <<104,101,108,108,111>> = <<“hello”>>
      • Binaries with Bit-Syntax:
        • <<1:1,32787:15>> = 2#1111111111111111
      • Other data types:
        • Funs (anonymous functions – closures)
        • ProcessID
        • Port
        • etc.
    7. Pattern Matching and Single Assignment
    8. List Operations
    9. List Operations (2)
    10. List Comprehensions
    11. Anonymous Functions
    12. Functions (cont.)
    13. Erlang Highlights
      • Declarative
      • Concurrency
      • Soft real-time
      • Robustness
      • Distribution
      • Hot code loading
      • External interfaces
      • Portability
      Functional programming language High abstraction level Pattern matching Concise readable programs
    14. Erlang Highlights
      • Declarative
      • Concurrency
      • Soft real-time
      • Robustness
      • Distribution
      • Hot code loading
      • External interfaces
      • Portability
      Solid concurrency model Scales to handle complex concurrency Simple abstractions Examples...
    15. 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)
    16. 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
    17. 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 encapsulation of sub-states Optional timeout Asynchronous send
    18. Erlang Highlights
      • Declarative
      • Concurrency
      • Soft real-time
      • Robustness
      • Distribution
      • Hot code loading
      • External interfaces
      • Portability
      Lightweight processes Fast message passing Response times in the order of milliseconds efficient garbage collection Numbers...
    19. Process creation times (LOG/LOG scale) Source: Joe Armstrong SICS > 200,000 processes 10 100 1,000 10,000 100,000 Number of processes 1 10 100 1,000 Microseconds/process erlang java C#
    20. Message passing times (LOG/LOG scale) Source: Joe Armstrong SICS > 200,000 processes 10 100 1,000 10,000 100,000 Number of processes 1 10 1,000 100,000 Microseconds/message erlang java C# 10,000 100 1
    21. Erlang Highlights
      • Declarative
      • Concurrency
      • Soft real-time
      • Robustness
      • Distribution
      • Hot code loading
      • External interfaces
      • Portability
      Simple and consistent error recovery Supervision hierarchies &quot;Program for the correct case&quot; Examples...
    22. Erlang Example Cooperating processes may be linked together using spawn_link(…,…,…) or link(Pid)
    23. Erlang Example When a process terminates, an exit signal is sent to all linked processes … and the termination is propagated
    24. Erlang Example Exit signals can be trapped and received as messages receive {‘EXIT’,Pid,...} -> ... end process_flag(trap_exit,true), ...
    25. Erlang Example Robust systems can be built by layering “ Supervisors” “ Workers”
    26. 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 designed into the language from the start!
    27. 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
    28. Erlang Highlights
      • Declarative
      • Concurrency
      • Soft real-time
      • Robustness
      • Distribution
      • Hot code loading
      • External interfaces
      • Portability
      Explicit or transparent distribution Network-aware runtime system Examples...
    29. Transparent Distribution Erlang Run-Time System Erlang 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 A B C
    30. 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} -> 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 = (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.
    31. 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 operation Simplifies testing Examples...
    32. Erlang Example Version 1 Version 2 change_code
    33. Erlang Highlights
      • Declarative
      • Concurrency
      • Soft real-time
      • Robustness
      • Distribution
      • Hot code loading
      • External interfaces
      • Portability
      &quot;Ports&quot; to the outside world behave as Erlang processes (c.f. UML ports) Examples...
    34. Erlang Example Port External process Port ! {self(), {command, [1,2,3]}}
    35. Erlang Example Port External process receive {Port, {data, Info}} -> end A port can use e.g. a TCP, UDP, SSL socket, UNIX pipe, or custom transport (e.g. SAAL)
    36. 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 heterogeneous networks Illustration...
    37. Systems Overview OTP Components Standard Libraries Erlang Run-Time System Hardware and Operating System Applications written in Erlang Applications written in C, C++ or Java
    38. 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
        • ...
    39. OTP Behaviors
      • &quot;A formalization of design patterns&quot;
        • 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
    40. Using Erlang as a Test Tool Language
      • Declarative style
      • Program for the correct case
      • Pattern matching used for compact &quot;assertions&quot;
      • 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
    41. 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
    42. 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
    43. Downloads since Open Source Launch ’98 Grouping: 6 months
    44. Example Products: Outside Ericsson
      • Amazon Web Services - SQS and SimpleDB, iMDB
      • Facebook - social networking chat
      • Powerset (now Microsoft bing) – Semantic Search & NLP
      • Twitter – microbloging
      • Slideaware.net – presentations
      • Mochimedia – ads in Flash games
      • Del.icio.us / Yahoo! – social bookmarking
    45. Example Products: Open Source
      • EDDIE, Distributed TCP/IP based Clusterware
      • Wings 3D, a 3D modeller based on Nendo
      • YAWS, Yet Another Web Server
      • RabbitMQ, high performance enterprise messaging
      • Ejabberd, instant messaging server
      • Erlyweb, web development framework
    46. Example Products: Open Source
      • Apache CouchDB – document-based DB with REST I/F
      • Disco – Map/Reduce framework for Erlang
      • Fuzed – Generic clustering framework (Powerset)
      • Mochiweb – Fast lightweight web server framework (like Java Servlets for Erlang)
      • Many-many web frameworks
      • OpenPoker – scalable Poker server
      • DHT – Distributed Key/Value Stores – 90% of all implementations in Erlang – Dunomite, Scalaris, etc.
    47. Erlang good fit for:
      • Irregular concurrency
        • Task-level parallelism
        • Fine-grained parallelism
      • Network servers
      • Distributed systems
      • Middleware:
        • Parallel databases
        • Message Queue servers
      • Soft Real-Time / Embedded applications
      • Monitoring, control and testing tools
    48. Erlang not so good for:
      • Concurrency more appropriate to synchronized parallel execution:
        • Data Parallelism
      • Floating-point intensive code (HPC)
      • Text Processing / Unicode
      • Traditional GUI
      • Hard Real-Time applications
      • Projects using:
        • Non-portable instructions
        • Running on JVM / CLR
        • Extensive use of libraries in other languages
    49. Questions?
    SlideShare Zeitgeist 2009

    + nivertechnivertech Nominate

    custom

    359 views, 3 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 359
      • 359 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 3
    • Downloads 1
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Tags