SlideShare una empresa de Scribd logo
1 de 34
Descargar para leer sin conexión
MILAN 20/21.11.2015
Handling Millions of
Concurrent Users
with Erlang/OTP
MANUEL RUBIO - ALTENWALD
MILAN 21.11.2015 - MANUEL RUBIO
Who I am?
○ Programmer from I was 12 years old... more than 20 years
programming in: Perl, Python, Ruby, PHP, Java, C/C++, JavaScript,
Pascal, Modula-2, Basic,Erlang/OTP and Elixir.
○ Systems Admin from I was 22 years old... more than 10 years
administering GNU/Linux y BSD systems.
○ Wrote the first Erlang/OTP book in Spanish language.
○ Contact:
○ Blog: http://altenwald.org (at this moment only in Spanish)
○ Twitter: @MRonErlang
MILAN 21.11.2015 - MANUEL RUBIO
Who we are?
Altenwald Solutions S.L. since 2013 is a company dedicated to:
● High Availability, Concurrency and Distributed Systems
consulting specially if they are built with Erlang/OTP.
● Erlang/OTP Community Support thru books, documentation and
courses (mainly in Spanish). We are part of IEUG (Industrial Erlang
Users Group).
● Make projects… mainly free software and open source.
MILAN 21.11.2015 - MANUEL RUBIO
Web 1.0 → 2.0
MILAN 21.11.2015 - MANUEL RUBIO
○ Collaboration
○ Interaction
○ Social Networks
○ …
Web 2.0
MILAN 21.11.2015 - MANUEL RUBIO
LAMP
GNU/Linux - Apache - MySQL - PHP
MILAN 21.11.2015 - MANUEL RUBIO
LAMP
Internet
MILAN 21.11.2015 - MANUEL RUBIO
LAMP
Internet
MILAN 21.11.2015 - MANUEL RUBIO
LAMP
Internet
MILAN 21.11.2015 - MANUEL RUBIO
○ Sessions: cannot be modified at the same time usually.
○ Replicate database: always keeps bottlenecks.
○ Master - Slave: only one server can perform writes.
○ Master - Master: decrease the speed of the database access.
○ Cache: increasing number of requests you’ll needed. New bottleneck and
complex flow if you need to purge data.
○ Accelerators & Internal cache for code: to speed up the load of the code.
○ Queues for asynchronous processes or delayed tasks.
○ Concurrency is hard to do or impossible to achieve in the most of the
cases.
○ Websockets … well, we need something better.
Main issues of these architectures
MILAN 21.11.2015 - MANUEL RUBIO
What is Erlang?
○ Born at 1986 as a Prolog extension in the Ericsson labs.
○ Language
○ Functional or not? ... better hybrid.
○ Oriented to the Concurrency... Actor Model
○ Virtual Machine or Platform
○ Scheduling and Managing of Processes (supports more than
1.000.000 procs)
○ Memory Management
○ Command line interpreter (shell)
○ Transparent interface for communication between nodes
○ Features
○ Distributed
○ Fault tolerant
○ Scalable
○ Hot code swapping
MILAN 21.11.2015 - MANUEL RUBIO
➔ Yaws (Erlang/OTP web server)
➔ Apache (MPM Worker, 250 threads)
➔ Apache (MPM Prefork, 64 processes)
This shows KBytes/second vs load
Why Erlang fits better?
MILAN 21.11.2015 - MANUEL RUBIO
When you are stuck in a traffic jam with a Porsche, all you
do is burn more gas in idle. Scalability is about building
wider roads, not about building faster cars.
- Steve Swartz
Why Erlang fits better?
MILAN 21.11.2015 - MANUEL RUBIO
Use cases...
MILAN 21.11.2015 - MANUEL RUBIO
● 67 million unique players / month
● 27 million daily players
● 7.5 million concurrent players
● 1 billion events routed / server /
day & only use 20-30% CPU & RAM
● 11K messages/second
● Few hundred chat servers managed
by only 3 people.
● 99% uptime
Use cases...
MILAN 21.11.2015 - MANUEL RUBIO
Who is using Erlang/OTP?
… AND MANY MORE
MILAN 21.11.2015 - MANUEL RUBIO
What is made in Erlang/OTP?
ejabberd RabbitMQ CouchBase Riak VerneMQ Chef
MILAN 21.11.2015 - MANUEL RUBIO
Erlang/OTP around the World!
job opportunities…
MILAN 21.11.2015 - MANUEL RUBIO
Actor Model vs OOP
○ Hertz vs Cores
○ Oriented Object Programming is attributed to Alan Kay (Smalltalk)
○ Actor Model is attributed to Carl Hewitt by a study published in 1977.
MILAN 21.11.2015 - MANUEL RUBIO
Actor Model vs OOP
MILAN 21.11.2015 - MANUEL RUBIO
Erlang Syntax
MILAN 21.11.2015 - MANUEL RUBIO
Factorial Example
A typical example of Factorial
MILAN 21.11.2015 - MANUEL RUBIO
Factorial Example
A typical example of Factorial (C)
factorial(int f) {
int i;
for (i=f-1; i>1; i--) {
f = f * i;
}
return f;
}
MILAN 21.11.2015 - MANUEL RUBIO
Factorial Example
A typical example of Factorial (C recursivo)
factorial(int f) {
if (f <= 1) {
return 1;
}
return f * factorial(f-1);
}
MILAN 21.11.2015 - MANUEL RUBIO
Factorial Example
A typical example of Factorial (Erlang)
factorial(0) -> 1;
factorial(1) -> 1;
factorial(N) -> N * factorial(N-1).
MILAN 21.11.2015 - MANUEL RUBIO
Language Features
○ Unique Assignments
> A = 1.
1
> A = 2.
** exception error: no match of right hand side value 2
○ Simple language: case, if, try...catch & receive.
case Value of
12 -> "OK";
_ when is_integer(Value) -> "OK";
_ -> "FAIL";
end.
○ Message passing
Pid = spawn(fun micode/0),
Pid ! "Ciao mondo!",
receive
Any -> io:format("OK")
end.
MILAN 21.11.2015 - MANUEL RUBIO
Language Features
○ Long, very long numbers
1> fact:fact(128).
38562048236258042173567706592346364061749310959022359027882840327637340257516554356068
61685885073615340300518330589163475921729322624988577661149552450393577600346447092792
47692495585280000000000000000000000000000000
2> fact:fact(1024).
54185287960588572830769219446838547380015539635380134444828702706832106120733766037331
40984136214586719079188457089807539319941657701873682604541333337219391083675280127649
93769768292516937891165755680659663747947314518404886677672556125188694335251213677274
52196343077013371320579624843312887008843617165469023751839045294473227780840293215872
20618538061628060639254353108221868482392871302616909142113622511446847138885878816292
52104046295315949943900357882410243934315037444113890806181406210863953275235375885018
59845158222959965455854124278913090248694429861092315330757913167574514643630402489082
04429077345618273690305022527969265530729673709907587477931276351047024698896679614621
33026237158973227857814631807156427767644064591085076564783456324457736853810336981776
08049870776704639427260534141677912569773337456803747518667626596166561588468145026333
70425226641418621570468256847733609443267374936766749150989537681129458316266438564790
27816385730291542667725665642276826058264393884514911976419675509290208592713156362983
2909894410527321251872495275013140716764...
MILAN 21.11.2015 - MANUEL RUBIO
○ Matching
> "Ciao " ++ Who = "Ciao mondo!".
"Ciao mondo!"
> Who.
"mondo!"
○ Sets
> A = [1,2,3,4,5], B = [2,4,6], A -- B.
[1,3,5]
> (A -- B) ++ (B -- A).
[1,3,5,6]
○ Binaries
{ok, PNG} = file:open("debian-logo.png", [read,binary]),
{ok, <<137,"PNG",13,10,26,10,Length:32,"IHDR">>} = file:read(PNG, 16),
{ok, <<Width:32, Height:32, Depth:8, Color:8>>} = file:read(PNG, 10),
{ok, <<Compression:8, Filter:8, Interlace:8>>} = file:read(PNG, 3),
file:close(PNG).
Language Features
MILAN 21.11.2015 - MANUEL RUBIO
Behaviors
○ gen_server: generic servers, actors base.
○ gen_fsm: finite state machines.
○ gen_event: event handlers.
○ supervisor: process supervisors.
○ application: base structure for applications.
MILAN 21.11.2015 - MANUEL RUBIO
Behaviors
-module(elevator).
-behaviour(gen_fsm).
-compile([export_all]). % to simplify, but should use -export()
start_link() ->
gen_fsm:start_link({local, ?MODULE}, ?MODULE, [], []).
init([]) ->
{ok, ground_floor, []}.
ground_floor(down, State) ->
io:format("Beeep!, incorrect option~n", []),
{next_state, ground_floor, State};
ground_floor(up, State) ->
io:format("Going to first floor~n", []),
{next_state, first_floor, State}.
first_floor(down, State) ->
io:format("Going to the ground floor~n", []),
{next_state, ground_floor, State};
first_floor(up, State) ->
io:format("Going to the second floor~n", []),
{next_state, second_floor, State}.
second_floor(down, State) ->
io:format("Going to the first floor~n", []),
{next_state, first_floor, State};
second_floor(up, State) ->
io:format("Beeep!, incorrect option~n", []),
{next_state, second_floor, State}.
% add functions to do easy the use of the calls.
% these are optional:
up_button() ->
gen_fsm:send_event(?MODULE, up).
down_button() ->
gen_fsm:send_event(?MODULE, down).
up up
down down
MILAN 21.11.2015 - MANUEL RUBIO
Books about Erlang/OTP
MILAN 21.11.2015 - MANUEL RUBIO
Books about Elixir
MILAN 21.11.2015 - MANUEL RUBIO
Leave your feedback on Joind.in!
https://m.joind.in/event/codemotion-milan-2015
facebook.com/altenwald
linkedin.com/company/altenwald github.com/altenwald
@altenwald
MILAN 21.11.2015 - MANUEL RUBIO
Questions?

