SlideShare a Scribd company logo
アクターモデルについて

株式会社ナチュラルスタイル 三辻尚栄

      2012/07/13
Actor はオブジェクトである
●
     内部状態をもつ
●
     ただし、公開メソッドはない

    Actor           Actor              Actor
    - 名前: mitsuwo   - 名前: dojo         - 名前: 握手会
    - 年齢: 34        - 年齢: 24           - 場所: メッセ
    - 既婚: True      - 既婚: False        - 入場者数: 2



Actor                       Actor
    - 名前: 藍染ジーパン            - 名前: JK Tシャツ
    - 価格: 24,800円           - 価格: 4,800円
    - 在庫数: 15               - 在庫数: 33
Actor はメッセージを受け取る
●
    アドレスがある
●
    メッセージを受け付ける(非同期)
●
    メールボックスのようなものを持っている
              to: event001
                                       Actor: event001
              内容:入場(3)
                                       [メッセージキュー]
                                       ・入場(3)
                                       ・入場(8)
              to: event001             ・入場(5)
    ユーザー      内容:入場(8)
                             Actor環境


                                       - 名前: 握手会
              to: event001
     Actor    内容:入場(5)                 - 場所: メッセ
                                       - 入場者数: 2

    他のActor
Actor はメッセージを処理する
 ●   自分の番が来たらメッセージを1件だけ処理する
 ●
     このときに内部状態に変更を加えるかも
 ●
     独立したスレッドのようなものが動いてる感じになる


Actor: event001        Actor: event001        Actor: event001
[メッセージキュー]             [メッセージキュー]             [メッセージキュー]
・入場(8)                 ・入場(5)
・入場(5)


                  処理                     処理


- 名前: 握手会              - 名前: 握手会              - 名前: 握手会
- 場所: メッセ              - 場所: メッセ              - 場所: メッセ
- 入場者数: 5              - 入場者数: 13             - 入場者数: 18
Actor はプロセス越しに通信する
ホスト: 10.10.0.1

   プロセス: PID1001



     Actor: yrm     Actor: dojo




   プロセス: PID1002

                          dojo@PID1001


    Actor: habu    Actor: mitsuwo
Actor はネットワーク越しに通信する
ホスト: 10.10.0.1                         ホスト: 10.10.100.1

   プロセス: TCP4001                          プロセス: TCP4001



     Actor: yrm    Actor: dojo             Actor: mine    Actor: tashiro




   プロセス: TCP4002                          プロセス: TCP4002


                           sho@10.10.100.1:4002

    Actor: habu   Actor: mitsuwo             Actor: sho   Actor: kubota
例: 簡単なチャット(DBの場合)

            DB




  INSERT   SELECT   SELECT
                             メッセージを閲覧する人は
                             定期的にSELECTを投げて
                             新しいメッセージがないか
                             見に行く(ポーリング)


  書き込み      閲覧         閲覧
例: 簡単なチャット(Actorの場合)

          Actor: ChatMaster




                    メッセージ
                    のコピー


                                             メッセージが届くとAgentが画
  メッセージ
                                             面に追加するのでポーリングし
            Actor: Agent      Actor: Agent   なくていい。
                                             ただし、過去ログは残らない。
            画面に追加             画面に追加

   書き込み        閲覧                閲覧
どこがいいの?
    [長所]
●
    並行プログラミングが簡単にできる
    –   Actor の作者はスレッドを直接扱うことがない
    –   Actor の作者は内部状態に対するロックを考えなくていい
●
    スケーラブル
    –   ボトルネックをどんどん小さなActorに分けられる
    –   CPUをどんどん増やせる(コア数 or ホスト数)

    [短所]
●   共有データの扱いがDBに比べて面倒なときがある
●   Actor 環境自体のオーバヘッドがある
    –   メッセージのコピー
    –   一旦キューに入れて処理すること
Actor環境の実装
      (メッセージスロット)
●
    スレッドセーフなキューを用意
●   Actor 毎にインスタンス化
●
    メッセージ投入スレッド
●
    定時にメッセージを発生させる仕組み
