SlideShare una empresa de Scribd logo
1 de 36
Descargar para leer sin conexión
Erlang.
Measurements and benefits
Valerii Vasylkov, Timecode LLC.
History
notes
Erlang shots
Erlang benefits
Functional nature
Pattern matching on steroids
Concurrency
Fault Tolerance
Let it crash
Distributed Computation
Debugging and profiling
Hot upgrades
Erlang benefits
Functional nature
Pattern matching on steroids
Concurrency
Fault Tolerance
Let it crash
Distributed Computation
Debugging and profiling
Hot upgrades
Functions are easy
Dynamic types
Pattern matching
No mutable data
structures
Binary tree search
Factorial function
Erlang benefits
Functional nature
Pattern matching on steroids
Concurrency
Fault Tolerance
Let it crash
Distributed Computation
Debugging and profiling
Hot upgrades
Pattern matching and steroids
Structure
s
Binaries
Complex
conditions1 get_vh_registered_users(Server, [{prefix, Prefix}, {limit, Limit}, {offset, Offset}])
2 when is_list(Prefix) and is_integer(Limit) and is_integer(Offset) ->
3 case [{U,S} || {U, S} <- get_vh_registered_users(Server), lists:prefix(Prefix, U)]
of
4 [] ->
5 [];
6 Users ->
7 Set = lists:keysort(1, Users),
8 L = length(Set),
9 Start = if Offset < 1 -> 1;
10 Offset > L -> L;
11 true -> Offset
12 end,
13 lists:sublist(Set, Start, Limit)
14 end.
* Not your familiar Regex string matching
Erlang benefits
Functional nature
Pattern matching on steroids
Concurrency
Fault Tolerance
Let it crash
Distributed Computation
Debugging and profiling
Hot upgrades
Erlang concurrency philosophy
The Actor Model
Thinking Parallel
Thinking Processes
• Behavior
• State
• Parallel
• Asynchronous Messages Mailboxes
• No Shared State
The Actor
Model
Carl Hewitt
1973
• Data + Code + Process
• Self-Contained Machines
• Stronger Encapsulation
• Less Inheritance
• Type Inference
• Hot Code Upgrades
Actor
structure
Behavior way
• Inheritance of Behavior only.
• Usually only one level deep.
• Usually one of the standard OTP behaviors:
• Generic Server
• Event
• State Machine
• Supervisor.
Actor vs. OO workflow
Synchronous Calls
Asynchronous Messages
Actor Model: Benefits
• More true to the real world
• Better suited for parallel hardware
• Better suited for distributed architectures
• Scaling garbage collection (gc/actor)
• Less Magic
Actors example
-module(pingpong).
-export([start/0]).
-export([ping/0, pong/0]).
start()->
PingPid = spawn(?MODULE, ping(), []),
PongPid = spawn(?MODULE, pong(), []),
PingPid ! {ping, PongPid},
erlang:send_after(60000,PingPid, stop),
erlang:send_after(60000,PongPid, stop).
ping()->
receive
{Pid, ping} ->
io:fwrite("Ping received Pong~n",[]),
timer:sleep(3000),
Pid ! {self(), pong},
ping();
stop ->
true
end.
pong() ->
receive
{Pid, pong} ->
io:fwrite("Pong received Ping~n",[]),
timer:sleep(3000),
Pid ! {self(), ping},
pong();
stop ->
true
end.
Erlang benefits
Functional nature
Pattern matching on steroids
Concurrency
Fault Tolerance
Let it crash
Distributed Computation
Debugging and profiling
Hot upgrades
Fault-tolerant
Erlang
Supervisors
Links and Monitors
Erlang benefits
Functional nature
Pattern matching on steroids
Concurrency
Fault Tolerance
Let it crash
Distributed Computation
Debugging and profiling
Hot upgrades
Faulty subsystem are difficult to
correct
P.S. Don’t bother, just
Erlang benefits
Functional nature
Pattern matching on steroids
Concurrency
Fault Tolerance
Distributed Computation
Debugging and profiling
Hot upgrades
Distributio
n
Node 1 Node 2
B ! Msg
A B C
transparent message passing in cluster
Setting up an Erlang cluster
erl -sname ketchup
...
(ketchup@ferdmbp)1>
(ketchup@ferdmbp)1> net_kernel:connect_node(fries@ferdmbp).
true
(ketchup@ferdmbp)2> node().
ketchup@ferdmbp
(ketchup@ferdmbp)3> nodes().
[fries@ferdmbp]
(ketchup@ferdmbp)4> register(shell, self()).
true
(ketchup@ferdmbp)5> {shell, fries@ferdmbp} ! {hello, from, self()}.
{hello,from,<0.52.0>}
(ketchup@ferdmbp)6> flush().
Shell got <<"hey there!">>
ok
erl -sname fries
...
(fries@ferdmbp)1>
(fries@ferdmbp)1> register(shell, self()).
true
(fries@ferdmbp)2> receive
{hello, from, OtherShell} ->
OtherShell ! <<"hey there!">>
end.
http://learnyousomeerlang.com/distribunomico
n
Erlang benefits
Functional nature
Pattern matching on steroids
Concurrency
Fault Tolerance
Distributed Computation
Debugging and profiling
Hot upgrades
Observer
Remote shells
(salad@ferdmbp)1>
User switch command
--> h
c [nn] - connect to job
i [nn] - interrupt job
k [nn] - kill job
j - list all jobs
s [shell] - start local shell
r [node [shell]] - start remote shell
q - quit erlang
? | h - this message
--> r mustard@ferdmbp
--> j
1 {shell,start,[init]}
2* {mustard@ferdmbp,shell,start,[]}
--> c
Eshell V5.8.4 (abort with ^G)
(mustard@ferdmbp)1> node().
mustard@ferdmbp
Debugger and profilers
Tool Results
Size of
Result
Effects on Program
Execution Time
Records
Number of
Calls
Records
Execution
Time
Records
Called by
Records
Garbage
Collection
fprof
Per process to
screen/file
Large Significant slowdown Yes
Total and
own
Yes Yes
eprof
Per process/function
to screen/file
Medium Small slowdown Yes Only total No No
cover
Per module to
screen/file
Small Moderate slowdown Yes, per line No No No
cprof Per module to caller Small Small slowdown Yes No No No
dbg Text based tracer Large Small slowdonw No No Yes No
Communit
y
• recon
• redbug
• lager
• xprof
More
introspection
• etop
• pman
• os_mon
• debugger
Bottleneck detection
Erlang benefits
Functional nature
Pattern matching on steroids
Concurrency
Fault Tolerance
Distributed Computation
Debugging and profiling
Hot upgrades
Hot code upgrades
Erlang applications pie
Measurements
Activity
• millions active users
• fast processes for handling
Stability
• developers and operations sleeps fine
• no emergencies for a couple of years
Performance
• compatible to C,
• VM memory management
• lightweight concurrency
• scalability from a box
Issues
• concurrent bottlenecks
• Net splits
• Networks security
• Hot upgrades
Top 5 lines of code
46292
11703
7328
2784
1479
Questions?

