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
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
89
Aprendizados de um projeto Elixir OTP
amandasposito
4
590
SOLID - Dependency inversion principle
amandasposito
0
81
Programação Funcional & Elixir
amandasposito
3
130
Ecto, você sabe o que é ?
amandasposito
4
240
Novidades no Rails 5
amandasposito
0
99
Rails Engines & RSpec
amandasposito
0
230
Elixir e Phoenix
amandasposito
3
570
Elixir em 5 minutos
amandasposito
1
93
Other Decks in Technology
See All in Technology
Oracle Cloud Infrastructure:2026年1月度サービス・アップデート
oracle4engineer
PRO
0
190
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
2.9k
Deno・Bunの標準機能やElysiaJSを使ったWebSocketサーバー実装 / ラーメン屋を貸し切ってLT会! IoTLT 2026新年会
you
PRO
0
130
変化するコーディングエージェントとの現実的な付き合い方 〜Cursor安定択説と、ツールに依存しない「資産」〜
empitsu
3
670
今日から始めるAmazon Bedrock AgentCore
har1101
4
200
Data Hubグループ 紹介資料
sansan33
PRO
0
2.7k
最速で価値を出すための プロダクトエンジニアのツッコミ術
kaacun
1
410
KubeCon + CloudNativeCon NA ‘25 Recap, Extensibility: Gateway API / NRI
ladicle
0
160
月間数億レコードのアクセスログ基盤を無停止・低コストでAWS移行せよ!アプリケーションエンジニアのSREチャレンジ💪
miyamu
0
230
AIとともに歩む情報セキュリティ / Information Security with AI
kanny
4
2.8k
ゼロから始めたFindy初のモバイルアプリ開発
grandbig
2
530
AWS Devops Agent ~ 自動調査とSlack統合をやってみた! ~
kubomasataka
2
270
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
BBQ
matthewcrist
89
10k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
290
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
100
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.4k
WENDY [Excerpt]
tessaabrams
9
36k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
150
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
400
RailsConf 2023
tenderlove
30
1.3k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
61
49k
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!