Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Solid Ground
Saša Jurić
May 20, 2017
Programming
16
1k
Solid Ground
Empex, 2017
Saša Jurić
May 20, 2017
Tweet
Share
More Decks by Saša Jurić
See All by Saša Jurić
sasajuric
0
120
sasajuric
3
380
sasajuric
3
510
sasajuric
3
230
sasajuric
2
560
sasajuric
0
92
sasajuric
3
740
sasajuric
1
160
sasajuric
0
76
Other Decks in Programming
See All in Programming
sansuke05
1
140
rarous
0
170
naokioouchi
1
280
korosuke613
2
250
grapecity_dev
0
170
grapecity_dev
0
180
koheisakata
0
100
bkuhlmann
2
310
manfredsteyer
PRO
0
250
emmaglorypraise
0
130
dbrumann
0
110
afilina
PRO
0
140
Featured
See All Featured
philnash
9
580
lara
15
2.7k
carmenhchung
31
1.5k
eitanlees
112
10k
reverentgeek
27
2k
nonsquared
81
3.4k
rocio
155
11k
addyosmani
311
21k
lauravandoore
437
28k
holman
461
280k
sachag
446
36k
smashingmag
230
18k
Transcript
Solid ground @sasajuric aircloak.com
pattern matching OTP metaprogramming mix Distillery the pipe operator Cowboy
Plug Phoenix Ecto functional programming community GenStage Credo ExUnit Combine Poolboy Nerves
None
LFE Erlang OTP BEAM Elixir Phoenix GenStage Ecto Plug magic
source magic beneficiaries Cowboy Poolboy
long-running system many tasks soft real-time finite time program all-or-nothing
hard real-time
scheduler scheduler scheduler scheduler BEAM CPU CPU CPU CPU
frequent context switches
t1 t2 t3 t4 t5 10 s 1 ms 1
ms 1 ms 1 ms
t1 BEAM scheduler t2 t3 t4 t5 t1
t1 cooperative scheduler t2 t3 t4 t5
thread 1 thread n long running task long running task
blocked cooperative scheduler …
thread 1 thread n long running task long running task
BEAM scheduler … not blocked :-)
activities as runtime citizens
send(pid, :please_stop)
mref = Process.monitor(pid) send(pid, :please_stop) receive do {:DOWN, ^mref, :process,
^pid, _reason} -> :ok end
mref = Process.monitor(pid) send(pid, :please_stop) receive do {:DOWN, ^mref, :process,
^pid, _reason} -> :ok after :timer.seconds(5) -> Process.exit(pid, :kill) receive do {:DOWN, ^mref, :process, ^pid, _reason} -> :ok end end
task = Task.async(fn -> ... end) case Task.yield(task, :timer.seconds(5)) do
{:ok, result} -> do_something(result) nil -> Task.shutdown(task, :brutal_kill) end
shared-nothing concurrency
Process heap resources
process-owned “stuff” is released
supervision tree
system backend frontend chat history repo cache endpoint
system backend chat history repo
supervisor foundations frequent context switching activities as runtime citizens observable
process termination stoppable processes shared-nothing concurrency
syntax developer friendliness ecosystem
runtime guarantees syntax developer friendliness ecosystem
Scales of Justice image taken from clipartfox.com How Erlang does
scheduling http://jlouisramblings.blogspot.hr/2013/01/how-erlang-does-scheduling.html Erlang scheduler details https://hamidreza-s.github.io/erlang/scheduling/real-time/preemptive/migration/ 2016/02/09/erlang-scheduler-details.html The BEAM book https://github.com/happi/theBeamBook BEAM wisdoms http://beam-wisdoms.clau.se/en/latest/ Web based observer https://github.com/shinyscorpion/wobserver Recon http://ferd.github.io/recon/ Erlang performance lab http://www.erlang.pl/