Más contenido relacionado

La actualidad más candente

Concurrency in Python
Concurrency in PythonConcurrency in Python
Concurrency in Python
Gavin Roy
 
DTrace - Miracle Scotland Database Forum
DTrace - Miracle Scotland Database ForumDTrace - Miracle Scotland Database Forum
DTrace - Miracle Scotland Database Forum
Doug Burns
 
Gevent what's the point
Gevent what's the pointGevent what's the point
Gevent what's the point
seanmcq
 
Do more than one thing at the same time, the Python way
Do more than one thing at the same time, the Python wayDo more than one thing at the same time, the Python way
Do more than one thing at the same time, the Python way
Jaime Buelta
 
Effective testing for spark programs Strata NY 2015
Effective testing for spark programs   Strata NY 2015Effective testing for spark programs   Strata NY 2015
Effective testing for spark programs Strata NY 2015
Holden Karau
 
Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming
Cloudflare
 

La actualidad más candente (20)

Paradigma FP y OOP usando técnicas avanzadas de Programación | Programacion A...
Paradigma FP y OOP usando técnicas avanzadas de Programación | Programacion A...Paradigma FP y OOP usando técnicas avanzadas de Programación | Programacion A...
Paradigma FP y OOP usando técnicas avanzadas de Programación | Programacion A...
 