Más contenido relacionado

Similar a Handling Millions of Concurrent Users with Erlang OTP

Meetup 2020 - Back to the Basics part 101 : IaC
Meetup 2020 - Back to the Basics part 101 : IaCMeetup 2020 - Back to the Basics part 101 : IaC
Meetup 2020 - Back to the Basics part 101 : IaCDamienCarpy
 
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019Jakarta_EE
 
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019The Eclipse Foundation
 
Kubernetes: The Very Hard Way
Kubernetes: The Very Hard WayKubernetes: The Very Hard Way
Kubernetes: The Very Hard WayRob Boll
 
SFScon18 - Armin Le Grand - Collective action come and see how LibreOffice go...
SFScon18 - Armin Le Grand - Collective action come and see how LibreOffice go...SFScon18 - Armin Le Grand - Collective action come and see how LibreOffice go...
SFScon18 - Armin Le Grand - Collective action come and see how LibreOffice go...South Tyrol Free Software Conference
 
Interop Tokyo 2014 -- Mellanox Demonstrations
Interop Tokyo 2014 -- Mellanox DemonstrationsInterop Tokyo 2014 -- Mellanox Demonstrations
Interop Tokyo 2014 -- Mellanox DemonstrationsMellanox Technologies
 
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...Pôle Systematic Paris-Region
 
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVMScala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVMRUDDER
 
