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
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
React 19時代のコンポーネント設計ベストプラクティス
uhyo
15
5.2k
22nd ACRi Webinar - 1Finity Tamura-san's slide
nao_sumikawa
0
130
30分でわかる「ネットワーク図の描き方入門」/infraengbooks56
corestate55
1
340
Three-Legged OAuth in AgentCore Gateway
hironobuiga
1
110
GitHub Copilot CLI 現状確認会議(2026年2月のすがた)
torumakabe
2
360
プレビュー版のDevOpsエージェントを現段階で触ってみた
ad_motsu
1
170
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
15
94k
Claude Code で画面の仕様書を作ろう
zozotech
PRO
0
300
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
2
1k
ブロックテーマ、WordPress でウェブサイトをつくるということ / 2026.02.07 Gifu WordPress Meetup
torounit
0
220
私たち準委任PdEは2つのプロダクトに挑戦する ~ソフトウェア、開発支援という”二重”のプロダクトエンジニアリングの実践~ / 20260212 Naoki Takahashi
shift_evolve
PRO
3
340
AWSが推進するAI駆動開発ライフサイクル入門 〜 AI駆動開発時代に必要な人材とは 〜/ introduction_to_aidlc_and_skills
fatsushi
6
3.2k
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Six Lessons from altMBA
skipperchong
29
4.2k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
120
Site-Speed That Sticks
csswizardry
13
1.1k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
330
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
210
Unsuck your backbone
ammeep
671
58k
What's in a price? How to price your products and services
michaelherold
247
13k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Tell your own story through comics
letsgokoyo
1
820
Accessibility Awareness
sabderemane
0
65
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
800
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!