Concurrency in Python
Concurrency in PythonConcurrency in Python
Concurrency in Python
 
Performance is a Feature! at DDD 11
Performance is a Feature! at DDD 11Performance is a Feature! at DDD 11
Performance is a Feature! at DDD 11
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
SmokeTests
SmokeTestsSmokeTests
SmokeTests
 
Replica Sets (NYC NoSQL Meetup)
Replica Sets (NYC NoSQL Meetup)Replica Sets (NYC NoSQL Meetup)
Replica Sets (NYC NoSQL Meetup)
 
Mercurial for Kittens
Mercurial for KittensMercurial for Kittens
Mercurial for Kittens
 
DTrace - Miracle Scotland Database Forum
DTrace - Miracle Scotland Database ForumDTrace - Miracle Scotland Database Forum
DTrace - Miracle Scotland Database Forum
 
Gevent what's the point
Gevent what's the pointGevent what's the point
Gevent what's the point
 
Multiprocessing with python
Multiprocessing with pythonMultiprocessing with python
Multiprocessing with python
 
Do more than one thing at the same time, the Python way
Do more than one thing at the same time, the Python wayDo more than one thing at the same time, the Python way
Do more than one thing at the same time, the Python way
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36
 
Protocol handler in Gecko
Protocol handler in GeckoProtocol handler in Gecko
Protocol handler in Gecko
 
Effective testing for spark programs Strata NY 2015
Effective testing for spark programs   Strata NY 2015Effective testing for spark programs   Strata NY 2015
Effective testing for spark programs Strata NY 2015
 
Understanding greenlet
Understanding greenletUnderstanding greenlet
Understanding greenlet
 
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modulesPython Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modules
 
속도체크
속도체크속도체크
속도체크
 
Testing multi outputformat based mapreduce
Testing multi outputformat based mapreduceTesting multi outputformat based mapreduce
Testing multi outputformat based mapreduce
 
Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming
 
Dynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web siteDynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web site
 

Similar a Valerii Vasylkov Erlang. measurements and benefits.

PostgreSQL 8.4 TriLUG 2009-11-12
PostgreSQL 8.4 TriLUG 2009-11-12PostgreSQL 8.4 TriLUG 2009-11-12
PostgreSQL 8.4 TriLUG 2009-11-12
Andrew Dunstan
 
Worst-Case Scheduling of Software Tasks
Worst-Case Scheduling of Software TasksWorst-Case Scheduling of Software Tasks
Worst-Case Scheduling of Software Tasks
Lionel Briand
 
Profiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf ToolsProfiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf Tools
emBO_Conference
 
PHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & PinbaPHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & Pinba
Patrick Allaert
 

Similar a Valerii Vasylkov Erlang. measurements and benefits. (20)

Monitoring Complex Systems: Keeping Your Head on Straight in a Hard World
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard WorldMonitoring Complex Systems: Keeping Your Head on Straight in a Hard World
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard World
 
Re-Design with Elixir/OTP
Re-Design with Elixir/OTPRe-Design with Elixir/OTP
Re-Design with Elixir/OTP
 
Building an ML Platform with Ray and MLflow
Building an ML Platform with Ray and MLflowBuilding an ML Platform with Ray and MLflow
Building an ML Platform with Ray and MLflow
 
Replication MongoDB Days 2013
Replication MongoDB Days 2013Replication MongoDB Days 2013
Replication MongoDB Days 2013
 
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor Concurrency
 
Workshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
Workshop "Can my .NET application use less CPU / RAM?", Yevhen TatarynovWorkshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
Workshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
 