Tarantool: теперь и с SQL
Tarantool: теперь и с SQLTarantool: теперь и с SQL
Tarantool: теперь и с SQLMail.ru Group
 
The Universal Developer: Deploying Modern Tcl/Tk Solutions on the Mac
The Universal Developer: Deploying Modern Tcl/Tk Solutions on the MacThe Universal Developer: Deploying Modern Tcl/Tk Solutions on the Mac
The Universal Developer: Deploying Modern Tcl/Tk Solutions on the MacKevin Walzer
 
SFSCON23 - Chris Mair - Self-hosted, Open Source Large Language Models (LLMs)
SFSCON23 - Chris Mair - Self-hosted, Open Source Large Language Models (LLMs)SFSCON23 - Chris Mair - Self-hosted, Open Source Large Language Models (LLMs)
SFSCON23 - Chris Mair - Self-hosted, Open Source Large Language Models (LLMs)South Tyrol Free Software Conference
 
TEE - kernel support is now upstream. What this means for open source security
TEE - kernel support is now upstream. What this means for open source securityTEE - kernel support is now upstream. What this means for open source security
TEE - kernel support is now upstream. What this means for open source securityLinaro
 
The logic behind choosing logic controllers
The logic behind choosing logic controllersThe logic behind choosing logic controllers
The logic behind choosing logic controllersOptima Control Solutions
 
