SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
Copyright © 2016 TIS Inc. All rights reserved.
Akkaで実現するステートフルでスケー
ラブルなアーキテクチャ
2016.10.8 Scala関西Summit
前出祐吾
杉本貴史
with デモ
Copyright © 2016 TIS Inc. All rights reserved. 2
自己紹介
TIS株式会社
リアクティブシステム コンサルティングサービス
前出祐吾
@yugolf
杉本貴史
@tksugimoto
https://twitter.com/okapies/status/781439220330164225
Copyright © 2016 TIS Inc. All rights reserved. 3
今日の話
Akka Actor
Akka Cluster
Akka Cluster Sharding
Akka Persistence
with デモ
知ってる人は、
デモで遊んでいてください。
Copyright © 2016 TIS Inc. All rights reserved. 4
スケールアップ vs スケールアウト
ステートレス vs ステートフル
ワークロード増加の備えは万全?
Copyright © 2016 TIS Inc. All rights reserved.
スケーラブル、かつ、ステートフルにするには
5
状態を共有する
or
毎回同じノードに振り分ける
Copyright © 2016 TIS Inc. All rights reserved.
war
war
6
Load	Balancer
毎回同じノードに振り分ける
Sticky Session
状態を共有する
Session Replication
スケーラブル、かつ、ステートフルにするには
Copyright © 2016 TIS Inc. All rights reserved.
Akkaの場合
7
毎回同じノードに振り分ける
状態を共有する
or
Copyright © 2016 TIS Inc. All rights reserved.
必要な知識
8
Akka Actor
Akka Cluster
Akka Cluster Sharding
Akka Persistence
Copyright © 2016 TIS Inc. All rights reserved.
アクターモデル
9
Akka Actor
Akka Cluster
Akka Cluster Sharding
Akka Persistence
参加者
状
Actorはメッセージを到着順に処理するだけ
なのでシンプルに非同期処理を実装できる
¥3,000
yugolf
幹事さん
tksugimoto
negoro
Copyright © 2016 TIS Inc. All rights reserved. 10
フロントエンドとバックエンド
front-end back-end
Akka Actor
Akka Cluster
Akka Cluster Sharding
Akka Persistence
Copyright © 2016 TIS Inc. All rights reserved.
Cluster
node2
node1
ワークロードに応じてスケール
11
Akka Actor
Akka Cluster
Akka Cluster Sharding
Akka Persistence
front-end
Copyright © 2016 TIS Inc. All rights reserved.
Cluster
node2
node1
12
Alice
Bob
John
Nina
Actor(Entity)が状態を保つ場合
状
毎回同じノードに
振り分けたい!
Akka Actor
Akka Cluster
Akka Cluster Sharding
Akka Persistence
注)イメージ図
front-end
Copyright © 2016 TIS Inc. All rights reserved.
Cluster
13
Akka Actor
Akka Cluster
Akka Cluster Sharding
Akka Persistence Alice
John
状
Shard
Coordinator
Shardの所在は
Coordinatorに尋ねる
Shardとして扱う
ShardRegion
ShardRegion
shard
George
Sunny
node1
node2
Copyright © 2016 TIS Inc. All rights reserved. 14
Alice
George
Sunny
John
状
ノードが増えるとリバランシングされる
Akka Actor
Akka Cluster
Akka Cluster Sharding
Akka Persistence
サーバの負荷を
できるだけ均等に
node1
node2
node3
shard
Copyright © 2016 TIS Inc. All rights reserved. 15
障害が起こるとどうなる?
Copyright © 2016 TIS Inc. All rights reserved. 16
Alice
状態が失われる?
George
Sunny
John
状
ノードがダウンすると
front-end
Copyright © 2016 TIS Inc. All rights reserved. 17
Akka Actor
Akka Cluster
Akka Cluster Sharding
Akka Persistence
Alice
状態を永続化しておく
George
Sunny
John
状
ノードのダウンに備えて
Copyright © 2016 TIS Inc. All rights reserved. 18
Akka Actor
Akka Cluster
Akka Cluster Sharding
Akka Persistence
Alice
永続化した情報から
Entityを復元
George
Sunny
John
状
ノードがダウンすると
Copyright © 2016 TIS Inc. All rights reserved. 19
Akka Actor
Akka Cluster
Akka Cluster Sharding
Akka Persistence
Alice
リバランスされる
John
状
次のダウンに備えて、ノードを追加
George
Sunny
Copyright © 2016 TIS Inc. All rights reserved. 20
デモ
Copyright © 2016 TIS Inc. All rights reserved.
Cluster
21
Alice
John
3
5
Shard
Coordinator
じゃんけん!!
ShardRegion
ShardRegion
shard
Win!!
-Ranking-	
1.John		5	
2.Alice	3	
3.Nina		2
Ranking
4
cassandra
Copyright © 2016 TIS Inc. All rights reserved.
何が起こったか?
22
• 4ノードのうち1つのノードをダウン
• ダウンしたノードの代わりに別のノードでActorを復元
• ダウンしてから復元されるまでに起こったこと
• ダウンしたノードの勝数カウントがストップ

