High Availability

High Availability

ElixirConf Europe

78d85ea26770975ea8c497d7bd722d55?s=128

Saša Jurić

April 23, 2015
Tweet

Transcript

  1. iex(1)> high_availability @sasajuric aircloak.com

  2. Erlang 
 (the language) Elixir LFE Erlang VM (BEAM)

  3. highly_available ≈ works_almost_always

  4. optional?(highly_available) # false

  5. easy?(highly_available) # false

  6. None
  7. highly_available do # the code here magically works end #doesntworklikethat

  8. fault-tolerance scalability + responsiveness = high availability

  9. A B D E F C

  10. send(pid, message) A B message = receive ...

  11. def loop(state) do receive do message -> new_state = handle(state,

    message) loop(new_state) end end
  12. bank account balance {:deposit, amount} {:withdraw, amount} :balance amount

  13. OS process or thread Erlang process

  14. db connection background job request handler state request handler request

    handler request handler request handler request handler state state state background job background job background job db connection db connection db connection
  15. A B C D E F

  16. A exit message B C D E F

  17. supervisor worker worker

  18. S S S W W S W W W S

    W W
  19. scheduler scheduler scheduler scheduler CPU CPU CPU CPU VM

  20. VM VM VM VM VM

  21. VM send(pid, message) VM 1 send(pid, message) VM 2

  22. shared-nothing concurrency process crash propagation + some VM magic =

    fault tolerance
 scalability
 responsiveness
  23. None
  24. 3rd party data source transform data push server browsers bets

    validation
  25. Data transformation 1.Receive TCP stream" 2.Assemble XML messages" 3.Update the

    model" 4.Store to database" 5.Serialize the model" 6.Dispatch
  26. receive stream assemble messages update model store to database serialize

    data dispatch
  27. receive stream assemble messages update model store to database serialize

    data dispatch message 6 message 5 message 4 message 3 message 2 message 1
  28. receive stream assemble messages update model store to database serialize

    data dispatch
  29. storing to database queuing bet odds storing bet odds

  30. match 1 match 3 match 2

  31. update model serialize data dispatch match 1 match 3 match

    2
  32. None
  33. None
  34. None
  35. None
  36. None