PostgreSQL 8.4 TriLUG 2009-11-12
PostgreSQL 8.4 TriLUG 2009-11-12PostgreSQL 8.4 TriLUG 2009-11-12
PostgreSQL 8.4 TriLUG 2009-11-12
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
Worst-Case Scheduling of Software Tasks
Worst-Case Scheduling of Software TasksWorst-Case Scheduling of Software Tasks
Worst-Case Scheduling of Software Tasks
 
Profiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf ToolsProfiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf Tools
 
PHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & PinbaPHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & Pinba
 
Improving the performance of Odoo deployments
Improving the performance of Odoo deploymentsImproving the performance of Odoo deployments
Improving the performance of Odoo deployments
 
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Data Provenance Support in...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Data Provenance Support in...Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Data Provenance Support in...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Data Provenance Support in...
 
Scaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approachScaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approach
 
Postgres Vision 2018: Making Postgres Even Faster
Postgres Vision 2018: Making Postgres Even FasterPostgres Vision 2018: Making Postgres Even Faster
Postgres Vision 2018: Making Postgres Even Faster
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
bluespec talk
bluespec talkbluespec talk
bluespec talk
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 
Naked Performance With Clojure
Naked Performance With ClojureNaked Performance With Clojure
Naked Performance With Clojure
 
High Availability in 37 Easy Steps
High Availability in 37 Easy StepsHigh Availability in 37 Easy Steps
High Availability in 37 Easy Steps
 

Más de Аліна Шепшелей

Más de Аліна Шепшелей (20)

Vladimir Lozanov How to deliver high quality apps to the app store
Vladimir Lozanov	How to deliver high quality apps to the app storeVladimir Lozanov	How to deliver high quality apps to the app store
Vladimir Lozanov How to deliver high quality apps to the app store
 
Oleksandr Yefremov Continuously delivering mobile project
Oleksandr Yefremov Continuously delivering mobile projectOleksandr Yefremov Continuously delivering mobile project
Oleksandr Yefremov Continuously delivering mobile project
 
Alexander Voronov Test driven development in real world
Alexander Voronov Test driven development in real worldAlexander Voronov Test driven development in real world
Alexander Voronov Test driven development in real world
 
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
 
Valerii Iakovenko Drones as the part of the present
Valerii Iakovenko	Drones as the part of the presentValerii Iakovenko	Drones as the part of the present
Valerii Iakovenko Drones as the part of the present
 
Valerii Moisieienko Apache hbase workshop
Valerii Moisieienko	Apache hbase workshopValerii Moisieienko	Apache hbase workshop
Valerii Moisieienko Apache hbase workshop
 
Dmitriy Kouperman Working with legacy systems. stabilization, monitoring, man...
Dmitriy Kouperman Working with legacy systems. stabilization, monitoring, man...Dmitriy Kouperman Working with legacy systems. stabilization, monitoring, man...
Dmitriy Kouperman Working with legacy systems. stabilization, monitoring, man...
 
Anton Ivinskyi Application level metrics and performance tests
Anton Ivinskyi	Application level metrics and performance testsAnton Ivinskyi	Application level metrics and performance tests
Anton Ivinskyi Application level metrics and performance tests
 
Миша Рыбачук Что такое дизайн?
Миша Рыбачук Что такое дизайн?Миша Рыбачук Что такое дизайн?
Миша Рыбачук Что такое дизайн?
 
Макс Семенчук Дизайнер, которому доверяют
 Макс Семенчук Дизайнер, которому доверяют Макс Семенчук Дизайнер, которому доверяют
Макс Семенчук Дизайнер, которому доверяют
 
Anton Parkhomenko Boost your design workflow or git rebase for designers
Anton Parkhomenko Boost your design workflow or git rebase for designersAnton Parkhomenko Boost your design workflow or git rebase for designers
Anton Parkhomenko Boost your design workflow or git rebase for designers
 
Andrew Veles Product design is about the process
Andrew Veles Product design is about the processAndrew Veles Product design is about the process
Andrew Veles Product design is about the process
 
Kononenko Alina Designing for Apple Watch and Apple TV
Kononenko Alina Designing for Apple Watch and Apple TVKononenko Alina Designing for Apple Watch and Apple TV
Kononenko Alina Designing for Apple Watch and Apple TV
 