したが、復旧後に正しくカウントされた
じゃんけん ランキング
運のいい人
(node1,2,3)
○
△(一部更新さ
れない)運の悪い人
(node4)
△(結果が不明)
Copyright © 2016 TIS Inc. All rights reserved.
レジリエント
23
部分的な障害が発生したときも、
動かし続けることができ、
元の状態に回復する
http://www.reactivemanifesto.org/
Copyright © 2016 TIS Inc. All rights reserved.
必ずメッセージを届けたい
24
At least once
勝った!
オッケー
勝った!ってば
❌
Copyright © 2016 TIS Inc. All rights reserved.
まとめ
25
で実現するステートフルでスケーラブルなシステムは
レジリエンスも実現できる
ただし、スケーラビリティやレジリエンスは
レスポンスタイムとのトレードオフ
実現したい性能要件に合わせた設計をしましょう
メッセージの信頼性もね
Akka Actor
Akka Cluster
Akka Cluster Sharding
Akka Persistence
Copyright © 2016 TIS Inc. All rights reserved.
• ダウンしてから復元されるまでに起こったこと
• サーバダウンしたユーザの勝数カウントが

ストップしたが、復旧後に正しくカウントされた
レジリエンス設計
26
じゃんけん ランキング
運のいい人
(node1,2,3)
○
△(一部更新さ
れない)運の悪い人
(node4)
△(結果が不明)
重要
もっと	
重要
Copyright © 2016 TIS Inc. All rights reserved.
TISリアクティブシステム コンサルティングサービス
27
• PoC支援
• 設計レビュー
• コードレビュー
      etc
リアクティブ TIS
THANK YOU

Mais conteúdo relacionado

Destaque

Preparing for distributed system failures using akka #ScalaMatsuri
Preparing for distributed system failures using akka #ScalaMatsuriPreparing for distributed system failures using akka #ScalaMatsuri
Preparing for distributed system failures using akka #ScalaMatsuriTIS Inc.
 
並行処理初心者のためのAkka入門
並行処理初心者のためのAkka入門並行処理初心者のためのAkka入門
並行処理初心者のためのAkka入門Yoshimura Soichiro
 
akka-doc-ja
akka-doc-jaakka-doc-ja
akka-doc-jaTIS Inc.
 
Developing an Akka Edge1-3
Developing an Akka Edge1-3Developing an Akka Edge1-3
Developing an Akka Edge1-3saaaaaaki
 
甲賀流Jenkins活用術
甲賀流Jenkins活用術甲賀流Jenkins活用術
甲賀流Jenkins活用術TIS Inc.
 
Effective Akka読書会2
Effective Akka読書会2Effective Akka読書会2
Effective Akka読書会2TIS Inc.
 
