나프다 웨비너 1604: Elixir와 함수형 프로그래밍을 이용한 웹 개발
-
Upload
changwook-park -
Category
Technology
-
view
522 -
download
5
Transcript of 나프다 웨비너 1604: Elixir와 함수형 프로그래밍을 이용한 웹 개발
Elixir 그리고 MSA
MSA?
http://www.slideshare.net/andrewdohyunjung/msa-43702981
http://www.slideshare.net/andrewdohyunjung/msa-43702981
http://www.slideshare.net/andrewdohyunjung/msa-43702981
Elixir 와 MSA 가 무슨 연관이 ?
Erlang
Elixir
사실 MSA 에 묻어가려고…
MSA 개발 / 운영 시에 있으면 좋을꺼 같은것들 ( 매우 주관적 )
• 서비스들이 죽지 않았으면 좋겠다 .• 운영중에 패치가 편했으면 좋겠다 .• 클러스터링 가능 했으면 좋겠다 .• 서비스들간의 통신이 편했으면 좋겠다 .
• 서비스들이 죽지 않았으면 좋겠다 . Supervisor• 운영중에 패치가 편했으면 좋겠다 . Hot Code Swapping• 클러스터링 가능 했으면 좋겠다 . Cluster• 서비스들간의 통신이 편했으면 좋겠다 . MessagePassing/RPC
ErlangElixir
Erlang/Elixir
1986: 에릭슨사 개발
1998: 오픈소스화
2016: Erlang/OTP18.3
Erlang
• 함수형 언어 .• 불변 변수 (Immutable variables)• 강타입 , 동적 타입 자료형 체계 (strong, dynamic typing)• 병행성 (Concurrency) 모델중 Actor model.
https://www.youtube.com/watch?v=B4rOG9Bc65Q
https://www.youtube.com/watch?v=B4rOG9Bc65Q
http://stackoverflow.com/questions/1636455/where-is-erlang-used-and-why/1637137#1637137
2012: José Valim 개발
2016: Elixir 1.2
Elixir• Erlang 의 특징을 계승 .• Elixir 컴파일러가 BEAM(Erlang VM) 용 바이트코트로 컴파일 .• 도큐먼트 제공• 툴 제공 (ExUnit, iex, Mix)• 페키지 관리 (Hex packages)
https://www.youtube.com/watch?v=lly-1UYmnFI
http://www.slideshare.net/gabriele.lana/the-magic-of-elixir
–Joe Armstrong
“Erlang was designed for writing concurrent programs that run forever”
Concurrency modelErlang/Elixir Actor model
Node.js Single thread, Event driven
Go CSP
Actor = Process + Data + Code
http://www.slideshare.net/christophevg/actors-la-akka
Actor Actor Actor
Actor Actor Actor
data data
datadata
data
Input
Output
http://www.slideshare.net/eonblast/why-erlang-gdc-online-2012
http://www.slideshare.net/eonblast/why-erlang-gdc-online-2012
Lightweight process
ProcessMail box
Heap
Stack
Garbage Collector
Message passing
P2Receiver
P1SenderMail box Mail box
message
message
Message passing
P2Mail boxmessage
P2
메시지 수신
메시지 라우팅
메시지 처리
메시지 응답
Message passingP2
메시지 수신
메시지 라우팅
메시지 처리
메시지 응답
Message passingP2
메시지 수신
메시지 라우팅
메시지 처리
메시지 응답
Message passingP2
메시지 수신
메시지 라우팅
메시지 처리
메시지 응답
Message passingP2
메시지 수신
메시지 라우팅
메시지 처리
메시지 응답
P3
메시지 수신
메시지 라우팅
메시지 처리
메시지 응답
PN
메시지 수신
메시지 라우팅
메시지 처리
메시지 응답
…
– erlang.org
“OTP (Open Telecom Platform) is a large collection of libraries for Erlang to do everything from compiling
ASN.1 to providing a WWW server. Most projects using "Erlang" are actually using "Erlang/OTP", i.e. the
language and the libraries. OTP is also open source.”
OTP Behaviours
• GenServer• GenEvent• GenFSM• Supervisor
GenServer
Server
Client
Client
requestresponse
request
기본 프로세스 GenServer 프로세스
GenEvent
EventManager
Client Client Client
event
GenFSM
http://knewter.github.io/erlang_dc_workshop/deck/otp_with_elixir/finite_state_machines/slides/#/2
MSA 와 Elixir
• 서비스들이 죽지 않았으면 좋겠다 . Supervisor• 운영중에 패치가 편했으면 좋겠다 . Hot Code Swapping• 클러스터링 가능 했으면 좋겠다 . Cluster• 서비스들간의 통신이 편했으면 좋겠다 . MessagePassing/RPC
ErlangElixir
Supervisor
Supervisor
ProcessProcess Process
Supervisor
ProcessProcess Process
Supervisor
ProcessProcess ProcessProcess
Supervisor
ProcessProcess Process
one_for_one
Supervisor
ProcessProcess Process
one_for_one
Supervisor
ProcessProcess Process
one_for_one
Process
Supervisor
ProcessProcess Process
one_for_all
Supervisor
ProcessProcess Process
one_for_all
Supervisor
ProcessProcess Process
one_for_all
Process Process Process
Supervisor
ProcessProcess Process
reset_for_all
Supervisor
ProcessProcess Process
reset_for_all
Supervisor
ProcessProcess Process
reset_for_all
Process Process
Supervisor
ProcessProcess Supervisor
ProcessProcess Process
Hot code swapping
ActorCode Data
Process
ActorCode Data
Process
New Code
ActorData
Process
New Code
Cluster
EndPoint
Payment Cart
Service
EndPoint
Payment Cart
Service
EndPoint
Payment Cart
Service
Proxy
Service
EndPoint
Payment Cart
특정 기능에만 부하가 집중된다면
ServiceService
EndPoint
Payment Cart
EndPoint
Payment Cart
Proxy
Node#2Node#1
EndPoint
Payment Cart Cart
Cart
EndPoint
EndPoint
EndPoint …
Cart Cart Payment …
DMZEndpoint
Business
Client
Node
Node Node
Node
$ Node.connect(nodename)
Service/Node 간 통신
SystemSystem
Node Node
Node Node
SystemSystem
SystemSystem
pid
사실 Thrift 씁니다 ..
Elixir 에 관심이 생기셨다면 ..
http://elixir-lang.org
https://www.facebook.com/groups/elixir.korea/
감사합니다 .