Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Let's create stateful systems, by Elixir
Search
さっちゃん
August 24, 2019
Programming
1
900
Let's create stateful systems, by Elixir
さっちゃん
August 24, 2019
Tweet
Share
More Decks by さっちゃん
See All by さっちゃん
みんなのオブザーバビリティプラットフォームを作ってるんだがパフォーマンスがやばい #mackerelio #srenext
ne_sachirou
0
1.3k
作ってよかったgraceful shutdownライブラリ #kyotogo
ne_sachirou
0
1.1k
path 依存型って何?
ne_sachirou
0
520
野生の onbording と onbording 設計 #kyototechtalk
ne_sachirou
0
590
メトリックはいかにして見え續ける樣になったか #devio2022
ne_sachirou
0
71
名實一致
ne_sachirou
0
620
まかれるあなとみあ ―Mackerel のしくみを理解する 30 分― @ Hatena Engineer Seminar #16
ne_sachirou
0
3k
tacit programming : Point-free, Concatenatives & J
ne_sachirou
0
870
Monitoring Containerized Elixir
ne_sachirou
1
930
Other Decks in Programming
See All in Programming
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
120
Запуск 1С:УХ в крупном энтерпрайзе: мечта и реальность ПМа
lamodatech
0
950
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
6
700
rails newと同時に型を書く
aki19035vc
5
710
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
170
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
930
ESLintプラグインを使用してCDKのセオリーを適用する
yamanashi_ren01
2
240
Azure AI Foundryのご紹介
qt_luigi
1
200
선언형 UI에서의 상태관리
l2hyunwoo
0
270
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
400
chibiccをCILに移植した結果 (NGK2025S版)
kekyo
PRO
0
130
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
1.8k
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
570
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
Site-Speed That Sticks
csswizardry
2
270
Into the Great Unknown - MozCon
thekraken
34
1.6k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Bash Introduction
62gerente
610
210k
Rails Girls Zürich Keynote
gr2m
94
13k
Transcript
Let's create stateful systems, by Elixir
. 。oO( さっちゃんですよヾ( 〃l _ l) ノ゙☆)
I'll show you a number.
2
Two
Ⅱ
⼆
2 is a number of collison & collaboration.
I & you hot & ice stand up & lie
down inside & outside
stateless & stateful
Function is stateless. f : x -> y e.g. Web
server
Dialogue is stateful. Alice : X. Bob : Y. Alice
: X. Bob : Z. Most of the system is stateful.
Elixir
Elixir is a functional programming language. Functional programming is stateless.
All data of Elixir is immutable. [x, 3, x] = Enum.map([1,2,1], &(&1 + 1)) assert 2 == x // Many lines that don't reassign to `x`. assert 2 == x
Elixir has processes. 29 = Task.async(fn -> 29 end) |>
Task.await
Process has state. agent = Agent.start_link(fn -> 29 end) 29
= Agent.get(agent, &(&1)) Agent.update(agent, &(&1 + 13)) 42 = Agent.get(agent, &(&1))
State should be updated in a transaction. State shold interact
& isolate each other. Accessing to state should be scaled in-out. Server with state should be updated gracefully. Elixir has all of these!
State should be updated in a transaction. (No shared state)
State shold interact & isolate each other. (Application, Supervisor) Accessing to state should be scaled in-out. (GenStage, Task, Register, Erlang cluster) Server with state should be updated gracefully. (Hot code swap)
We can create stateful system easy, by constructing stateless parts.
How we can start Elixir? Let's create some applications. *
Web application with Phoenix. * Slack bot.
Phoenix is a Web application framework that familiar with WebSocket.
https://hexdocs.pm/phoenix/overview.html
React is available (✿ >ヮ ╹ )-♡ Let's create a
realtime interaction ∩ (> ◡ <*)∩ ♡ https://speakerdeck.com/ne_sachirou/phoenix-livereact
Create a Slack bot. https://github.com/BlakeWilliams/Elixir-Slack (Easy, so no topic.)
Installing Elixir. asdf https://asdf-vm.com/ asdf plugin-add erlang asdf install erlang
22.0.7 asdf plugin-add elixir asdf install elixir 1.9.1
Text editor? VSCode with mjmcloug.vscode-elixir works.
Format & lint. InnerCotton https://github.com/ne-sachirou/inner_cotton is a set of standard
development tools. mix cotton.init mix cotton.lint --fix
Docker image (You need Docker :-) Fix major ver.s both
Erlang & Elixir. docker run -it --rm nesachirou/elixir:1.9_erl22
Textbook & document. Official guide : https://elixir-lang.org/ Official document :
https://hexdocs.pm/elixir/Kernel.html Online textbook : https://elixirschool.com/ja/ Textbook : https://tatsu-zine.com/books/programming-elixir-ja
https://speakerdeck.com/ne_sachirou/elixirwan-quan-nili-jie-sita
Advanced resources
Erlang in Anger https://ymotongpoo.github.io/erlang-in-anger/text-ja.pdf You want to read this… before
production.
https://speakerdeck.com/ne_sachirou/sutetohurudeda-gui-mo- akusesufalsearusoft-realtimenagemusabawoeasynitukuru
https://speakerdeck.com/ne_sachirou/elixir-on-containers
https://speakerdeck.com/ne_sachirou/phoenix-at-scale
https://speakerdeck.com/ne_sachirou/ddd-data-driven-development