Typesafe Reactive Platformで作るReactive System入門
Typesafe Reactive Platformで作るReactive System入門Typesafe Reactive Platformで作るReactive System入門
Typesafe Reactive Platformで作るReactive System入門TIS Inc.
 
Typesafe Reactive Platformで作るReactive System
Typesafe Reactive Platformで作るReactive SystemTypesafe Reactive Platformで作るReactive System
Typesafe Reactive Platformで作るReactive SystemTIS Inc.
 
エンタープライズへのアジャイル開発の導入事例
エンタープライズへのアジャイル開発の導入事例エンタープライズへのアジャイル開発の導入事例
エンタープライズへのアジャイル開発の導入事例Shozaburo Yoshihara
 
Twitterのリアルタイム分散処理システム「Storm」入門
Twitterのリアルタイム分散処理システム「Storm」入門Twitterのリアルタイム分散処理システム「Storm」入門
Twitterのリアルタイム分散処理システム「Storm」入門AdvancedTechNight
 
Device Simulator with Akka
Device Simulator with AkkaDevice Simulator with Akka
Device Simulator with AkkaMax Huang
 
10分で分かるリアクティブシステム
10分で分かるリアクティブシステム10分で分かるリアクティブシステム
10分で分かるリアクティブシステムTIS Inc.
 

Destaque (12)

Preparing for distributed system failures using akka #ScalaMatsuri
Preparing for distributed system failures using akka #ScalaMatsuriPreparing for distributed system failures using akka #ScalaMatsuri
Preparing for distributed system failures using akka #ScalaMatsuri
 
並行処理初心者のためのAkka入門
並行処理初心者のためのAkka入門並行処理初心者のためのAkka入門
並行処理初心者のためのAkka入門
 
akka-doc-ja
akka-doc-jaakka-doc-ja
akka-doc-ja
 
Developing an Akka Edge1-3
Developing an Akka Edge1-3Developing an Akka Edge1-3
Developing an Akka Edge1-3
 
甲賀流Jenkins活用術
甲賀流Jenkins活用術甲賀流Jenkins活用術
甲賀流Jenkins活用術
 
Effective Akka読書会2
Effective Akka読書会2Effective Akka読書会2
Effective Akka読書会2
 
Typesafe Reactive Platformで作るReactive System入門
Typesafe Reactive Platformで作るReactive System入門Typesafe Reactive Platformで作るReactive System入門
Typesafe Reactive Platformで作るReactive System入門
 
Typesafe Reactive Platformで作るReactive System
Typesafe Reactive Platformで作るReactive SystemTypesafe Reactive Platformで作るReactive System
Typesafe Reactive Platformで作るReactive System
 
エンタープライズへのアジャイル開発の導入事例
エンタープライズへのアジャイル開発の導入事例エンタープライズへのアジャイル開発の導入事例
エンタープライズへのアジャイル開発の導入事例
 
Twitterのリアルタイム分散処理システム「Storm」入門
Twitterのリアルタイム分散処理システム「Storm」入門Twitterのリアルタイム分散処理システム「Storm」入門
Twitterのリアルタイム分散処理システム「Storm」入門
 
Device Simulator with Akka
Device Simulator with AkkaDevice Simulator with Akka
Device Simulator with Akka
 
10分で分かるリアクティブシステム
10分で分かるリアクティブシステム10分で分かるリアクティブシステム
10分で分かるリアクティブシステム
 

Mais de TIS Inc.

AWSマネージドサービスとOSSによるミッションクリティカルなシステムの実現
AWSマネージドサービスとOSSによるミッションクリティカルなシステムの実現AWSマネージドサービスとOSSによるミッションクリティカルなシステムの実現
AWSマネージドサービスとOSSによるミッションクリティカルなシステムの実現TIS Inc.
 
