SlideShare a Scribd company logo
1 of 63
Download to read offline
From a web application to a
distributed system
How engineering is hard but could be harder without the BEAM
GPad
Born to be a developer with an interest in distributed system.
I develop using many languages like C++, C#, js and ruby. I had fallen in love with
functional programming, especially with elixir, erlang.
● Twitter: https://twitter.com/gpad619
● Github: https://github.com/gpad/
● Medium: https://medium.com/@gpad
CTO & founder of coders51
Web development history ...
Web development history ...
A long a time ago in Galaxy Far Away there was a DB, with some scripts and a
web-server in front of these.
Every request was a bunch of queries on DB and nothing more …
Everything was fine and consistent …
Then …
Today
You have a bunch of services that need to talk to one another.
You need to maintain some state for a time span longer than a http request.
You have more DB (no transaction).
You need to scale.
Why Erlang/Elixir/BEAM
The BEAM
Who came from classic web development, especially with OOP, was trained to:
1. Don’t keep the state in memory
2. Create object/struct during http request
3. Destroy everything at the end
It works!
But ...
But ...
I need to maintain state for more than an http transaction (long operation).
I need to talk/listen to other systems and “react” to these event.
I don’t have a single DB so I don’t have transaction.
I need to keep the connection open and send some data to my “client”.
Evolution ...
Question
How can we create a web application that takes
advantage of the characteristics of the BEAM using
the resources of a single node and eventually scale
to a multi-node application?
Example
Simple e-commerce app where you can:
1. Create users
2. Get products by a third party system
3. Buy some products
4. Pay
Embrace the memory state
Embrace the memory state
We can maintain the state of our app in memory.
In the BEAM world every process is isolated and can keep the state.
Use the DB as the backup of you state.
We can store on it and read from it but don’t use the DB as your state.
Embrace the memory state - Customer
Every customer can be mapped to a process that maintains the state of the customer in
memory and saves it on DB.
If a customer crashes, it doesn’t affect the other customers.
The operation of a single customer is serialized through a single process.
Show me to code ...
Demo!
Embrace the KV pattern
Embrace the KV pattern
We could build our app using the KV pattern.
We could find this “entities” and use the process as boundaries between them.
Every entity should be something that can be executed as a unit.
Every entity should talk to other entities.
The crash of a single entity should affect only a single entities.
Embrace the KV pattern
Use other processes (activities) to interact and keep track of the interaction with other
entities.
Every process can run independently from the others, it can crash and recover to
conclude the interaction with the other entities/systems.
Show me the code ...
UserEntity
Products
Payment
Demo!
Embrace the world ...
Embrace the world ...
With this KV pattern you can “scale” your application horizontally.
Every entity can be “transparently located” inside the cluster.
You can see your application as composed by two different parts: an “application level”
composed by entities and activities and another level “system level” that take care of
distribution.
You should have a “platform” that take care of spinning, move and locate your entities
inside your cluster.
Do you remember something ?!?
Embrace the world - BEAM
The BEAM has “natively” a lot of mechanism to take care of a lot of problems that can
raise from a distributed system.
You can contact a process inside your cluster in a transparently way.
You have a registry (local or remote) that can help you to find an entity (process).
It’s a good solution as a starting point ...
Embrace the world - Library
There are a lot of libraries that can help you in this wide and dangerous world.
riak_core - Now fully managed by community
erleans - Inspired by orleans
lasp - A entire suite of libraries
Show me the code ...
Demo!
Recap
Embrace the memory state - Keep the state of your app in memory and use the DB as
storage. DB is not your App!!!
Embrace the KV pattern - Identify the entities of your app and try to build it as
isolated as possible.
Rule the world - You are running on the BEAM!!!
References
● Thinking like an Erlanger
● Selling Food With Elixir
● To spawn, or not to spawn?
● Life Beyond Distributed Transactions
● Create a riak_core application in elixir
● Erleans
● Lasp
● Repo of the example
Thanks!!!
W la BEAM!!!

More Related Content

Similar to From a web application to a distributed system

The Revolution Will Not Be Centralized
The Revolution Will Not Be CentralizedThe Revolution Will Not Be Centralized
The Revolution Will Not Be CentralizedEdward Faulkner
 
