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

Simplifying systems with Elixir - Belgrade

Simplifying systems with Elixir - Belgrade

78d85ea26770975ea8c497d7bd722d55?s=128

Saša Jurić

October 25, 2018
Tweet

Transcript

  1. Simplifying systems with Elixir @sasajuric aircloak.com

  2. Elixir functional concurrent

  3. process ... foo(...) bar(...) ...

  4. functional Elixir modules and functions immutable data first-class functions

  5. ... spawn(fn -> ... end) ...

  6. process A ... foo(...) bar(...) ... process B ... baz(...)

    qux(...) ...
  7. send( process_b, some_message ) receive do message -> handle(message) end

    process a process b
  8. BEAM (Erlang VM)

  9. BEAM (Erlang VM)

  10. scheduler scheduler scheduler scheduler BEAM (Erlang VM) CPU CPU CPU

    CPU
  11. concurrent functional

  12. activities incoming requests background jobs in-memory state load control …

  13. managing activities multiple OS processes 3rd party products service managers

  14. None
  15. None
  16. uniformity simpler development simpler testing simpler deployment simpler maintenance improved

    collaboration
  17. None
  18. theerlangelist.com

  19. git clone https://github.com/sasa1977/erlangelist.git mix deps.get && pushd assets && npm

    install && popd iex -S mix phx.server
  20. None
  21. serving requests

  22. http listener https listener

  23. http listener https listener handler 1 handler 2 handler n

  24. usage stats

  25. stats collector handler handler handler

  26. stats collector disk writer

  27. def store(path, data) do File.write!( path, :erlang.term_to_binary(data) ) end

  28. def read(path, default) do path |> File.read!() |> :erlang.binary_to_term() rescue

    ArgumentError -> default end
  29. cleanup

  30. scheduler cleanup job periodically starts

  31. HTTPS

  32. our system CA server certificate request challenge info challenge

  33. certifier http server usage stats

  34. dev CA server

  35. service management

  36. defmodule StatsCollector do def start_link() do # ... end #

    ... end
  37. Supervisor.start_link( [ StatsCollector, Cleanup ], # .. )

  38. supervisor stats collector cleanup

  39. supervisor worker

  40. 1

  41. 1 2

  42. 1 2 3 4 5

  43. 1 2 6 9 7 8 3 4 5

  44. erlangelist usage stats web

  45. usage stats stats collector cleanup

  46. web ACME server main site certifier

  47. None
  48. technical feature built-in options services GenServer, Task service manager Supervisor

    service registry Registry k-v ets, mnesia web server phoenix, plug, cowboy periodical jobs :timer, quantum, periodic load regulation jobs, safetyvalve, sbroker concurrent flows Flow, GenStage
  49. Elixir in a nutshell start simple go far

  50. Elixir guides Phoenix guides Learning resources Elixir forum

  51. 40% off using code ctwelixirbg18 at manning.com slides available at

    bit.ly/elixirbg102018