Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Solid Ground

Solid Ground

ElixirDaze 2017

Video available at https://www.youtube.com/watch?v=5SbWapbXhKo

78d85ea26770975ea8c497d7bd722d55?s=128

Saša Jurić

March 06, 2017
Tweet

Transcript

  1. Solid ground @sasajuric aircloak.com

  2. None
  3. long-running system many tasks soft real-time finite time program all-or-nothing

    hard real-time
  4. NIFs

  5. scheduler scheduler scheduler scheduler BEAM CPU CPU CPU CPU

  6. frequent context switches

  7. t1 t2 t3 t4 t5 10 s 1 ms 1

    ms 1 ms 1 ms
  8. t1 t2 t3 t4 t5 t1 BEAM scheduler

  9. t2 t3 t4 t5 t1 cooperative scheduler

  10. thread 1 thread n … long running task long running

    task blocked cooperative scheduler
  11. thread 1 thread n … long running task long running

    task not blocked :-) BEAM scheduler
  12. activities as runtime citizens

  13. send(pid, :please_stop)

  14. mref = Process.monitor(pid) send(pid, :please_stop) receive do {:DOWN, ^mref, :process,

    ^pid, _reason} -> :ok end
  15. 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
  16. 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
  17. shared-nothing concurrency

  18. Process heap resources

  19. process-owned “stuff” is released

  20. supervision tree

  21. system backend frontend chat history repo cache endpoint

  22. system backend chat history repo

  23. supervisor foundations frequent context switching activities as runtime citizens observable

    process termination stoppable processes shared-nothing concurrency
  24. runtime 
 guarantees syntax developer friendliness ecosystem

  25. Image credit Scales of Justice