AliExpress’ Way to Microservices - microXchg 2017
AliExpress’ Way to Microservices  - microXchg 2017AliExpress’ Way to Microservices  - microXchg 2017
AliExpress’ Way to Microservices - microXchg 2017juvenxu
 
Introduction to Docker and Containers- Learning Simple
Introduction to Docker and Containers- Learning SimpleIntroduction to Docker and Containers- Learning Simple
Introduction to Docker and Containers- Learning SimpleSandeep Hijam
 
30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software EngineerSean Coates
 
RedisConf18 - Common Redis Use Cases for Cloud Native Apps and Microservices
RedisConf18 - Common Redis Use Cases for Cloud Native Apps and MicroservicesRedisConf18 - Common Redis Use Cases for Cloud Native Apps and Microservices
RedisConf18 - Common Redis Use Cases for Cloud Native Apps and MicroservicesRedis Labs
 
Distributed-ness: Distributed computing & the clouds
Distributed-ness: Distributed computing & the cloudsDistributed-ness: Distributed computing & the clouds
Distributed-ness: Distributed computing & the cloudsRobert Coup
 
HLayer / Cloud Native Best Practices
HLayer / Cloud Native Best PracticesHLayer / Cloud Native Best Practices
HLayer / Cloud Native Best PracticesAymen EL Amri
 
Building a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one weekBuilding a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one weekDr. Felix Raab
 
Offline of web applications
Offline of web applicationsOffline of web applications
Offline of web applicationsFDConf
 
Offline for web - Frontend Dev Conf Minsk 2014
Offline for web - Frontend Dev Conf Minsk 2014Offline for web - Frontend Dev Conf Minsk 2014
Offline for web - Frontend Dev Conf Minsk 2014Jan Jongboom
 
JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)jaxLondonConference
 
Technologies for startup
Technologies for startupTechnologies for startup
Technologies for startupDzung Nguyen
 
Becoming a hyperledger aries developer learn things.online
Becoming a hyperledger aries developer   learn things.onlineBecoming a hyperledger aries developer   learn things.online
Becoming a hyperledger aries developer learn things.onlinedjaber3
 
Become a webdeveloper - AKAICamp Beginner #1
Become a webdeveloper - AKAICamp Beginner #1Become a webdeveloper - AKAICamp Beginner #1
Become a webdeveloper - AKAICamp Beginner #1Jacek Tomaszewski
 
Dev Environments: The Next Generation
Dev Environments: The Next GenerationDev Environments: The Next Generation
Dev Environments: The Next GenerationTravis Thieman
 
Managing Large Flask Applications On Google App Engine (GAE)
Managing Large Flask Applications On Google App Engine (GAE)Managing Large Flask Applications On Google App Engine (GAE)
Managing Large Flask Applications On Google App Engine (GAE)Emmanuel Olowosulu
 
Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1Manoj Ellappan
 
Cs121 Unit Test
Cs121 Unit TestCs121 Unit Test
Cs121 Unit TestJill Bell
 

Similar to From a web application to a distributed system (20)

The Revolution Will Not Be Centralized
The Revolution Will Not Be CentralizedThe Revolution Will Not Be Centralized
The Revolution Will Not Be Centralized
 
AliExpress’ Way to Microservices - microXchg 2017
AliExpress’ Way to Microservices  - microXchg 2017AliExpress’ Way to Microservices  - microXchg 2017
AliExpress’ Way to Microservices - microXchg 2017
 
Ob Essay
Ob EssayOb Essay
Ob Essay
 
Introduction to Docker and Containers- Learning Simple
Introduction to Docker and Containers- Learning SimpleIntroduction to Docker and Containers- Learning Simple
Introduction to Docker and Containers- Learning Simple
 
30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer
 
RedisConf18 - Common Redis Use Cases for Cloud Native Apps and Microservices
RedisConf18 - Common Redis Use Cases for Cloud Native Apps and MicroservicesRedisConf18 - Common Redis Use Cases for Cloud Native Apps and Microservices
RedisConf18 - Common Redis Use Cases for Cloud Native Apps and Microservices
 