Building a globalized, customer facing e-commerce product, powered by micro-s...
Building a globalized, customer facing e-commerce product, powered by micro-s...Building a globalized, customer facing e-commerce product, powered by micro-s...
Building a globalized, customer facing e-commerce product, powered by micro-s...Nikos Dimitrakopoulos
 
OpenNebulaConf2018 - Welcome and Project Update - Ignacio M. Llorente, Rubén ...
OpenNebulaConf2018 - Welcome and Project Update - Ignacio M. Llorente, Rubén ...OpenNebulaConf2018 - Welcome and Project Update - Ignacio M. Llorente, Rubén ...
OpenNebulaConf2018 - Welcome and Project Update - Ignacio M. Llorente, Rubén ...OpenNebula Project
 
Peering and Transit Tutorials: Open-IXSDN Umbrella IXP Fabric
Peering and Transit Tutorials: Open-IXSDN Umbrella IXP FabricPeering and Transit Tutorials: Open-IXSDN Umbrella IXP Fabric
Peering and Transit Tutorials: Open-IXSDN Umbrella IXP FabricInternet Society
 
Umbrella Fabric/IXP SDN OpenFlow: The TouiX to TouSIX Experience
Umbrella Fabric/IXP SDN OpenFlow: The TouiX to TouSIX ExperienceUmbrella Fabric/IXP SDN OpenFlow: The TouiX to TouSIX Experience
Umbrella Fabric/IXP SDN OpenFlow: The TouiX to TouSIX ExperienceAPNIC
 
Sasaki webtechcon2010
Sasaki webtechcon2010Sasaki webtechcon2010
Sasaki webtechcon2010Felix Sasaki
 
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...Russell Pavlicek
 

Similar a Handling Millions of Concurrent Users with Erlang OTP (20)

Meetup 2020 - Back to the Basics part 101 : IaC
Meetup 2020 - Back to the Basics part 101 : IaCMeetup 2020 - Back to the Basics part 101 : IaC
Meetup 2020 - Back to the Basics part 101 : IaC
 
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
 
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
 
Kubernetes: The Very Hard Way
Kubernetes: The Very Hard WayKubernetes: The Very Hard Way
Kubernetes: The Very Hard Way
 
SFScon18 - Armin Le Grand - Collective action come and see how LibreOffice go...
SFScon18 - Armin Le Grand - Collective action come and see how LibreOffice go...SFScon18 - Armin Le Grand - Collective action come and see how LibreOffice go...
SFScon18 - Armin Le Grand - Collective action come and see how LibreOffice go...
 
Interop Tokyo 2014 -- Mellanox Demonstrations
Interop Tokyo 2014 -- Mellanox DemonstrationsInterop Tokyo 2014 -- Mellanox Demonstrations
Interop Tokyo 2014 -- Mellanox Demonstrations
 
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
 
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVMScala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
 
NATS & IoT
NATS & IoTNATS & IoT
NATS & IoT
 
Tarantool: теперь и с SQL
Tarantool: теперь и с SQLTarantool: теперь и с SQL
Tarantool: теперь и с SQL
 
The Universal Developer: Deploying Modern Tcl/Tk Solutions on the Mac
The Universal Developer: Deploying Modern Tcl/Tk Solutions on the MacThe Universal Developer: Deploying Modern Tcl/Tk Solutions on the Mac
The Universal Developer: Deploying Modern Tcl/Tk Solutions on the Mac
 
SFSCON23 - Chris Mair - Self-hosted, Open Source Large Language Models (LLMs)
SFSCON23 - Chris Mair - Self-hosted, Open Source Large Language Models (LLMs)SFSCON23 - Chris Mair - Self-hosted, Open Source Large Language Models (LLMs)
SFSCON23 - Chris Mair - Self-hosted, Open Source Large Language Models (LLMs)
 
TEE - kernel support is now upstream. What this means for open source security
TEE - kernel support is now upstream. What this means for open source securityTEE - kernel support is now upstream. What this means for open source security
TEE - kernel support is now upstream. What this means for open source security
 