Mihail Patalaha Aso: how to start and how to finish?
Mihail Patalaha Aso: how to start and how to finish?Mihail Patalaha Aso: how to start and how to finish?
Mihail Patalaha Aso: how to start and how to finish?
 
Gregory Shehet Undefined' on prod, or how to test a react app
Gregory Shehet Undefined' on  prod, or how to test a react appGregory Shehet Undefined' on  prod, or how to test a react app
Gregory Shehet Undefined' on prod, or how to test a react app
 
Alexey Osipenko Basics of functional reactive programming
Alexey Osipenko Basics of functional reactive programmingAlexey Osipenko Basics of functional reactive programming
Alexey Osipenko Basics of functional reactive programming
 
Vladimir Mikhel Scrapping the web
Vladimir Mikhel Scrapping the web Vladimir Mikhel Scrapping the web
Vladimir Mikhel Scrapping the web
 
Roman Ugolnikov Migrationа and sourcecontrol for your db
Roman Ugolnikov Migrationа and sourcecontrol for your dbRoman Ugolnikov Migrationа and sourcecontrol for your db
Roman Ugolnikov Migrationа and sourcecontrol for your db
 
Dmutro Panin JHipster
Dmutro Panin JHipster Dmutro Panin JHipster
Dmutro Panin JHipster
 
Alex Theedom Java ee revisits design patterns
Alex Theedom	Java ee revisits design patternsAlex Theedom	Java ee revisits design patterns
Alex Theedom Java ee revisits design patterns
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

