Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Como concorrência funciona em Elixir?
Search
Amanda
February 03, 2018
Technology
1
210
Como concorrência funciona em Elixir?
Amanda
February 03, 2018
Tweet
Share
More Decks by Amanda
See All by Amanda
Lessons Learned From an Elixir OTP Project
amandasposito
2
56
Aprendizados de um projeto Elixir OTP
amandasposito
4
500
SOLID - Dependency inversion principle
amandasposito
0
66
Programação Funcional & Elixir
amandasposito
3
110
Ecto, você sabe o que é ?
amandasposito
4
230
Novidades no Rails 5
amandasposito
0
92
Rails Engines & RSpec
amandasposito
0
200
Elixir e Phoenix
amandasposito
3
540
Elixir em 5 minutos
amandasposito
1
83
Other Decks in Technology
See All in Technology
OCI Success Journey OCIの何が評価されてる?疑問に答える事例セミナー(2025年2月実施)
oracle4engineer
PRO
2
140
AIエージェント時代のエンジニアになろう #jawsug #jawsdays2025 / 20250301 Agentic AI Engineering
yoshidashingo
8
3.6k
30→150人のエンジニア組織拡大に伴うアジャイル文化を醸成する役割と取り組みの変化
nagata03
0
160
AWSを活用したIoTにおけるセキュリティ対策のご紹介
kwskyk
0
350
RemoveだらけのPHPUnit 12に備えよう
cocoeyes02
0
280
Cracking the Coding Interview 6th Edition
gdplabs
14
28k
JAWS FESTA 2024「バスロケ」GPS×サーバーレスの開発と運用の舞台裏/jawsfesta2024-bus-gps-serverless
ma2shita
2
100
分解して理解する Aspire
nenonaninu
2
1.1k
遷移の高速化 ヤフートップの試行錯誤
narirou
6
1.1k
Aurora PostgreSQLがCloudWatch Logsに 出力するログの課金を削減してみる #jawsdays2025
non97
1
200
AIエージェント入門
minorun365
PRO
31
17k
AI Agent時代なのでAWSのLLMs.txtが欲しい!
watany
2
220
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
Faster Mobile Websites
deanohume
306
31k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.4k
The World Runs on Bad Software
bkeepers
PRO
67
11k
For a Future-Friendly Web
brad_frost
176
9.6k
Into the Great Unknown - MozCon
thekraken
35
1.6k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
27
1.9k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
133
33k
Building an army of robots
kneath
303
45k
Transcript
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!