Distributed-ness: Distributed computing & the clouds
Distributed-ness: Distributed computing & the cloudsDistributed-ness: Distributed computing & the clouds
Distributed-ness: Distributed computing & the clouds
 
HLayer / Cloud Native Best Practices
HLayer / Cloud Native Best PracticesHLayer / Cloud Native Best Practices
HLayer / Cloud Native Best Practices
 
Building a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one weekBuilding a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one week
 
Offline of web applications
Offline of web applicationsOffline of web applications
Offline of web applications
 
Offline for web - Frontend Dev Conf Minsk 2014
Offline for web - Frontend Dev Conf Minsk 2014Offline for web - Frontend Dev Conf Minsk 2014
Offline for web - Frontend Dev Conf Minsk 2014
 
JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)
 
Technologies for startup
Technologies for startupTechnologies for startup
Technologies for startup
 
Becoming a hyperledger aries developer learn things.online
Becoming a hyperledger aries developer   learn things.onlineBecoming a hyperledger aries developer   learn things.online
Becoming a hyperledger aries developer learn things.online
 
Become a webdeveloper - AKAICamp Beginner #1
Become a webdeveloper - AKAICamp Beginner #1Become a webdeveloper - AKAICamp Beginner #1
Become a webdeveloper - AKAICamp Beginner #1
 
Dev Environments: The Next Generation
Dev Environments: The Next GenerationDev Environments: The Next Generation
Dev Environments: The Next Generation
 
Raptor 2
Raptor 2Raptor 2
Raptor 2
 
Managing Large Flask Applications On Google App Engine (GAE)
Managing Large Flask Applications On Google App Engine (GAE)Managing Large Flask Applications On Google App Engine (GAE)
Managing Large Flask Applications On Google App Engine (GAE)
 
Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1
 
Cs121 Unit Test
Cs121 Unit TestCs121 Unit Test
Cs121 Unit Test
 

More from Gianluca Padovani

Beam me up, scotty (PUG Roma)
Beam me up, scotty (PUG Roma)Beam me up, scotty (PUG Roma)
Beam me up, scotty (PUG Roma)Gianluca Padovani
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Gianluca Padovani
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Gianluca Padovani
 
DDD loves Actor Model and Actor Model loves Elixir
DDD loves Actor Model and Actor Model loves ElixirDDD loves Actor Model and Actor Model loves Elixir
DDD loves Actor Model and Actor Model loves ElixirGianluca Padovani
 
System integration through queues
System integration through queuesSystem integration through queues
System integration through queuesGianluca Padovani
 
La mia prima lezione di pozioni
La mia prima lezione di pozioniLa mia prima lezione di pozioni
La mia prima lezione di pozioniGianluca Padovani
 
Keynote meetup Elixir/Erlang 17 ottobre 2015
Keynote meetup Elixir/Erlang 17 ottobre 2015Keynote meetup Elixir/Erlang 17 ottobre 2015
Keynote meetup Elixir/Erlang 17 ottobre 2015Gianluca Padovani
 
C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...Gianluca Padovani
 

More from Gianluca Padovani (14)

Beam me up, scotty (PUG Roma)
Beam me up, scotty (PUG Roma)Beam me up, scotty (PUG Roma)
Beam me up, scotty (PUG Roma)
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 
DDD loves Actor Model and Actor Model loves Elixir
DDD loves Actor Model and Actor Model loves ElixirDDD loves Actor Model and Actor Model loves Elixir
DDD loves Actor Model and Actor Model loves Elixir
 
Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
 
Beam way of life
Beam way of lifeBeam way of life
Beam way of life
 
System integration through queues
System integration through queuesSystem integration through queues
System integration through queues
 
Beam me up, Scotty
Beam me up, ScottyBeam me up, Scotty
Beam me up, Scotty
 
Docker e git lab
Docker e git labDocker e git lab
Docker e git lab
 
La mia prima lezione di pozioni
La mia prima lezione di pozioniLa mia prima lezione di pozioni
La mia prima lezione di pozioni
 
Keynote meetup Elixir/Erlang 17 ottobre 2015
Keynote meetup Elixir/Erlang 17 ottobre 2015Keynote meetup Elixir/Erlang 17 ottobre 2015
Keynote meetup Elixir/Erlang 17 ottobre 2015
 
