O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Distributed system in Elixir

770 visualizações

Publicada em

Harucon 2016 에서 발표한 "Elixir를 이용한 분산시스템" 입니다.

Publicada em: Tecnologia
  • Seja o primeiro a comentar

Distributed system in Elixir

  1. 1. ELIXIR를 이용한 분산시스템 HARU CONFERENCE
  2. 2. OVERVIEW ▸ Erlang/OTP ▸ Elixir ▸ Distributed systems ▸ Wrapping up
  3. 3. ERALNG/OTP
  4. 4. 1986 1998 2016 Ericsson 개발 오픈소스화 Erlang OTP 19.x
  5. 5. 1986 1998 2016 Ericsson 개발 오픈소스화 Erlang OTP 19.x 1995 Java
  6. 6. SWITCH SWITCH http://stackoverflow.com/questions/1636455/where-is-erlang-used-and-why/1637137#1637137
  7. 7. CONCURRENCY. DISTRIBUTION. FAULT TOLERANCE.
  8. 8. SERVER SERVER http://stackoverflow.com/questions/1636455/where-is-erlang-used-and-why/1637137#1637137
  9. 9. ERLANG/OTP ▸ Functional language ▸ Immutable variables ▸ Strong, dynamic typing ▸ Actor model ▸ OTP ▸ Behavior
  10. 10. FUNCTIONAL LANGUAGE FUNCTION(X) A B
  11. 11. FUNCTIONAL LANGUAGE FUNCTION(X) FUNCTION(X) FUNCTION(X)
  12. 12. ACTOR MODEL Actor = Lightweight Process + Data + Code ACTOR CODE DATA PROCESS
  13. 13. ACTOR MODEL ACTOR CODE DATA PROCESS ACTOR CODE DATA PROCESS message message queuemessage queue
  14. 14. ACTOR MODEL ACTOR CODE DATA PROCESS message queue message
  15. 15. ACTOR MODEL ACTOR CODE DATA PROCESS message ACTOR CODE DATA PROCESS message
  16. 16. ACTOR MODEL LIFE CYCLE INITIALIZE TERMINATE RECEIVE-EVALUATE LOOP Designing for Scalability with Erlang/OTP start stop
  17. 17. ACTOR MODEL https://viethip.com/category/erlang/ process process process ERLANG VM GARBAGE COLLECTOR
  18. 18. ACTOR MODEL
  19. 19. ACTOR MODEL 노동자 관리자 사장
  20. 20. ACTOR MODEL WORKER SUPERVISOR ROOT_SUPERVISOR
  21. 21. OTP-BEHAVIOR ▸ GenServer ▸ Supervisor ▸ GenEvent ▸ GenFsm ▸ GenStatem
  22. 22. OTP-BEHAVIOR ▸ GenServer ▸ Supervisor ▸ GenEvent ▸ GenStatem
  23. 23. GENSERVER GENERIC SERVER SERVER CLIENT CLIENT CLIENT http://erlang.org/doc/design_principles/gen_server_concepts.html requestresponse
  24. 24. SUPERVISOR ACTOR ACTOR ACTOR SUPERVISOR http://erlang.org/doc/design_principles/gen_server_concepts.html
  25. 25. SUPERVISOR ACTOR ACTOR WORKER SUPERVISOR ACTOR ACTOR ACTOR SUPERVISOR http://erlang.org/doc/design_principles/gen_server_concepts.html SUPERVISION TREE
  26. 26. “Erlang was designed for writing concurrent programs that run forever.” A History of Erlang - Joe Amstrong
  27. 27. ELIXIR
  28. 28. 2012 2016 José Valim 개발 Elixir 1.3.x
  29. 29. ELIXIR ▸ Functional language ▸ Immutable variables ▸ Strong, dynamic typing ▸ Actor model
  30. 30. ELIXIR BEAM OTP ERLANG ELIXIR
  31. 31. ELIXIR ▸ Support tools ▸ ExUnit - Unit test ▸ Mix - Build tool ▸ Standard library ▸ Metaprogramming ▸ Ecosystem ▸ Hex - Package management ▸ Phoenix - Web framework
  32. 32. DISTRIBUTED SYSTEMS
  33. 33. “A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable” Leslie Lamport
  34. 34. ERLANG CLUSTER NODE A distributed Erlang system consists of a number of Erlang runtime systems communicating with each other. Each such runtime system is called a node.
  35. 35. ERLANG CLUSTER NODE NODE NODE NODE
  36. 36. ERLANG CLUSTER NODE NODE ACTOR ACTOR message
  37. 37. WHY DISTRIBUTED SYSTEMS?
  38. 38. WHY DISTRIBUTED SYSTEMS? ▸ Enhanced Performance ▸ Higher Availability
  39. 39. PERFORMANCE ▸ Latency ▸ Throughput ▸ Computing power
  40. 40. PERFORMANCE NODE CLIENT
  41. 41. PERFORMANCE CLIENT BUSINESS NODE LOADBALANCER ENDPOINT NODE ENDPOINT NODE BUSINESS NODE
  42. 42. PERFORMANCE BUSINESS NODE ENDPOINT NODE PAYMENT GROUP BUSINESS NODE BUSINESS NODE LOGIN GROUP BUSINESS NODE
  43. 43. PERFORMANCE BUSINESS NODE ENDPOINT NODE PAYMENT GROUP BUSINESS NODE BUSINESS NODE LOGIN GROUP BUSINESS NODE Stateless
  44. 44. PERFORMANCE CLIENT BUSINESS NODE LOADBALANCER ENDPOINT NODE ENDPOINT NODE BUSINESS NODE CACHE STATEFUL #1
  45. 45. PERFORMANCE CLIENT BUSINESS NODE LOADBALANCER ENDPOINT NODE ENDPOINT NODE BUSINESS NODE CACHE STATEFUL #1
  46. 46. PERFORMANCE BUSINESS NODE + LOCAL MEMORY LOADBALANCER ENDPOINT NODE ENDPOINT NODE STATEFUL #2 BUSINESS NODE + LOCAL MEMORY CLIENT
  47. 47. PERFORMANCE CLIENT#1 BUSINESS NODE + LOCAL MEMORY LOADBALANCER ENDPOINT NODE ENDPOINT NODE CLIENT#2 STATEFUL #2 BUSINESS NODE + LOCAL MEMORY {session : client#1} {session : client#2}
  48. 48. PERFORMANCE BUSINESS NODE + LOCAL MEMORY LOADBALANCER ENDPOINT NODE ENDPOINT NODE CLIENT#2 STATEFUL #2 BUSINESS NODE + LOCAL MEMORY {session : client#1} {session : client#2}
  49. 49. PERFORMANCE RIAK_CORE STATEFUL #2
  50. 50. PERFORMANCE STATEFUL #2
  51. 51. PERFORMANCE STATEFUL #2 NODE VNODE1 VNODE2 NODE VNODE3 VNODE4 NODE VNODE5 VNODE6 … hash(session_id) = 1 https://www.youtube.com/watch?v=sYYOLaJ-VDQ
  52. 52. PERFORMANCE Designing for Scalability with Erlang/OTP
  53. 53. PERFORMANCE SYNCHRONOUS CALLS
  54. 54. PERFORMANCE SYNCHRONOUS CALLS ACTOR A ACTOR B ACTOR C ACTOR D BC A
  55. 55. PERFORMANCE EXTERNAL SERVICE
  56. 56. PERFORMANCE CLIENT BUSINESS NODE LOADBALANCER ENDPOINT NODE ENDPOINT NODE BUSINESS NODE EXTERNAL SERVICEEXTERNAL SERVICE
  57. 57. PERFORMANCE LOAD REGULATION AND BACKPRESSURE
  58. 58. PERFORMANCE ENDPOINT NODE BUSINESS NODE EXTERNAL SERVICEEXTERNAL SERVICE BACKPRESSURE LOAD REGULATION ENDPOINT NODE BUSINESS NODE BACKPRESSURE LOAD REGULATION CLIENTS
  59. 59. AVAILABILITY ▸ Fault Tolerance ▸ Resilience ▸ Reliability
  60. 60. AVAILABILITY FAULT TOLERANCE CLIENT BUSINESS NODE ENDPOINT NODE CLIENT BUSINESS NODE ENDPOINT NODE error error
  61. 61. AVAILABILITY FAULT TOLERANCE NODE NODE ACTOR ACTOR asynchronous request
  62. 62. AVAILABILITY FAULT TOLERANCE NODE NODE ACTOR ACTOR timeout
  63. 63. BUSINESS NODE ENDPOINT NODE PAYMENT GROUP BUSINESS NODE BUSINESS NODE LOGIN GROUP BUSINESS NODE AVAILABILITY RESILIENCE - NODE
  64. 64. BUSINESS NODE ENDPOINT NODE PAYMENT GROUP BUSINESS NODE BUSINESS NODE LOGIN GROUP BUSINESS NODE AVAILABILITY RESILIENCE - NODE
  65. 65. PAYMENT GROUP ENDPOINT NODE BUSINESS NODE BUSINESS NODE LOGIN GROUP BUSINESS NODE AVAILABILITY RESILIENCE - NODE
  66. 66. BUSINESS NODE ENDPOINT NODE PAYMENT GROUP BUSINESS NODE BUSINESS NODE LOGIN GROUP BUSINESS NODE AVAILABILITY RESILIENCE - NODE
  67. 67. ACTOR ACTOR ACTOR SUPERVISOR AVAILABILITY RESILIENCE - ACTOR
  68. 68. ACTOR ACTOR ACTOR SUPERVISOR AVAILABILITY RESILIENCE - ACTOR
  69. 69. ACTOR ACTOR ACTOR SUPERVISOR AVAILABILITY RESILIENCE - ACTOR ACTOR
  70. 70. AVAILABILITY RELIABILITY CLIENT ENDPOINT NODE BUSINESS NODEBUSINESS NODE
  71. 71. AVAILABILITY RELIABILITY CLIENT ENDPOINT NODE BUSINESS NODEBUSINESS NODE
  72. 72. AVAILABILITY RELIABILITY CLIENT ENDPOINT NODE BUSINESS NODEBUSINESS NODE
  73. 73. WRAPPING UP
  74. 74. NO SILVER BULLET
  75. 75. Designing for Scalability with Erlang/OTP
  76. 76. Programming Elixir 1.3
  77. 77. Erlang/Elixir Korea User Group https://www.facebook.com/groups/elixir.korea/
  78. 78. REFERENCES ▸ Books ▸ Designing for Scalability with Erlang/OTP ▸ Programming Elixir 1.3 Reliability ▸ The_Little_Elixir_&_OTP_Guidebook ▸ Videos ▸ Experimenting with Superpowered Web Services: Phoenix on Riak_Core https://www.youtube.com/watch?v=sYYOLaJ-VDQ ▸ Erlang Factory SF 2016 - Concurrency + Distribution = Scalability + Availability, a Journey Architecting Erlang Systems 
 https://www.youtube.com/watch?v=_IZMQMuphfo
  79. 79. THANK YOU…

×