Reactive Systems that focus on High Availability with Lerna
Reactive Systems that focus on High Availability with LernaReactive Systems that focus on High Availability with Lerna
Reactive Systems that focus on High Availability with LernaTIS Inc.
 
Starting Reactive Systems with Lerna #reactive_shinjuku
Starting Reactive Systems with Lerna #reactive_shinjukuStarting Reactive Systems with Lerna #reactive_shinjuku
Starting Reactive Systems with Lerna #reactive_shinjukuTIS Inc.
 
可用性を突き詰めたリアクティブシステム
可用性を突き詰めたリアクティブシステム可用性を突き詰めたリアクティブシステム
可用性を突き詰めたリアクティブシステムTIS Inc.
 
EventStormingワークショップ 〜かつてない図書館をモデリングしてみよう〜
EventStormingワークショップ 〜かつてない図書館をモデリングしてみよう〜EventStormingワークショップ 〜かつてない図書館をモデリングしてみよう〜
EventStormingワークショップ 〜かつてない図書館をモデリングしてみよう〜TIS Inc.
 
Akkaの並行性
Akkaの並行性Akkaの並行性
Akkaの並行性TIS Inc.
 
JavaからAkkaハンズオン
JavaからAkkaハンズオンJavaからAkkaハンズオン
JavaからAkkaハンズオンTIS Inc.
 
リアクティブシステムとAkka
リアクティブシステムとAkkaリアクティブシステムとAkka
リアクティブシステムとAkkaTIS Inc.
 
Akka in Action workshop #ScalaMatsuri 2018
Akka in Action workshop #ScalaMatsuri 2018Akka in Action workshop #ScalaMatsuri 2018
Akka in Action workshop #ScalaMatsuri 2018TIS Inc.
 
再帰で脱Javaライク
再帰で脱Javaライク再帰で脱Javaライク
再帰で脱JavaライクTIS Inc.
 
Scalable Generator: Using Scala in SIer Business (ScalaMatsuri)
Scalable Generator: Using Scala in SIer Business (ScalaMatsuri)Scalable Generator: Using Scala in SIer Business (ScalaMatsuri)
Scalable Generator: Using Scala in SIer Business (ScalaMatsuri)TIS Inc.
 

Mais de TIS Inc. (11)

AWSマネージドサービスとOSSによるミッションクリティカルなシステムの実現
AWSマネージドサービスとOSSによるミッションクリティカルなシステムの実現AWSマネージドサービスとOSSによるミッションクリティカルなシステムの実現
AWSマネージドサービスとOSSによるミッションクリティカルなシステムの実現
 
Reactive Systems that focus on High Availability with Lerna
Reactive Systems that focus on High Availability with LernaReactive Systems that focus on High Availability with Lerna
Reactive Systems that focus on High Availability with Lerna
 
Starting Reactive Systems with Lerna #reactive_shinjuku
Starting Reactive Systems with Lerna #reactive_shinjukuStarting Reactive Systems with Lerna #reactive_shinjuku
Starting Reactive Systems with Lerna #reactive_shinjuku
 
可用性を突き詰めたリアクティブシステム
可用性を突き詰めたリアクティブシステム可用性を突き詰めたリアクティブシステム
可用性を突き詰めたリアクティブシステム
 
EventStormingワークショップ 〜かつてない図書館をモデリングしてみよう〜
EventStormingワークショップ 〜かつてない図書館をモデリングしてみよう〜EventStormingワークショップ 〜かつてない図書館をモデリングしてみよう〜
EventStormingワークショップ 〜かつてない図書館をモデリングしてみよう〜
 
Akkaの並行性
Akkaの並行性Akkaの並行性
Akkaの並行性
 
JavaからAkkaハンズオン
JavaからAkkaハンズオンJavaからAkkaハンズオン
JavaからAkkaハンズオン
 
リアクティブシステムとAkka
リアクティブシステムとAkkaリアクティブシステムとAkka
リアクティブシステムとAkka
 