C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...
 
Ferrara Linux Day 2011
Ferrara Linux Day 2011Ferrara Linux Day 2011
Ferrara Linux Day 2011
 
OOP vs COP
OOP vs COPOOP vs COP
OOP vs COP
 

Recently uploaded

Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 

Recently uploaded (20)

Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 

From a web application to a distributed system

  • 1. From a web application to a distributed system How engineering is hard but could be harder without the BEAM
  • 2. GPad Born to be a developer with an interest in distributed system. I develop using many languages like C++, C#, js and ruby. I had fallen in love with functional programming, especially with elixir, erlang. ● Twitter: https://twitter.com/gpad619 ● Github: https://github.com/gpad/ ● Medium: https://medium.com/@gpad CTO & founder of coders51
  • 4. Web development history ... A long a time ago in Galaxy Far Away there was a DB, with some scripts and a web-server in front of these. Every request was a bunch of queries on DB and nothing more … Everything was fine and consistent … Then …
  • 5. Today You have a bunch of services that need to talk to one another. You need to maintain some state for a time span longer than a http request. You have more DB (no transaction). You need to scale.
  • 7. The BEAM Who came from classic web development, especially with OOP, was trained to: 1. Don’t keep the state in memory 2. Create object/struct during http request 3. Destroy everything at the end It works!
  • 9. But ... I need to maintain state for more than an http transaction (long operation). I need to talk/listen to other systems and “react” to these event. I don’t have a single DB so I don’t have transaction. I need to keep the connection open and send some data to my “client”.
  • 11. Question How can we create a web application that takes advantage of the characteristics of the BEAM using the resources of a single node and eventually scale to a multi-node application?
  • 12. Example Simple e-commerce app where you can: 1. Create users 2. Get products by a third party system 3. Buy some products 4. Pay
  • 14. Embrace the memory state We can maintain the state of our app in memory. In the BEAM world every process is isolated and can keep the state. Use the DB as the backup of you state. We can store on it and read from it but don’t use the DB as your state.
  • 15. Embrace the memory state - Customer Every customer can be mapped to a process that maintains the state of the customer in memory and saves it on DB. If a customer crashes, it doesn’t affect the other customers. The operation of a single customer is serialized through a single process. Show me to code ...
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23. Demo!
  • 24. Embrace the KV pattern
  • 25. Embrace the KV pattern We could build our app using the KV pattern. We could find this “entities” and use the process as boundaries between them. Every entity should be something that can be executed as a unit. Every entity should talk to other entities. The crash of a single entity should affect only a single entities.
  • 26. Embrace the KV pattern Use other processes (activities) to interact and keep track of the interaction with other entities. Every process can run independently from the others, it can crash and recover to conclude the interaction with the other entities/systems. Show me the code ...
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50. Demo!
  • 52. Embrace the world ... With this KV pattern you can “scale” your application horizontally. Every entity can be “transparently located” inside the cluster. You can see your application as composed by two different parts: an “application level” composed by entities and activities and another level “system level” that take care of distribution. You should have a “platform” that take care of spinning, move and locate your entities inside your cluster. Do you remember something ?!?
  • 53. Embrace the world - BEAM The BEAM has “natively” a lot of mechanism to take care of a lot of problems that can raise from a distributed system. You can contact a process inside your cluster in a transparently way. You have a registry (local or remote) that can help you to find an entity (process). It’s a good solution as a starting point ...
  • 54. Embrace the world - Library There are a lot of libraries that can help you in this wide and dangerous world. riak_core - Now fully managed by community erleans - Inspired by orleans lasp - A entire suite of libraries Show me the code ...
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60. Demo!
  • 61. Recap Embrace the memory state - Keep the state of your app in memory and use the DB as storage. DB is not your App!!! Embrace the KV pattern - Identify the entities of your app and try to build it as isolated as possible. Rule the world - You are running on the BEAM!!!
  • 62. References ● Thinking like an Erlanger ● Selling Food With Elixir ● To spawn, or not to spawn? ● Life Beyond Distributed Transactions ● Create a riak_core application in elixir ● Erleans ● Lasp ● Repo of the example