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
240
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
More Decks by Amanda
See All by Amanda
Lessons Learned From an Elixir OTP Project
amandasposito
2
98
Aprendizados de um projeto Elixir OTP
amandasposito
4
640
SOLID - Dependency inversion principle
amandasposito
0
92
Programação Funcional & Elixir
amandasposito
3
130
Ecto, você sabe o que é ?
amandasposito
4
250
Novidades no Rails 5
amandasposito
0
100
Rails Engines & RSpec
amandasposito
0
240
Elixir e Phoenix
amandasposito
3
590
Elixir em 5 minutos
amandasposito
1
100
Other Decks in Technology
See All in Technology
OCI Oracle AI Database Services新機能アップデート(2026/03-2026/05)
oracle4engineer
PRO
0
250
ChatworkとBPaaS 異なる特性で学んだAI機能開発の ベストプラクティス
kubell_hr
2
2.9k
SIer20年! 培ったスキルがスタートアップで輝く時
shucho0103
0
470
DevOps Agentで始めるAWS運用 〜フロンティアエージェントが変える運用の現場〜
nyankotaro
1
270
Databricks 月刊サービスアップデート 2026年05月号
tyosi1212
0
210
サイバーセキュリティ概論 / Introduction to Cybersecurity
ks91
PRO
0
170
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.8k
2026.06.13_AI時代に事業会社が「SIer出身エンジニア」を求める理由 / Why Businesses Seek Engineers with a System Integrator Background in the AI Era
jumtech
0
560
速さだけじゃない! VoidZero ツールが移行先に選ばれる理由
mizdra
PRO
6
760
コードレビューを制するチームがソフトウェアデリバリーのフローを制す / Beyond Code Review: Distributing Its Responsibilities Across the SDLC
mtx2s
4
1.2k
はじめてのDatadog
kairim0
0
290
美味しいスイスチーズを作ろう🧀🐭
taigamikami
1
250
Featured
See All Featured
Docker and Python
trallard
47
3.9k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
200
Code Reviewing Like a Champion
maltzj
528
40k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
440
Exploring anti-patterns in Rails
aemeredith
3
400
Embracing the Ebb and Flow
colly
88
5.1k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
55k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
600
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!