FRANCESCO CESARINI presents IV P E R K 1 S X T Jw fshjxht Gjxfw n sn Erlang Solutions @FrancescoC francesco@erlang-solutions.com www.erlang-solutions.com
W HAT I S S CALABILITY ?
W HAT I S ( MASSIVE ) C ONCURRENCY ?
W HAT I S H IGH A VAILABILITY ?
W HAT I S F AULT T OLERANCE ?
W HAT I S D ISTRIBUTION T RANSPARENCY ?
Do you need a distributed system? Do you need a scalable system? Do you need a reliable system? Do you need a fault-tolerant system? Do you need a massively concurrent system? Do you need a distributed system? Do you need a scalable YES, PLEASE!!! system? Do you need a reliable system? Do you need a fault-tolerant system? Do distributed system? Do you need a scalable system? Do you need a reliable system? Do you need a fault-tolerant system? Do you need a massively
TO THE RESCUE
• O PEN SOURCE • C ONCURRENCY - ORIENTED WHAT IS ERLANG • L IGHTWEIGHT PROCESSES • A SYNCHRONOUS MESSAGE PASSING • S HARE - NOTHING MODEL • P ROCESS LINKING / MONITORING • S UPERVISION TREES AND RECOVERY STRATEGIES • T RANSPARENT DISTRIBUTION MODEL • S OFT - REAL TIME • L ET - IT - FAIL PHILOSOPHY • H OT - CODE UPGRADES
WELL, IN FACT YOU NEED MORE.
ERLANG IS JUST A PROGRAMMING LANGUAGE.
YOU NEED ARCHITECTURE PATTERNS. YOU NEED MIDDLEWARE. YOU NEED LIBRARIES. YOU NEED TOOLS.
Y OU NEED OTP.
S OME T EXT
W HAT IS M IDDLEWARE ?
D ESIGN P ATTERNS Q M H H P I[ F AULT T OLERANCE E V I D ISTRIBUTION U PGRADES P ACKAGING
W HAT ARE L IBRARIES ?
S TORAGE P M F V E V O&M M IW I NTERFACES C OMMUNICATION
W HAT T OOLS ?
D EVELOPMENT S X T X S T EST F RAMEWORKS S P W R ELEASE & D EPLOYMENT D EBUGGING & M ONITORING
OPEN SOURCE OTP IS PART OF THE ERLANG DISTRIBUTION
OTP Less Code Servers Less Bugs Finite State Machines More Solid Code Event Handlers More Tested Code Supervisors More Free Time Applications
Your Heading
Let It Fail convert(Day) -> case Day of monday -> 1; tuesday -> 2; wednesday -> 3; thursday -> 4; friday -> 5; saturday -> 6; sunday -> 7; Other -> {error, unknown_day} end.
Let It Fail convert(Day) -> case Day of monday -> 1; tuesday -> 2; wednesday -> 3; thursday -> 4; friday -> 5; saturday -> 6; sunday -> 7; end.
I SOLATE T HE E RROR !
Exit Signals P ROPAGATING E XIT S IGNALS {'EXIT', PidA, Reason} PidB PidA {'EXIT', PidB, Reason} PidC
Trap Exit T RAPPING AN E XIT S IGNAL {'EXIT', PidA, Reason} PidB PidA PidC
Supervisors Supervisor PidB PidA Workers PidC Application
Releases Release Mongoose folsom lager IM snmp mnesia stdlib ERTS SASL kernel
B EHAVIOURS
W jw |jw GENERIC SPECIFIC BEHAVIOUR CALLBACK MODULE MODULE process
OTP Less Code Servers Less Bugs Finite State Machines More Solid Code Event Handlers More Tested Code Supervisors More Free Time Applications
{request, Pid, Message} Client Server {reply, Reply} call(Name, Message) -> Name ! {request, self(), Message}, receive {reply, Reply} -> Reply end. reply(Pid, Reply) -> Pid ! {reply, Reply}.
{request, Pid, Message} {request, { Ref , self()}, Message} Client Server {reply, Ref , Reply} {reply, Reply} {reply, ??? , Reply} {reply, Reply} Server 2 call(Name, Msg) -> Ref = make_ref(), Name ! {request, { Ref , self()}, Msg}, receive {reply, Ref , Reply} -> Reply end. reply({ Ref , Pid}, Reply) -> Pid ! {reply, Ref , Reply}.
{request, {Ref, PidA}, Msg} PidB PidA call(Name, Msg) -> Ref = erlang:monitor(process, Name), Name ! {request, {Ref, self()}, Msg}, receive � {reply, Ref, Reply} -> � erlang:demonitor(Ref), � Reply; � {'DOWN', Ref, process, _Name, _Reason} -> � {error, no_proc} end.
{'DOWN', Ref, process, PidB, Reason} {request, {Ref, PidA}, Msg} {reply, Ref, Reply} PidB PidA call(Name, Msg) -> Ref = erlang:monitor(process, Name), Name ! {request, {Ref, self()}, Msg}, receive � {reply, Ref, Reply} -> � erlang:demonitor(Ref, [flush] ), � Reply; � {'DOWN', Ref, process, _Name, _Reason} -> � {error, no_proc} end.
T IMEOUTS F IL E Z M D EADLOCKS S Y V W TRACING M ONITORING D ISTRIBUTION
A UTOMATIC T AKEOVER AND F AILOVER
{myApp, 2000, {n1@host, {n2@host, n3@host}]} N1 N2 N3 Application Master n1@host dies Application Masters on failover nodes Application
{myApp, 2000, {n1@host, {n2@host, n3@host}]} N2 N3 n2@host dies Application is restarted on n2@host
{myApp, 2000, {n1@host, {n2@host, n3@host}]} N1 N3 Application is restarted on n3@host n1@host comes back up
{myApp, 2000, {n1@host, {n2@host, n3@host}]} N1 N3 N1 takes over N3
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).”
The Runtime Queues Erlang VM Scheduler #1 run queue migration migration Scheduler #2 Scheduler #2 run queue logic logic Scheduler #N run queue
LIMITATIONS ARE PRESENT AT THREE LEVELS WP6 Case Studies WP4 Scalable Infrastructure WP5 Tools WP3 SD Erlang Language WP2 Virtual Machine
VM LANGUAGE INFRASTRUCTURE • P USH THE RESPONSIBILITY FOR SCALABILITY FROM THE PROGRAMMER TO THE VM • A NALYZE PERFORMANCE AND SCALABILITY • I DENTIFY BOTTLENECKS AND PRIORITIZE CHANGES AND EXTENSIONS • T ACKLE WELL - KNOWN SCALABILITY ISSUES • E TS TABLES ( SHARED GLOBAL DATA STRUCTURE ) • M ESSAGE PASSING , COPYING AND FREQUENTLY COMMUNICATING PROCESSES
VM LANGUAGE INFRASTRUCTURE • T WO MAJOR ISSUES • F ULLY CONNECTED CLUSTERS • E XPLICIT PROCESS PLACEMENT • S CALABLE D ISTRIBUTED (SD) E RLANG • N ODES GROUPING • N ON - TRANSITIVE CONNECTIONS • I MPLICIT PROCESS PLACEMENT • P ART OF THE STANDARD E RLANG /OTP PACKAGE • N EW CONCEPTS INTRODUCED • L OCALITY , A FFINITY AND D ISTANCE
VM LANGUAGE INFRASTRUCTURE CCL /s ɪˈ s ɪ l ɪ / • M IDDLEWARE LAYER • S ET OF E RLANG A PPLICATIONS • C REATE AND MANAGE CLUSTERS OF ( HETEROGENEOUS ) ERLANG NODES • API TO MONITOR AND CONTROL ERLANG DISTRIBUTED SYSTEMS • E XISTING TRACING / LOGGING / DEBUGGING TOOLS PLUGGABLE • B ROKER LAYER BETWEEN USERS AND CLOUD PROVIDERS • A UTO - SCALING ... A ND M UCH M ORE
C ONCLUSIONS
Do you need a distributed system? Do you need a scalable system? Do you need a reliable system? Do you need a fault-tolerant system? Do you need a massively concurrent system? Do you need a distributed system? Do you need a scalable USE ERLANG system? Do you need a reliable system? Do you need a fault-tolerant system? Do distributed system? Do you need a scalable system? Do you need a reliable system? Do you need a fault-tolerant system? Do you need a massively
Do you need a distributed system? Do you need a scalable system? Do you need a reliable system? Do you need a fault-tolerant system? Do you need a massively concurrent system? Do you need a distributed system? Do you need a scalable USE ERLANG/OTP system? Do you need a reliable system? Do you need a fault-tolerant system? Do distributed system? Do you need a scalable system? Do you need a reliable system? Do you need a fault-tolerant system? Do you need a massively
Q UESTIONS ? @francescoC
Recommend
More recommend