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
Concurrent and Resilient Connections to Outside...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Andrea Leopardi
May 11, 2016
Programming
330
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Concurrent and Resilient Connections to Outside the BEAM
Andrea Leopardi
May 11, 2016
More Decks by Andrea Leopardi
See All by Andrea Leopardi
Agentic Elixir
whatyouhide
0
500
The Umbrella and the Range
whatyouhide
0
67
gen_statem - OTP's Unsung Hero
whatyouhide
2
350
The World is a Network (and We Are Just Nodes)
whatyouhide
1
260
BEAM: The Perfect Fit for Networks
whatyouhide
1
270
Update from the Elixir team - 2022
whatyouhide
0
460
Testing Asynchronous OTP
whatyouhide
1
580
Elixir Sightseeing Tour
whatyouhide
0
490
Mint - Disrupting HTTP clients
whatyouhide
0
310
Other Decks in Programming
See All in Programming
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
230
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
170
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
870
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.3k
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
980
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.5k
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
220
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.5k
Datadog LLM Observabilityで実現する 安全なLLM Usage 管理
3150
0
120
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.6k
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.6k
ふつうのFeature Flag実践入門
irof
8
4.2k
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
250
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
740
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
170
How to Talk to Developers About Accessibility
jct
2
260
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
160
Unsuck your backbone
ammeep
672
58k
Un-Boring Meetings
codingconduct
0
330
Into the Great Unknown - MozCon
thekraken
41
2.6k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
220
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
Transcript
outside CONCURRENT RESILIENT and CONNECTIONS to the BEAM
ERLANG VM mnesia message passing ets
ERLANG VM key-value store relational db message queue
ERLANG VM key-value store relational db message queue
the outside world is SCARY
ANDREA LEOPARDI @WHATYOUHIDE
Gothenburg, Sweden
FOOTBALL ADDICTS
GENSERVER TCP
SILLY the way
defmodule Redis do def command(cmd) do end end
defmodule Redis do def command(cmd) do {:ok, sock} = :gen_tcp.connect(...)
:gen_tcp.send(sock, encode(cmd)) {:ok, data} = :gen_tcp.recv(sock, 0) :gen_tcp.close(sock) decode(data) end end
defmodule Redis do def command(cmd) do {:ok, sock} = :gen_tcp.connect(...)
:gen_tcp.send(sock, encode(cmd)) {:ok, data} = :gen_tcp.recv(sock, 0) :gen_tcp.close(sock) decode(data) end end
defmodule Redis do def command(cmd) do {:ok, sock} = :gen_tcp.connect(...)
:gen_tcp.send(sock, encode(cmd)) {:ok, data} = :gen_tcp.recv(sock, 0) :gen_tcp.close(sock) decode(data) end end
defmodule Redis do def command(cmd) do {:ok, sock} = :gen_tcp.connect(...)
:gen_tcp.send(sock, encode(cmd)) {:ok, data} = :gen_tcp.recv(sock, 0) :gen_tcp.close(sock) decode(data) end end
defmodule Redis do def command(cmd) do {:ok, sock} = :gen_tcp.connect(...)
:gen_tcp.send(sock, encode(cmd)) {:ok, data} = :gen_tcp.recv(sock, 0) :gen_tcp.close(sock) decode(data) end end
defmodule Redis do def command(cmd) do {:ok, sock} = :gen_tcp.connect(...)
:gen_tcp.send(sock, encode(cmd)) {:ok, data} = :gen_tcp.recv(sock, 0) :gen_tcp.close(sock) decode(data) end end
opening NEW connections is EXPENSIVE
GENSERVER keeping the socket in a
TWO WAYS blocking non-blocking
TWO WAYS blocking
CLIENT GENSERVER socket socket send() recv()
defmodule Redis do def command(conn, cmd) do sock = checkout(conn)
# send and recv checkin(conn, sock) end end
defmodule Redis do def command(conn, cmd) do sock = checkout(conn)
# send and recv checkin(conn, sock) end end
{:error, :checked_out} :queue.in() VS
POOLING :|
TWO WAYS non-blocking
active: true {:noreply, _} + GenServer.reply/2 +
client Redis client client GenServer
tcp is FULL DUPLEX
client Redis client client Sender Receiver
TWO WAYS blocking non-blocking copies less data + needs pooling
- doesn't use full duplex - enc/dec on client + - copies more data + doesn't need pooling + uses full duplex - enc/dec in server
RESIL IENCY
Redis GenServer
Redis GenServer
{:tcp_closed, reason} backoff + reconnect
hex.pm/packages/connection gen_
Connection GenServer
init/1 connect/2 disconnect/2 handle_call/3 handle_cast/2 handle_info/2 terminate/2 code_change/3 {:disconnect, reason,
state} {:backoff, timeout, state}
sync/async CONNECT
SYNC start_link {:ok, pid} init() connect
ASYNC start_link {:ok, pid} init() connect connect()
You now allow initializations with fewer guarantees: they went from
"the connection is available" to "the connection manager is available". Fred Hebert
CONNECTION TALKING CONCURRENCY RESILIENCY
@whatyouhide