The logic behind choosing logic controllers
The logic behind choosing logic controllersThe logic behind choosing logic controllers
The logic behind choosing logic controllers
 
Building a globalized, customer facing e-commerce product, powered by micro-s...
Building a globalized, customer facing e-commerce product, powered by micro-s...Building a globalized, customer facing e-commerce product, powered by micro-s...
Building a globalized, customer facing e-commerce product, powered by micro-s...
 
OpenNebulaConf2018 - Welcome and Project Update - Ignacio M. Llorente, Rubén ...
OpenNebulaConf2018 - Welcome and Project Update - Ignacio M. Llorente, Rubén ...OpenNebulaConf2018 - Welcome and Project Update - Ignacio M. Llorente, Rubén ...
OpenNebulaConf2018 - Welcome and Project Update - Ignacio M. Llorente, Rubén ...
 
Peering and Transit Tutorials: Open-IXSDN Umbrella IXP Fabric
Peering and Transit Tutorials: Open-IXSDN Umbrella IXP FabricPeering and Transit Tutorials: Open-IXSDN Umbrella IXP Fabric
Peering and Transit Tutorials: Open-IXSDN Umbrella IXP Fabric
 
Umbrella Fabric/IXP SDN OpenFlow: The TouiX to TouSIX Experience
Umbrella Fabric/IXP SDN OpenFlow: The TouiX to TouSIX ExperienceUmbrella Fabric/IXP SDN OpenFlow: The TouiX to TouSIX Experience
Umbrella Fabric/IXP SDN OpenFlow: The TouiX to TouSIX Experience
 
Sasaki webtechcon2010
Sasaki webtechcon2010Sasaki webtechcon2010
Sasaki webtechcon2010
 
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
 

Más de Codemotion

Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Codemotion
 
Pompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyPompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyCodemotion
 
Pastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaPastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaCodemotion
 
Pennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserPennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserCodemotion
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Codemotion
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Codemotion
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Codemotion
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 - Codemotion
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Codemotion
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Codemotion
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Codemotion
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Codemotion
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Codemotion
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Codemotion
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Codemotion
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...Codemotion
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Codemotion
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Codemotion
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Codemotion
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Codemotion
 

Más de Codemotion (20)

Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
 
Pompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyPompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending story
 
Pastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaPastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storia
 
Pennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserPennisi - Essere Richard Altwasser
Pennisi - Essere Richard Altwasser
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
 

