Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Erlang and the Cloud

Roberto Aloi
November 17, 2012

Erlang and the Cloud

In the era of multicore and cloud computing, the only limit for your application is the sky. But for your application to be able to exploit all of this potential, it needs to be designed in a manner that scales. In this talk we discuss the suitability of the Erlang programming language for scenarios such as cloud computing and multicore, explaining how the concurrency model of Erlang maps to multicore architectures and what principles should be kept in mind when designing a scalable application.

Roberto Aloi

November 17, 2012
Tweet

More Decks by Roberto Aloi

Other Decks in Programming

Transcript

  1. Definitions of Scalability “Property of a system that can accommodate

    changes in transaction volume without major changes to the system [...] A scalable system can be downsized as easily as it can grow” Barron's Marketing Dictionary “The ability of a system, network, or process, to handle a growing amount of work in a capable manner” André B. Bondi, 2000
  2. “The ability for a business or technology to accept increased

    volume without impacting the contribution margin” Wikipedia Alternative definition of Scalability Contribution Margin = Marginal Profit per Unit Sale
  3. - TONS OF PROCESSES - EXECUTING SIMULTANEOUSLY - REACTING TO

    EVENTS - PERFORMING SMALL COMPUTATIONS
  4. Processes need to be easy to create and destroy. Context

    switch needs to be a cheap operation.
  5. - FAIL IS UNAVOIDABLE - FAIL FAST - AVOID PROPAGATION

    OF FAILURES - RECOVER FROM FAILURE
  6. - HAVE IMMUTABLE DATA - USE PURE FUNCTIONS - NO

    SIDE EFFECTS - REFERENTIAL TRANSPARENCY
  7. IMMUTABILITY SCALABILITY 101 LARGE SCALE CONCURRENCY ASYNCHRONOUS COMMUNICATION RELIABILITY PREDICTABILITY

    DECOUPLING PROCESS ISOLATION FAULT ISOLATION NO SHARED MEMORY SYNCHRONIZATION RACE CONDITIONS EVENTUAL CONSISTENCY CAP THEOREM SMP MULTICORE CLOUD COMPUTING DECENTRALIZATION OF DATA MAINTENANCE NO DOWN TIME
  8. • OPEN SOURCE • CONCURRENCY-ORIENTED • LIGHTWEIGHT PROCESSES (10.000 PER

    CORE) • ASYNCHRONOUS MESSAGE PASSING • SHARE-NOTHING MODEL • PROCESS LINKING / MONITORING • SUPERVISION TREES AND RECOVERY STRATEGIES • TRANSPARENT DISTRIBUTION MODEL • SOFT-REAL TIME • LET-IT-FAIL PHILOSOPHY • HOT-CODE UPGRADES WHAT IS ERLANG DOES IT SOUND FAMILIAR?
  9. Let It Crash convert(Day) -> case Day of monday ->

    1; tuesday -> 2; wednesday -> 3; thursday -> 4; friday -> 5; saturday -> 6; sunday -> 7; Other -> {error, unknown_day} end.
  10. Let It Crash convert(Day) -> case Day of monday ->

    1; tuesday -> 2; wednesday -> 3; thursday -> 4; friday -> 5; saturday -> 6; sunday -> 7; end.
  11. SEND A MESSAGE TO A PROCESS Pid2 Pid1 Pid2 !

    {self(), msg} Message Passing
  12. SEND A MESSAGE TO A PROCESS Pid2 Pid1 Pid2 !

    {self(), msg} {Pid1, msg} Message Passing
  13. RELEASE STATEMENT OF AIMS “To scale the radical concurrency-oriented programming

    paradigm to build reliable general-purpose software, such as server- based systems, on massively parallel machines (10^5 cores).”
  14. WP4 Scalable Infrastructure WP3 SD Erlang Language WP2 Virtual Machine

    WP5 Tools WP6 Case Studies LIMITATIONS ARE PRESENT AT THREE LEVELS
  15. • PUSH THE RESPONSIBILITY FOR SCALABILITY FROM THE PROGRAMMER TO

    THE VM • ANALYZE PERFORMANCE AND SCALABILITY • IDENTIFY BOTTLENECKS AND PRIORITIZE CHANGES AND EXTENSIONS • TACKLE WELL-KNOWN SCALABILITY ISSUES • ETS TABLES (SHARED GLOBAL DATA STRUCTURE) • MESSAGE PASSING, COPYING AND FREQUENTLY COMMUNICATING PROCESSES VM LANGUAGE INFRASTRUCTURE
  16. VM LANGUAGE INFRASTRUCTURE • TWO MAJOR ISSUES • FULLY CONNECTED

    CLUSTERS • EXPLICIT PROCESS PLACEMENT • SCALABLE DISTRIBUTED (SD) ERLANG • NODES GROUPING • NON-TRANSITIVE CONNECTIONS • IMPLICIT PROCESS PLACEMENT • PART OF THE STANDARD ERLANG/OTP PACKAGE • NEW CONCEPTS INTRODUCED • LOCALITY, AFFINITY AND DISTANCE
  17. • MIDDLEWARE LAYER • SET OF ERLANG APPLICATIONS • CREATE

    AND MANAGE CLUSTERS OF (HETEROGENEOUS) ERLANG NODES • API TO MONITOR AND CONTROL ERLANG DISTRIBUTED SYSTEMS • EXISTING TRACING/LOGGING/DEBUGGING TOOLS PLUGGABLE • BROKER LAYER BETWEEN USERS AND CLOUD PROVIDERS • AUTO-SCALING VM LANGUAGE INFRASTRUCTURE CCL /sɪˈsɪlɪ/ ... AND MUCH MORE
  18. erlang.org github.com/erlang/otp erlang-solutions.com www.learnyousomeerlang.org elearning.erlang-solutions.com Erlang Programming Erlang and OTP

    in Action Official Home Page Sources Binary Packages, News, Events Best Online Tutorial Commercial e-learning solution Best book about Erlang Best book about OTP