Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Como concorrência funciona em Elixir?
Search
Amanda
February 03, 2018
Technology
250
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Como concorrência funciona em Elixir?
Amanda
February 03, 2018
Transcript
73 slides
Como concorrência funciona em Elixir?
amandasposito.com.br @amsposito linkedin.com/in/amandasposito
None
https://plataformatec.recruitee.com/
Por que falar sobre concorrência?
None
O que é concorrência?
Paralelismo?
Concorrência vs Paralelismo
Por que isso é importante?
http://www.gotw.ca/publications/concurrency-ddj.htm
Como isso interfere no nosso software?
Mas e como isso funciona em Elixir?
Estado explicito
Processos
Troca de mensagens
Processos são a base do modelo de concorrência em Elixir
São totalmente isolados
Processos rodam concorrentemente e podem rodar em paralelo
Troca de mensagens
None
Processos podem ser supervisionados
Como isso funciona exatamente?
Scheduler
CPU Scheduler Scheduler CPU Scheduler CPU Scheduler CPU BEAM
CPU Scheduler Scheduler CPU Scheduler CPU Scheduler CPU BEAM
CPU Scheduler Scheduler CPU Scheduler CPU Scheduler CPU BEAM
CPU Scheduler Scheduler CPU Scheduler CPU Scheduler CPU BEAM
CPU Scheduler Scheduler CPU Scheduler CPU Scheduler CPU BEAM
CPU Scheduler Scheduler CPU Scheduler CPU Scheduler CPU BEAM
CPU Scheduler Scheduler CPU Scheduler CPU Scheduler CPU BEAM
O que acontece quando um processo falha?
Let it crash
None
Mas como?
Processos não são isolados?
Sim
Arvore de Supervisão
SUP Process Process Process
Estrategias de restart
One for one
SUP Process Process Process
SUP Process Process Process
SUP Process Process Process
One for all
SUP Process Process Process
SUP Process Process Process
SUP Process Process Process
Rest for one
SUP Process Process Process
SUP Process Process Process
SUP Process Process Process
Tolerância a falhas
Como que nós usamos processos em Elixir então?
Task
{:ok, task1} = Task.async(fn -> do_some_work() end) {:ok, task2} =
Task.async(fn -> do_more_work() end) Task.await(task1) Task.await(task2)
Agent
{:ok, pid} = Agent.start_link(fn -> 0 end) value1 = Agent.get(pid,
fn x -> x end) Agent.update(pid, fn x -> x + 1 end) value2 = Agent.get(pid, fn x -> x end)
GenServer
E esse tal de OTP?
None
Task, Agent e Genserver são OTP complient
Preciso implementar isso tudo na mão?
Sim e não
Recapitulando
Concorrência é conseguir realizar várias tarefas no mesmo intervalo de
tempo
Processos são muito importantes para concorrência
Processos podem ser Supervisionados
Arvore de supervisão acontece quando temos vários supervisores
Task é uma abstração para controlar processos simples
Agent é uma abstração para lidarmos com Estado
GenServer é uma abstração que pode controlar processos e estados.
Obrigada!
More Decks by Amanda
See All by Amanda
Lessons Learned From an Elixir OTP Project
amandasposito
2
110
Aprendizados de um projeto Elixir OTP
amandasposito
4
660
SOLID - Dependency inversion principle
amandasposito
0
110
Programação Funcional & Elixir
amandasposito
3
150
Ecto, você sabe o que é ?
amandasposito
4
260
Novidades no Rails 5
amandasposito
0
110
Rails Engines & RSpec
amandasposito
0
260
Elixir e Phoenix
amandasposito
3
600
Elixir em 5 minutos
amandasposito
1
110
Other Decks in Technology
See All in Technology
Biohub - Cell Tracking During Development 5th place solution
rist
0
170
Agent Harnessはどう作る?事例から学ぶAI Agentの設計思想
sergicalsix
0
330
お風呂場をサーバルームにしよう
yusuke427
0
290
Where Should Platform Complexity Live? Lessons from a Cross-Team PR Preview Platform
taiki45
0
120
こんなに変わった! AWSネットワークの常識
shotashiratori
13
8.6k
OpenTelemetryで変わった 新時代のCloudWatchメトリクス監視
tsukuboshi
0
370
_マネジメントする人される人ナイト_2026__良いチームを作っていきたい_お気持ち_.pdf
xkxaxkx
0
730
人間+AIを「チーム」としてプロセスを再設計する
littlehands
4
3.3k
契約書SaaSにAIエージェントを組み込む
sansantech
PRO
0
170
SSFの現在地 ― CAEP/RISCからAI Identityへ
oidfj
0
460
Quick Automate | 目指せ Quick マスター 12
inariku
PRO
1
120
AI対話型分析を作成し、リリースするまでの話 / The Road to Release: Buiding AI Conversational Analytics
yappli_developers
0
150
Featured
See All Featured
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
400
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.3k
Test your architecture with Archunit
thirion
2
2.5k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.3k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Marketing to machines
jonoalderson
1
6k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
460
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
850
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
610
RailsConf 2023
tenderlove
30
1.6k