Actor環境の実装
        (スケジューラー)
●
    スレッドプールを用意
●
    コア数分だけスレッドをたてておく
●   各Actor に平等にスレッドを割り当てる
●
    メッセージスロットから
    メッセージを受け取ってActorの処理を実行
Actor環境の実装
               (通信機構)
●
    メッセージのネットワーク対応
    –   オブジェクトを深くシリアライズ → XML, json など
    –   XML, json など → オブジェクトにデシリアライズ
●
    ネットワーク通信を束ねる
    –   あるエンドポイントに対して通信が発生したら接続
    –   Actor間・メッセージ間で接続を使い回す
    –   一定時間通信がなければ切断
実在するActor環境
●   Erlang/OTP     エリクソン社のActor専用VM環境
●   Scala          言語に組み込み、通信なし?
●   akka(Java/Scala) JVM上で動作する環境、通信も可
●   Theron(C++)    ドキュメントなど良さそう、通信なし
実例
500エラーシステム
500エラーの用途
●
    異常事態を知る → 障害発生時の通知
●
    現在発生しているエラーを見る → リリース時
    の影響確認
●
    過去に発生したエラーの見る → 問い合わせ対
    応等
●
    一定期間に発生したエラーの状況を知る → い
    つまでも放置されているエラーを無くす
こんな機能があるといい
●
    単位時間あたりの発生件数がしきい値を超え
    たらメールで通知する機能
●
    現在発生しているエラーを受信する機能
●   過去に発生したエラーをDBから検索する機能
●
    今日とか今週のエラーの統計をメールで通知
    する機能
500エラーシステム
                                    発生件数がしきい値を
500エラーが発生したら                        超えたらメール
POST(HTTP)

Webサーバ                                             受け取った500エラーを
                                                   send(WebSocket)

Webサーバ                             Actor: Agent          Webブラウザ
               Actor: Receiver


Webサーバ                             Actor: Agent          Webブラウザ

 (数百台)

                Actor: Logger      Actor: Agent          Webブラウザ



                          INSERT

                                            過去ログをSELECT参照
                     DB

                                                  集計データを定期的にメール

More Related Content

Recently uploaded

FIDO Alliance Osaka Seminar: Welcome Slides.pdf
FIDO Alliance Osaka Seminar: Welcome Slides.pdfFIDO Alliance Osaka Seminar: Welcome Slides.pdf
FIDO Alliance Osaka Seminar: Welcome Slides.pdf
FIDO Alliance
 
CS集会#13_なるほどわからん通信技術 発表資料
CS集会#13_なるほどわからん通信技術 発表資料CS集会#13_なるほどわからん通信技術 発表資料
CS集会#13_なるほどわからん通信技術 発表資料
Yuuitirou528 default
 
FIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdf
FIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdfFIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdf
FIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdf
FIDO Alliance
 
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
NTT DATA Technology & Innovation
 
【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow
Sony - Neural Network Libraries
 
論文紹介:When Visual Prompt Tuning Meets Source-Free Domain Adaptive Semantic Seg...
論文紹介:When Visual Prompt Tuning Meets Source-Free Domain Adaptive Semantic Seg...論文紹介:When Visual Prompt Tuning Meets Source-Free Domain Adaptive Semantic Seg...
論文紹介:When Visual Prompt Tuning Meets Source-Free Domain Adaptive Semantic Seg...
Toru Tamaki
 
TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024
TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024
TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024
Matsushita Laboratory
 
FIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdf
FIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdfFIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdf
FIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdf
FIDO Alliance
 
単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...
単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...
単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...
Fukuoka Institute of Technology
 
【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching
【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching
【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching
harmonylab
 
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
yassun7010
 
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
atsushi061452
 
FIDO Alliance Osaka Seminar: CloudGate.pdf
FIDO Alliance Osaka Seminar: CloudGate.pdfFIDO Alliance Osaka Seminar: CloudGate.pdf
FIDO Alliance Osaka Seminar: CloudGate.pdf
FIDO Alliance
 
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LBカタログ
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LBカタログLoRaWAN 4チャンネル電流センサー・コンバーター CS01-LBカタログ
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LBカタログ
CRI Japan, Inc.
 
FIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdf
FIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdfFIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdf
FIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdf
FIDO Alliance
 
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
iPride Co., Ltd.
 

Recently uploaded (16)

FIDO Alliance Osaka Seminar: Welcome Slides.pdf
FIDO Alliance Osaka Seminar: Welcome Slides.pdfFIDO Alliance Osaka Seminar: Welcome Slides.pdf
FIDO Alliance Osaka Seminar: Welcome Slides.pdf
 
CS集会#13_なるほどわからん通信技術 発表資料
CS集会#13_なるほどわからん通信技術 発表資料CS集会#13_なるほどわからん通信技術 発表資料
CS集会#13_なるほどわからん通信技術 発表資料
 
FIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdf
FIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdfFIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdf
FIDO Alliance Osaka Seminar: LY-DOCOMO-KDDI-Mercari Panel.pdf
 
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
 
【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow
 
論文紹介:When Visual Prompt Tuning Meets Source-Free Domain Adaptive Semantic Seg...
論文紹介:When Visual Prompt Tuning Meets Source-Free Domain Adaptive Semantic Seg...論文紹介:When Visual Prompt Tuning Meets Source-Free Domain Adaptive Semantic Seg...
論文紹介:When Visual Prompt Tuning Meets Source-Free Domain Adaptive Semantic Seg...
 
TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024
TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024
TaketoFujikawa_物語のコンセプトに基づく情報アクセス手法の基礎検討_JSAI2024
 
FIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdf
FIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdfFIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdf
FIDO Alliance Osaka Seminar: PlayStation Passkey Deployment Case Study.pdf
 
単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...
単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...
単腕マニピュレータによる 複数物体の同時組み立ての 基礎的考察 / Basic Approach to Robotic Assembly of Multi...
 
【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching
【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching
【DLゼミ】XFeat: Accelerated Features for Lightweight Image Matching
 
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
 
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
 
FIDO Alliance Osaka Seminar: CloudGate.pdf
FIDO Alliance Osaka Seminar: CloudGate.pdfFIDO Alliance Osaka Seminar: CloudGate.pdf
FIDO Alliance Osaka Seminar: CloudGate.pdf
 
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LBカタログ
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LBカタログLoRaWAN 4チャンネル電流センサー・コンバーター CS01-LBカタログ
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LBカタログ
 
FIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdf
FIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdfFIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdf
FIDO Alliance Osaka Seminar: NEC & Yubico Panel.pdf
 
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