Akka in Action workshop #ScalaMatsuri 2018
Akka in Action workshop #ScalaMatsuri 2018Akka in Action workshop #ScalaMatsuri 2018
Akka in Action workshop #ScalaMatsuri 2018
 
再帰で脱Javaライク
再帰で脱Javaライク再帰で脱Javaライク
再帰で脱Javaライク
 
Scalable Generator: Using Scala in SIer Business (ScalaMatsuri)
Scalable Generator: Using Scala in SIer Business (ScalaMatsuri)Scalable Generator: Using Scala in SIer Business (ScalaMatsuri)
Scalable Generator: Using Scala in SIer Business (ScalaMatsuri)
 

Último

Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsWSO2
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptxsn679259
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video UnderstandingToru Tamaki
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイスCRI Japan, Inc.
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Gamesatsushi061452
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルCRI Japan, Inc.
 
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Hiroshi Tomioka
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NTT DATA Technology & Innovation
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...Toru Tamaki
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 

Último (12)

Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native Integrations
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 

Akkaで実現するステートフルでスケーラブルなアーキテクチャ

  • 1. Copyright © 2016 TIS Inc. All rights reserved. Akkaで実現するステートフルでスケー ラブルなアーキテクチャ 2016.10.8 Scala関西Summit 前出祐吾 杉本貴史 with デモ
  • 2. Copyright © 2016 TIS Inc. All rights reserved. 2 自己紹介 TIS株式会社 リアクティブシステム コンサルティングサービス 前出祐吾 @yugolf 杉本貴史 @tksugimoto https://twitter.com/okapies/status/781439220330164225
  • 3. Copyright © 2016 TIS Inc. All rights reserved. 3 今日の話 Akka Actor Akka Cluster Akka Cluster Sharding Akka Persistence with デモ 知ってる人は、 デモで遊んでいてください。
  • 4. Copyright © 2016 TIS Inc. All rights reserved. 4 スケールアップ vs スケールアウト ステートレス vs ステートフル ワークロード増加の備えは万全?
  • 5. Copyright © 2016 TIS Inc. All rights reserved. スケーラブル、かつ、ステートフルにするには 5 状態を共有する or 毎回同じノードに振り分ける
  • 6. Copyright © 2016 TIS Inc. All rights reserved. war war 6 Load Balancer 毎回同じノードに振り分ける Sticky Session 状態を共有する Session Replication スケーラブル、かつ、ステートフルにするには
  • 7. Copyright © 2016 TIS Inc. All rights reserved. Akkaの場合 7 毎回同じノードに振り分ける 状態を共有する or
  • 8. Copyright © 2016 TIS Inc. All rights reserved. 必要な知識 8 Akka Actor Akka Cluster Akka Cluster Sharding Akka Persistence
  • 9. Copyright © 2016 TIS Inc. All rights reserved. アクターモデル 9 Akka Actor Akka Cluster Akka Cluster Sharding Akka Persistence 参加者 状 Actorはメッセージを到着順に処理するだけ なのでシンプルに非同期処理を実装できる ¥3,000 yugolf 幹事さん tksugimoto negoro
  • 10. Copyright © 2016 TIS Inc. All rights reserved. 10 フロントエンドとバックエンド front-end back-end Akka Actor Akka Cluster Akka Cluster Sharding Akka Persistence
  • 11. Copyright © 2016 TIS Inc. All rights reserved. Cluster node2 node1 ワークロードに応じてスケール 11 Akka Actor Akka Cluster Akka Cluster Sharding Akka Persistence front-end
  • 12. Copyright © 2016 TIS Inc. All rights reserved. Cluster node2 node1 12 Alice Bob John Nina Actor(Entity)が状態を保つ場合 状 毎回同じノードに 振り分けたい! Akka Actor Akka Cluster Akka Cluster Sharding Akka Persistence 注)イメージ図 front-end
  • 13. Copyright © 2016 TIS Inc. All rights reserved. Cluster 13 Akka Actor Akka Cluster Akka Cluster Sharding Akka Persistence Alice John 状 Shard Coordinator Shardの所在は Coordinatorに尋ねる Shardとして扱う ShardRegion ShardRegion shard George Sunny node1 node2
  • 14. Copyright © 2016 TIS Inc. All rights reserved. 14 Alice George Sunny John 状 ノードが増えるとリバランシングされる Akka Actor Akka Cluster Akka Cluster Sharding Akka Persistence サーバの負荷を できるだけ均等に node1 node2 node3 shard
  • 15. Copyright © 2016 TIS Inc. All rights reserved. 15 障害が起こるとどうなる?
  • 16. Copyright © 2016 TIS Inc. All rights reserved. 16 Alice 状態が失われる? George Sunny John 状 ノードがダウンすると front-end
  • 17. Copyright © 2016 TIS Inc. All rights reserved. 17 Akka Actor Akka Cluster Akka Cluster Sharding Akka Persistence Alice 状態を永続化しておく George Sunny John 状 ノードのダウンに備えて
  • 18. Copyright © 2016 TIS Inc. All rights reserved. 18 Akka Actor Akka Cluster Akka Cluster Sharding Akka Persistence Alice 永続化した情報から Entityを復元 George Sunny John 状 ノードがダウンすると
  • 19. Copyright © 2016 TIS Inc. All rights reserved. 19 Akka Actor Akka Cluster Akka Cluster Sharding Akka Persistence Alice リバランスされる John 状 次のダウンに備えて、ノードを追加 George Sunny
  • 20. Copyright © 2016 TIS Inc. All rights reserved. 20 デモ
  • 21. Copyright © 2016 TIS Inc. All rights reserved. Cluster 21 Alice John 3 5 Shard Coordinator じゃんけん!! ShardRegion ShardRegion shard Win!! -Ranking- 1.John 5 2.Alice 3 3.Nina 2 Ranking 4 cassandra
  • 22. Copyright © 2016 TIS Inc. All rights reserved. 何が起こったか? 22 • 4ノードのうち1つのノードをダウン • ダウンしたノードの代わりに別のノードでActorを復元 • ダウンしてから復元されるまでに起こったこと • ダウンしたノードの勝数カウントがストップ
 したが、復旧後に正しくカウントされた じゃんけん ランキング 運のいい人 (node1,2,3) ○ △(一部更新さ れない)運の悪い人 (node4) △(結果が不明)
  • 23. Copyright © 2016 TIS Inc. All rights reserved. レジリエント 23 部分的な障害が発生したときも、 動かし続けることができ、 元の状態に回復する http://www.reactivemanifesto.org/
  • 24. Copyright © 2016 TIS Inc. All rights reserved. 必ずメッセージを届けたい 24 At least once 勝った! オッケー 勝った!ってば ❌
  • 25. Copyright © 2016 TIS Inc. All rights reserved. まとめ 25 で実現するステートフルでスケーラブルなシステムは レジリエンスも実現できる ただし、スケーラビリティやレジリエンスは レスポンスタイムとのトレードオフ 実現したい性能要件に合わせた設計をしましょう メッセージの信頼性もね Akka Actor Akka Cluster Akka Cluster Sharding Akka Persistence
  • 26. Copyright © 2016 TIS Inc. All rights reserved. • ダウンしてから復元されるまでに起こったこと • サーバダウンしたユーザの勝数カウントが
 ストップしたが、復旧後に正しくカウントされた レジリエンス設計 26 じゃんけん ランキング 運のいい人 (node1,2,3) ○ △(一部更新さ れない)運の悪い人 (node4) △(結果が不明) 重要 もっと 重要
  • 27. Copyright © 2016 TIS Inc. All rights reserved. TISリアクティブシステム コンサルティングサービス 27 • PoC支援 • 設計レビュー • コードレビュー       etc リアクティブ TIS