Último

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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 WorkerThousandEyes
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Último (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

Handling Millions of Concurrent Users with Erlang OTP

  • 1. MILAN 20/21.11.2015 Handling Millions of Concurrent Users with Erlang/OTP MANUEL RUBIO - ALTENWALD
  • 2. MILAN 21.11.2015 - MANUEL RUBIO Who I am? ○ Programmer from I was 12 years old... more than 20 years programming in: Perl, Python, Ruby, PHP, Java, C/C++, JavaScript, Pascal, Modula-2, Basic,Erlang/OTP and Elixir. ○ Systems Admin from I was 22 years old... more than 10 years administering GNU/Linux y BSD systems. ○ Wrote the first Erlang/OTP book in Spanish language. ○ Contact: ○ Blog: http://altenwald.org (at this moment only in Spanish) ○ Twitter: @MRonErlang
  • 3. MILAN 21.11.2015 - MANUEL RUBIO Who we are? Altenwald Solutions S.L. since 2013 is a company dedicated to: ● High Availability, Concurrency and Distributed Systems consulting specially if they are built with Erlang/OTP. ● Erlang/OTP Community Support thru books, documentation and courses (mainly in Spanish). We are part of IEUG (Industrial Erlang Users Group). ● Make projects… mainly free software and open source.
  • 4. MILAN 21.11.2015 - MANUEL RUBIO Web 1.0 → 2.0
  • 5. MILAN 21.11.2015 - MANUEL RUBIO ○ Collaboration ○ Interaction ○ Social Networks ○ … Web 2.0
  • 6. MILAN 21.11.2015 - MANUEL RUBIO LAMP GNU/Linux - Apache - MySQL - PHP
  • 7. MILAN 21.11.2015 - MANUEL RUBIO LAMP Internet
  • 8. MILAN 21.11.2015 - MANUEL RUBIO LAMP Internet
  • 9. MILAN 21.11.2015 - MANUEL RUBIO LAMP Internet
  • 10. MILAN 21.11.2015 - MANUEL RUBIO ○ Sessions: cannot be modified at the same time usually. ○ Replicate database: always keeps bottlenecks. ○ Master - Slave: only one server can perform writes. ○ Master - Master: decrease the speed of the database access. ○ Cache: increasing number of requests you’ll needed. New bottleneck and complex flow if you need to purge data. ○ Accelerators & Internal cache for code: to speed up the load of the code. ○ Queues for asynchronous processes or delayed tasks. ○ Concurrency is hard to do or impossible to achieve in the most of the cases. ○ Websockets … well, we need something better. Main issues of these architectures
  • 11. MILAN 21.11.2015 - MANUEL RUBIO What is Erlang? ○ Born at 1986 as a Prolog extension in the Ericsson labs. ○ Language ○ Functional or not? ... better hybrid. ○ Oriented to the Concurrency... Actor Model ○ Virtual Machine or Platform ○ Scheduling and Managing of Processes (supports more than 1.000.000 procs) ○ Memory Management ○ Command line interpreter (shell) ○ Transparent interface for communication between nodes ○ Features ○ Distributed ○ Fault tolerant ○ Scalable ○ Hot code swapping
  • 12. MILAN 21.11.2015 - MANUEL RUBIO ➔ Yaws (Erlang/OTP web server) ➔ Apache (MPM Worker, 250 threads) ➔ Apache (MPM Prefork, 64 processes) This shows KBytes/second vs load Why Erlang fits better?
  • 13. MILAN 21.11.2015 - MANUEL RUBIO When you are stuck in a traffic jam with a Porsche, all you do is burn more gas in idle. Scalability is about building wider roads, not about building faster cars. - Steve Swartz Why Erlang fits better?
  • 14. MILAN 21.11.2015 - MANUEL RUBIO Use cases...
  • 15. MILAN 21.11.2015 - MANUEL RUBIO ● 67 million unique players / month ● 27 million daily players ● 7.5 million concurrent players ● 1 billion events routed / server / day & only use 20-30% CPU & RAM ● 11K messages/second ● Few hundred chat servers managed by only 3 people. ● 99% uptime Use cases...
  • 16. MILAN 21.11.2015 - MANUEL RUBIO Who is using Erlang/OTP? … AND MANY MORE
  • 17. MILAN 21.11.2015 - MANUEL RUBIO What is made in Erlang/OTP? ejabberd RabbitMQ CouchBase Riak VerneMQ Chef
  • 18. MILAN 21.11.2015 - MANUEL RUBIO Erlang/OTP around the World! job opportunities…
  • 19. MILAN 21.11.2015 - MANUEL RUBIO Actor Model vs OOP ○ Hertz vs Cores ○ Oriented Object Programming is attributed to Alan Kay (Smalltalk) ○ Actor Model is attributed to Carl Hewitt by a study published in 1977.
  • 20. MILAN 21.11.2015 - MANUEL RUBIO Actor Model vs OOP
  • 21. MILAN 21.11.2015 - MANUEL RUBIO Erlang Syntax
  • 22. MILAN 21.11.2015 - MANUEL RUBIO Factorial Example A typical example of Factorial
  • 23. MILAN 21.11.2015 - MANUEL RUBIO Factorial Example A typical example of Factorial (C) factorial(int f) { int i; for (i=f-1; i>1; i--) { f = f * i; } return f; }
  • 24. MILAN 21.11.2015 - MANUEL RUBIO Factorial Example A typical example of Factorial (C recursivo) factorial(int f) { if (f <= 1) { return 1; } return f * factorial(f-1); }
  • 25. MILAN 21.11.2015 - MANUEL RUBIO Factorial Example A typical example of Factorial (Erlang) factorial(0) -> 1; factorial(1) -> 1; factorial(N) -> N * factorial(N-1).
  • 26. MILAN 21.11.2015 - MANUEL RUBIO Language Features ○ Unique Assignments > A = 1. 1 > A = 2. ** exception error: no match of right hand side value 2 ○ Simple language: case, if, try...catch & receive. case Value of 12 -> "OK"; _ when is_integer(Value) -> "OK"; _ -> "FAIL"; end. ○ Message passing Pid = spawn(fun micode/0), Pid ! "Ciao mondo!", receive Any -> io:format("OK") end.
  • 27. MILAN 21.11.2015 - MANUEL RUBIO Language Features ○ Long, very long numbers 1> fact:fact(128). 38562048236258042173567706592346364061749310959022359027882840327637340257516554356068 61685885073615340300518330589163475921729322624988577661149552450393577600346447092792 47692495585280000000000000000000000000000000 2> fact:fact(1024). 54185287960588572830769219446838547380015539635380134444828702706832106120733766037331 40984136214586719079188457089807539319941657701873682604541333337219391083675280127649 93769768292516937891165755680659663747947314518404886677672556125188694335251213677274 52196343077013371320579624843312887008843617165469023751839045294473227780840293215872 20618538061628060639254353108221868482392871302616909142113622511446847138885878816292 52104046295315949943900357882410243934315037444113890806181406210863953275235375885018 59845158222959965455854124278913090248694429861092315330757913167574514643630402489082 04429077345618273690305022527969265530729673709907587477931276351047024698896679614621 33026237158973227857814631807156427767644064591085076564783456324457736853810336981776 08049870776704639427260534141677912569773337456803747518667626596166561588468145026333 70425226641418621570468256847733609443267374936766749150989537681129458316266438564790 27816385730291542667725665642276826058264393884514911976419675509290208592713156362983 2909894410527321251872495275013140716764...
  • 28. MILAN 21.11.2015 - MANUEL RUBIO ○ Matching > "Ciao " ++ Who = "Ciao mondo!". "Ciao mondo!" > Who. "mondo!" ○ Sets > A = [1,2,3,4,5], B = [2,4,6], A -- B. [1,3,5] > (A -- B) ++ (B -- A). [1,3,5,6] ○ Binaries {ok, PNG} = file:open("debian-logo.png", [read,binary]), {ok, <<137,"PNG",13,10,26,10,Length:32,"IHDR">>} = file:read(PNG, 16), {ok, <<Width:32, Height:32, Depth:8, Color:8>>} = file:read(PNG, 10), {ok, <<Compression:8, Filter:8, Interlace:8>>} = file:read(PNG, 3), file:close(PNG). Language Features
  • 29. MILAN 21.11.2015 - MANUEL RUBIO Behaviors ○ gen_server: generic servers, actors base. ○ gen_fsm: finite state machines. ○ gen_event: event handlers. ○ supervisor: process supervisors. ○ application: base structure for applications.
  • 30. MILAN 21.11.2015 - MANUEL RUBIO Behaviors -module(elevator). -behaviour(gen_fsm). -compile([export_all]). % to simplify, but should use -export() start_link() -> gen_fsm:start_link({local, ?MODULE}, ?MODULE, [], []). init([]) -> {ok, ground_floor, []}. ground_floor(down, State) -> io:format("Beeep!, incorrect option~n", []), {next_state, ground_floor, State}; ground_floor(up, State) -> io:format("Going to first floor~n", []), {next_state, first_floor, State}. first_floor(down, State) -> io:format("Going to the ground floor~n", []), {next_state, ground_floor, State}; first_floor(up, State) -> io:format("Going to the second floor~n", []), {next_state, second_floor, State}. second_floor(down, State) -> io:format("Going to the first floor~n", []), {next_state, first_floor, State}; second_floor(up, State) -> io:format("Beeep!, incorrect option~n", []), {next_state, second_floor, State}. % add functions to do easy the use of the calls. % these are optional: up_button() -> gen_fsm:send_event(?MODULE, up). down_button() -> gen_fsm:send_event(?MODULE, down). up up down down
  • 31. MILAN 21.11.2015 - MANUEL RUBIO Books about Erlang/OTP
  • 32. MILAN 21.11.2015 - MANUEL RUBIO Books about Elixir
  • 33. MILAN 21.11.2015 - MANUEL RUBIO Leave your feedback on Joind.in! https://m.joind.in/event/codemotion-milan-2015 facebook.com/altenwald linkedin.com/company/altenwald github.com/altenwald @altenwald
  • 34. MILAN 21.11.2015 - MANUEL RUBIO Questions?