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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Amanda
February 03, 2018
Technology
1
230
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
94
Aprendizados de um projeto Elixir OTP
amandasposito
4
600
SOLID - Dependency inversion principle
amandasposito
0
86
Programação Funcional & Elixir
amandasposito
3
130
Ecto, você sabe o que é ?
amandasposito
4
240
Novidades no Rails 5
amandasposito
0
100
Rails Engines & RSpec
amandasposito
0
230
Elixir e Phoenix
amandasposito
3
580
Elixir em 5 minutos
amandasposito
1
97
Other Decks in Technology
See All in Technology
Snowflakeデータ基盤で挑むAI活用 〜4年間のDataOpsの基礎をもとに〜
kaz3284
1
330
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.4k
LINE Messengerの次世代ストレージ選定
lycorptech_jp
PRO
17
7k
LINEアプリ開発のための Claude Code活用基盤の構築
lycorptech_jp
PRO
1
1.3k
Datadog Cloud Cost Management で実現するFinOps
taiponrock
PRO
0
100
【PyCon mini Shizuoka 2026】生成AI時代に画像処理やオーディオ処理のノードエディターを作る理由
kazuhitotakahashi
0
260
Snowflake Night #2 LT
taromatsui_cccmkhd
0
310
【SLO】"多様な期待値" と向き合ってみた
z63d
2
290
ソフトウェアアーキテクトのための意思決定術: Create Decision Readiness—The Real Skill Behind Architectural Decision
snoozer05
PRO
27
8.3k
AIエンジニア Devin と歩む、自律型運用プロセスの構築
a2ito
0
600
LY Tableauでの Tableau x AIの実践 (at Tableau Now! - 2026-02-26)
yoshitakaarakawa
0
1.2k
Lookerの最新バージョンv26.2がやばい話
waiwai2111
1
150
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
AI: The stuff that nobody shows you
jnunemaker
PRO
3
340
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
130
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Abbi's Birthday
coloredviolet
2
5.1k
Technical Leadership for Architectural Decision Making
baasie
3
270
It's Worth the Effort
3n
188
29k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.7k
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!