アクターモデルについて

  • 2. Actor はオブジェクトである ● 内部状態をもつ ● ただし、公開メソッドはない Actor Actor Actor - 名前: mitsuwo - 名前: dojo - 名前: 握手会 - 年齢: 34 - 年齢: 24 - 場所: メッセ - 既婚: True - 既婚: False - 入場者数: 2 Actor Actor - 名前: 藍染ジーパン - 名前: JK Tシャツ - 価格: 24,800円 - 価格: 4,800円 - 在庫数: 15 - 在庫数: 33
  • 3. Actor はメッセージを受け取る ● アドレスがある ● メッセージを受け付ける(非同期) ● メールボックスのようなものを持っている to: event001 Actor: event001 内容:入場(3) [メッセージキュー] ・入場(3) ・入場(8) to: event001 ・入場(5) ユーザー 内容:入場(8) Actor環境 - 名前: 握手会 to: event001 Actor 内容:入場(5) - 場所: メッセ - 入場者数: 2 他のActor
  • 4. Actor はメッセージを処理する ● 自分の番が来たらメッセージを1件だけ処理する ● このときに内部状態に変更を加えるかも ● 独立したスレッドのようなものが動いてる感じになる Actor: event001 Actor: event001 Actor: event001 [メッセージキュー] [メッセージキュー] [メッセージキュー] ・入場(8) ・入場(5) ・入場(5) 処理 処理 - 名前: 握手会 - 名前: 握手会 - 名前: 握手会 - 場所: メッセ - 場所: メッセ - 場所: メッセ - 入場者数: 5 - 入場者数: 13 - 入場者数: 18
  • 5. Actor はプロセス越しに通信する ホスト: 10.10.0.1 プロセス: PID1001 Actor: yrm Actor: dojo プロセス: PID1002 dojo@PID1001 Actor: habu Actor: mitsuwo
  • 6. Actor はネットワーク越しに通信する ホスト: 10.10.0.1 ホスト: 10.10.100.1 プロセス: TCP4001 プロセス: TCP4001 Actor: yrm Actor: dojo Actor: mine Actor: tashiro プロセス: TCP4002 プロセス: TCP4002 sho@10.10.100.1:4002 Actor: habu Actor: mitsuwo Actor: sho Actor: kubota
  • 7. 例: 簡単なチャット(DBの場合) DB INSERT SELECT SELECT メッセージを閲覧する人は 定期的にSELECTを投げて 新しいメッセージがないか 見に行く(ポーリング) 書き込み 閲覧 閲覧
  • 8. 例: 簡単なチャット(Actorの場合) Actor: ChatMaster メッセージ のコピー メッセージが届くとAgentが画 メッセージ 面に追加するのでポーリングし Actor: Agent Actor: Agent なくていい。 ただし、過去ログは残らない。 画面に追加 画面に追加 書き込み 閲覧 閲覧
  • 9. どこがいいの? [長所] ● 並行プログラミングが簡単にできる – Actor の作者はスレッドを直接扱うことがない – Actor の作者は内部状態に対するロックを考えなくていい ● スケーラブル – ボトルネックをどんどん小さなActorに分けられる – CPUをどんどん増やせる(コア数 or ホスト数) [短所] ● 共有データの扱いがDBに比べて面倒なときがある ● Actor 環境自体のオーバヘッドがある – メッセージのコピー – 一旦キューに入れて処理すること
  • 10. Actor環境の実装 (メッセージスロット) ● スレッドセーフなキューを用意 ● Actor 毎にインスタンス化 ● メッセージ投入スレッド ● 定時にメッセージを発生させる仕組み
  • 11. Actor環境の実装 (スケジューラー) ● スレッドプールを用意 ● コア数分だけスレッドをたてておく ● 各Actor に平等にスレッドを割り当てる ● メッセージスロットから メッセージを受け取ってActorの処理を実行
  • 12. Actor環境の実装 (通信機構) ● メッセージのネットワーク対応 – オブジェクトを深くシリアライズ → XML, json など – XML, json など → オブジェクトにデシリアライズ ● ネットワーク通信を束ねる – あるエンドポイントに対して通信が発生したら接続 – Actor間・メッセージ間で接続を使い回す – 一定時間通信がなければ切断
  • 13. 実在するActor環境 ● Erlang/OTP エリクソン社のActor専用VM環境 ● Scala 言語に組み込み、通信なし? ● akka(Java/Scala) JVM上で動作する環境、通信も可 ● Theron(C++) ドキュメントなど良さそう、通信なし
  • 15. 500エラーの用途 ● 異常事態を知る → 障害発生時の通知 ● 現在発生しているエラーを見る → リリース時 の影響確認 ● 過去に発生したエラーの見る → 問い合わせ対 応等 ● 一定期間に発生したエラーの状況を知る → い つまでも放置されているエラーを無くす
  • 16. こんな機能があるといい ● 単位時間あたりの発生件数がしきい値を超え たらメールで通知する機能 ● 現在発生しているエラーを受信する機能 ● 過去に発生したエラーをDBから検索する機能 ● 今日とか今週のエラーの統計をメールで通知 する機能
  • 17. 500エラーシステム 発生件数がしきい値を 500エラーが発生したら 超えたらメール POST(HTTP) Webサーバ 受け取った500エラーを send(WebSocket) Webサーバ Actor: Agent Webブラウザ Actor: Receiver Webサーバ Actor: Agent Webブラウザ (数百台) Actor: Logger Actor: Agent Webブラウザ INSERT 過去ログをSELECT参照 DB 集計データを定期的にメール