Valerii Vasylkov Erlang. measurements and benefits.

  • 4. Erlang benefits Functional nature Pattern matching on steroids Concurrency Fault Tolerance Let it crash Distributed Computation Debugging and profiling Hot upgrades
  • 5. Erlang benefits Functional nature Pattern matching on steroids Concurrency Fault Tolerance Let it crash Distributed Computation Debugging and profiling Hot upgrades
  • 6. Functions are easy Dynamic types Pattern matching No mutable data structures Binary tree search Factorial function
  • 7. Erlang benefits Functional nature Pattern matching on steroids Concurrency Fault Tolerance Let it crash Distributed Computation Debugging and profiling Hot upgrades
  • 8. Pattern matching and steroids Structure s Binaries Complex conditions1 get_vh_registered_users(Server, [{prefix, Prefix}, {limit, Limit}, {offset, Offset}]) 2 when is_list(Prefix) and is_integer(Limit) and is_integer(Offset) -> 3 case [{U,S} || {U, S} <- get_vh_registered_users(Server), lists:prefix(Prefix, U)] of 4 [] -> 5 []; 6 Users -> 7 Set = lists:keysort(1, Users), 8 L = length(Set), 9 Start = if Offset < 1 -> 1; 10 Offset > L -> L; 11 true -> Offset 12 end, 13 lists:sublist(Set, Start, Limit) 14 end. * Not your familiar Regex string matching
  • 9. Erlang benefits Functional nature Pattern matching on steroids Concurrency Fault Tolerance Let it crash Distributed Computation Debugging and profiling Hot upgrades
  • 10. Erlang concurrency philosophy The Actor Model Thinking Parallel Thinking Processes
  • 11. • Behavior • State • Parallel • Asynchronous Messages Mailboxes • No Shared State The Actor Model Carl Hewitt 1973
  • 12. • Data + Code + Process • Self-Contained Machines • Stronger Encapsulation • Less Inheritance • Type Inference • Hot Code Upgrades Actor structure Behavior way • Inheritance of Behavior only. • Usually only one level deep. • Usually one of the standard OTP behaviors: • Generic Server • Event • State Machine • Supervisor.
  • 13. Actor vs. OO workflow Synchronous Calls Asynchronous Messages
  • 14.
  • 15. Actor Model: Benefits • More true to the real world • Better suited for parallel hardware • Better suited for distributed architectures • Scaling garbage collection (gc/actor) • Less Magic
  • 16. Actors example -module(pingpong). -export([start/0]). -export([ping/0, pong/0]). start()-> PingPid = spawn(?MODULE, ping(), []), PongPid = spawn(?MODULE, pong(), []), PingPid ! {ping, PongPid}, erlang:send_after(60000,PingPid, stop), erlang:send_after(60000,PongPid, stop). ping()-> receive {Pid, ping} -> io:fwrite("Ping received Pong~n",[]), timer:sleep(3000), Pid ! {self(), pong}, ping(); stop -> true end. pong() -> receive {Pid, pong} -> io:fwrite("Pong received Ping~n",[]), timer:sleep(3000), Pid ! {self(), ping}, pong(); stop -> true end.
  • 17. Erlang benefits Functional nature Pattern matching on steroids Concurrency Fault Tolerance Let it crash Distributed Computation Debugging and profiling Hot upgrades
  • 21. Erlang benefits Functional nature Pattern matching on steroids Concurrency Fault Tolerance Let it crash Distributed Computation Debugging and profiling Hot upgrades
  • 22. Faulty subsystem are difficult to correct P.S. Don’t bother, just
  • 23. Erlang benefits Functional nature Pattern matching on steroids Concurrency Fault Tolerance Distributed Computation Debugging and profiling Hot upgrades
  • 24. Distributio n Node 1 Node 2 B ! Msg A B C transparent message passing in cluster
  • 25. Setting up an Erlang cluster erl -sname ketchup ... (ketchup@ferdmbp)1> (ketchup@ferdmbp)1> net_kernel:connect_node(fries@ferdmbp). true (ketchup@ferdmbp)2> node(). ketchup@ferdmbp (ketchup@ferdmbp)3> nodes(). [fries@ferdmbp] (ketchup@ferdmbp)4> register(shell, self()). true (ketchup@ferdmbp)5> {shell, fries@ferdmbp} ! {hello, from, self()}. {hello,from,<0.52.0>} (ketchup@ferdmbp)6> flush(). Shell got <<"hey there!">> ok erl -sname fries ... (fries@ferdmbp)1> (fries@ferdmbp)1> register(shell, self()). true (fries@ferdmbp)2> receive {hello, from, OtherShell} -> OtherShell ! <<"hey there!">> end. http://learnyousomeerlang.com/distribunomico n
  • 26. Erlang benefits Functional nature Pattern matching on steroids Concurrency Fault Tolerance Distributed Computation Debugging and profiling Hot upgrades
  • 28. Remote shells (salad@ferdmbp)1> User switch command --> h c [nn] - connect to job i [nn] - interrupt job k [nn] - kill job j - list all jobs s [shell] - start local shell r [node [shell]] - start remote shell q - quit erlang ? | h - this message --> r mustard@ferdmbp --> j 1 {shell,start,[init]} 2* {mustard@ferdmbp,shell,start,[]} --> c Eshell V5.8.4 (abort with ^G) (mustard@ferdmbp)1> node(). mustard@ferdmbp
  • 29. Debugger and profilers Tool Results Size of Result Effects on Program Execution Time Records Number of Calls Records Execution Time Records Called by Records Garbage Collection fprof Per process to screen/file Large Significant slowdown Yes Total and own Yes Yes eprof Per process/function to screen/file Medium Small slowdown Yes Only total No No cover Per module to screen/file Small Moderate slowdown Yes, per line No No No cprof Per module to caller Small Small slowdown Yes No No No dbg Text based tracer Large Small slowdonw No No Yes No Communit y • recon • redbug • lager • xprof More introspection • etop • pman • os_mon • debugger
  • 31. Erlang benefits Functional nature Pattern matching on steroids Concurrency Fault Tolerance Distributed Computation Debugging and profiling Hot upgrades
  • 34. Measurements Activity • millions active users • fast processes for handling Stability • developers and operations sleeps fine • no emergencies for a couple of years Performance • compatible to C, • VM memory management • lightweight concurrency • scalability from a box Issues • concurrent bottlenecks • Net splits • Networks security • Hot upgrades
  • 35. Top 5 lines of code 46292 11703 7328 2784 1479