ElixirConf Europe
iex(1)> high_availability@sasajuricaircloak.com
View Slide
Erlang (the language)Elixir LFEErlang VM (BEAM)
highly_available ≈ works_almost_always
optional?(highly_available) # false
easy?(highly_available) # false
highly_available do# the code here magically worksend#doesntworklikethat
fault-tolerancescalability+ responsiveness= high availability
ABDEFC
send(pid, message)ABmessage = receive ...
def loop(state) doreceive domessage ->new_state = handle(state, message)loop(new_state)endend
bank accountbalance{:deposit, amount}{:withdraw, amount}:balanceamount
OS process or threadErlang process
db connectionbackground jobrequest handlerstaterequest handlerrequest handlerrequest handlerrequest handlerrequest handler statestatestatebackground jobbackground jobbackground jobdb connection db connectiondb connection
ABCDEF
Aexit messageBCDEF
supervisorworker worker
SS SWWSWWW SWW
scheduler scheduler scheduler schedulerCPU CPU CPU CPUVM
VMVMVMVMVM
VMsend(pid, message)VM 1send(pid, message)VM 2
shared-nothing concurrencyprocess crash propagation+ some VM magic= fault tolerance scalability responsiveness
3rd party datasourcetransform datapush serverbrowsersbets validation
Data transformation1.Receive TCP stream"2.Assemble XML messages"3.Update the model"4.Store to database"5.Serialize the model"6.Dispatch
receive streamassemble messagesupdate modelstore to databaseserialize datadispatch
receive streamassemble messagesupdate modelstore to databaseserialize datadispatchmessage 6message 5message 4message 3message 2message 1
storing to databasequeuing bet oddsstoring bet odds
match 1 match 3match 2
update modelserialize datadispatchmatch 1 match 3match 2