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

Elixir - Exploring actor-based systems

Elixir - Exploring actor-based systems

Talk given at PartialConf 2017 in Sofia, Bulgaria

Michał Muskała

September 23, 2017
Tweet

More Decks by Michał Muskała

Other Decks in Programming

Transcript

  1. ELIXIR Exploring actor-based systems

  2. ELIXIR Exploring actor-based systems The good parts

  3. THE COMMUNITY

  4. None
  5. MICHAŁ MUSKAŁA http://michal.muskala.eu/ https://github.com/michalmuskala/ @michalmuskala

  6. http://omt.tech/ Orther Mulelid-Tynes Technology, Inc.

  7. THE MODERN COMPUTING

  8. None
  9. None
  10. ACTOR MODEL

  11. Actor Model Communicating Sequential Processes π-calculus Software Transactional Memory

  12. None
  13. FUNCTIONAL PROGRAMMING

  14. • Explicit state • Transformation instead of mutation

  15. – José Valim “Functional programming is associated with concurrency but

    it was not by design. It just happens that, by making the complex parts of our system explicit, solving more complicated issues like concurrency becomes much simpler.”
  16. None
  17. None
  18. Switch Switch

  19. Server Server Browser Endpoints Mobile

  20. None
  21. 2 MILLION CONNECTIONS on a single server https://blog.whatsapp.com/196/1-million- is-so-2011

  22. None
  23. None
  24. http://www.phoenixframework.org/blog/the-road-to-2-million-websocket-connections

  25. ELIXIR CONCURRENT FUNCTIONAL

  26. Sequential code

  27. Sequential code Functional code

  28. None
  29. x1 = async_func1() x2 = async_func2(x1) x3 = async_func3(x2) x4

    = async_func4(x3) x5 = async_func5(x4) x6 = async_func6(x5)
  30. async_func1() |> async_func2() |> async_func3() |> async_func4() |> async_func5() |>

    async_func6()
  31. None
  32. None
  33. OTP

  34. DB Web Mailer Websockets

  35. DB Web Mailer Websockets Supervisor

  36. Application

  37. None
  38. None
  39. app1@node1 app1@node2

  40. – Joe Armstrong “We do not have ONE web-server handling

    2 millions sessions. We have 2 million webservers handling one session each.”
  41. GOALS OF ELIXIR

  42. THE GOALS OF ELIXIR • COMPATIBILITY • EXTENSIBILITY • PRODUCTIVITY

  43. None
  44. THE GOALS OF ELIXIR • COMPATIBILITY • EXTENSIBILITY • PRODUCTIVITY

  45. THE GOALS OF ELIXIR • COMPATIBILITY • EXTENSIBILITY • PRODUCTIVITY

    • PRODUCTIVITY • MAINTAINABILITY • RELIABILITY
  46. COMPATIBILITY

  47. https://elixir-lang.org/crash-course.html

  48. EXTENSIBILITY

  49. defmodule Test do use ExUnit.Case, async: true test "math works"

    do assert 1 + 2 == 2 end end
  50. None
  51. from w in Weather, where: w.prcp <= 0.0 or is_nil(w.prcp),

    order_by: w.city, select: w
  52. defmacro if(condition, clauses) do optimize_boolean(quote do case unquote(condition) do x

    when x in [false, nil] -> unquote(else_clause) _ -> unquote(do_clause) end end) end
  53. PRODUCTIVITY

  54. None
  55. None
  56. None
  57. None
  58. HEXDOCS • https://hexdocs.pm/elixir/String.html • https://hexdocs.pm/elixir/1.5.0/String.html • https://hexdocs.pm/phoenix/Phoenix.Channel.html • https://hexdocs.pm/phoenix/1.2.0/Phoenix.Channel.html

  59. None
  60. None
  61. None
  62. None
  63. None
  64. DEMO

  65. MAINTAINABILITY

  66. RELIABILITY

  67. HOW DO I START?

  68. elixir-lang.org

  69. None
  70. None
  71. • http://elixir-lang.org • http://www.erlang.org • http://nerves-project.com • http://www.phoenixframework.org/

  72. ELIXIR Exploring actor-based systems

  73. None