SlideShare une entreprise Scribd logo
1  sur  11
Télécharger pour lire hors ligne
dRubyによる分散・Webプログラミング入門

      CSNagoya toyoshi


           2009/09/06
dRubyとは(1)


• Rubyのオブジェクトをプロセスやネット
  ワークを越えて扱うための仕組み
• クライアント・サーバモデルのシステムが
  簡単に作れる
• Ruby限定 / Pure Ruby / IDL不要
• 標準添付ライブラリである


                               2
dRubyとは(2)

• dRubyが勝手にネットワークを越えてく
  れる

クライアント       ネットワーク   サーバ


 ObjectX              ObjectX
  dRuby                dRuby




                                3
dRubyの活用事例

• Railsプラグイン backgrounDRb
• FAX 送信制御システム(株)アンタス
• はてなスクリーンショット




                            4
デモ「メモアプリ」

• どれぐらい簡単かメモアプリでみてみる
 サーバのコード
 require 'drb/drb'

 class Memo
         def initialize
                    @item = []
         end

          def add(str)
                   p str
                   @item.push(str)
          end

          def list
                     @item
          end
 end
                                     5
わかったこと


• かんたん
• プロセスの寿命を越えた永続化ができる
• つまりKVS的な使い方もできる
 オンメモリキャッシュサーバとして druby を試してみた→失敗
 http://d.hatena.ne.jp/clayfish/20090610/1244634242




                                                      6
Rindaによるプロセスの協調


• Rindaとは分散処理システムLindaのタプル
  スペースのRubyによる実装


                      Tuple Space

             write                       take



       Tuple                              Tuple
 [“Hello”, “World”]                 [“Hello”, “World”]


                                                         7
サンプル「階乗サーバ」
 • 階乗を計算するシステムを作ってみる
 • タプルのフォーマットは
       – [“fact”,最初の数字,終わりの数字]
       – [“fact-answer”,最初の数字,終わりの数字,結果]



                                          タプルスペース

               (1)write                                               (2)take

                               (4)take               (3)write

                                               tmp, m, n = $ts.take(['fact', Integer, Integer])
$ts.write([“fact”,1,2])
                                               value = (m..n).inject(1) { |a,b| a*b}
ans = $ts.take([“fact-answer”,1,2,nil])
                                               $ts.write(['fact-answer', m, n, value])


                                                                                                  8
そのほかの注意点など

• 参照渡しと値渡し
  – Marshal.dumpできるものは値渡し。できないもの
    は参照渡し
  – 値渡しの際は、値と参照の値も渡す
• GC
  – 別プロセスからだけ参照されているオブジェクトが
    ガベージコレクトの対象になる場合がある
• セキュリティ
  – Rubyは柔軟なのですごく危ない。ACLやUNIXドメ
    インソケット、$SAFEなどを使おう
                                   9
まとめ

• とても簡単に分散オブジェクトシステムが
  作れる
• 夢が広がる




                    10
参考文献など

• dRubyによる分散・Webプログラミング
 – 著者 関 将俊 出版社 オーム社




                          11

Contenu connexe

Tendances (11)

jant aur jant walo ki jalalk
jant aur jant walo ki jalalk jant aur jant walo ki jalalk
jant aur jant walo ki jalalk
 
高中数学知识
高中数学知识高中数学知识
高中数学知识
 
【12-B-4】 並列処理開発を支援するコンパイラの機能
【12-B-4】 並列処理開発を支援するコンパイラの機能【12-B-4】 並列処理開発を支援するコンパイラの機能
【12-B-4】 並列処理開発を支援するコンパイラの機能
 
01 Sk Cvc 2009 Key Note St P
01 Sk   Cvc 2009 Key Note St P01 Sk   Cvc 2009 Key Note St P
01 Sk Cvc 2009 Key Note St P
 
自作言語でお絵描き
自作言語でお絵描き自作言語でお絵描き
自作言語でお絵描き
 
知识管理解读
知识管理解读知识管理解读
知识管理解读
 
054 alqamar
054 alqamar054 alqamar
054 alqamar
 
PDF
PDFPDF
PDF
 
可扩展网站架构(for 网志年会)
可扩展网站架构(for 网志年会)可扩展网站架构(for 网志年会)
可扩展网站架构(for 网志年会)
 
普通の見積り勉強会 番外編
普通の見積り勉強会 番外編普通の見積り勉強会 番外編
普通の見積り勉強会 番外編
 
Основы работы с Memcached
Основы работы с MemcachedОсновы работы с Memcached
Основы работы с Memcached
 

Similaire à dRuby

Sc2009autumn 次世代Daoフレームワーク Doma
Sc2009autumn 次世代Daoフレームワーク DomaSc2009autumn 次世代Daoフレームワーク Doma
Sc2009autumn 次世代Daoフレームワーク Doma
Toshihiro Nakamura
 
清华大学精品课程 量子力学
清华大学精品课程 量子力学清华大学精品课程 量子力学
清华大学精品课程 量子力学
littlesujin
 
081210 Idcon 04 Itoh Peopleservice
081210 Idcon 04 Itoh Peopleservice081210 Idcon 04 Itoh Peopleservice
081210 Idcon 04 Itoh Peopleservice
Hiroki Itoh
 
Ohp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 MojiretsuOhp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 Mojiretsu
sesejun
 
技術トレンディセミナー フレームワークとしてのTrac
技術トレンディセミナー フレームワークとしてのTrac技術トレンディセミナー フレームワークとしてのTrac
技術トレンディセミナー フレームワークとしてのTrac
terada
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
iwata
 

Similaire à dRuby (20)

Reloaded
ReloadedReloaded
Reloaded
 
とちぎRuby会議01(原)
とちぎRuby会議01(原)とちぎRuby会議01(原)
とちぎRuby会議01(原)
 
Cop",!@#%$%&*()*()
Cop",!@#%$%&*()*()Cop",!@#%$%&*()*()
Cop",!@#%$%&*()*()
 
Sc2009autumn 次世代Daoフレームワーク Doma
Sc2009autumn 次世代Daoフレームワーク DomaSc2009autumn 次世代Daoフレームワーク Doma
Sc2009autumn 次世代Daoフレームワーク Doma
 
Where20 2009report
Where20 2009reportWhere20 2009report
Where20 2009report
 
清华大学精品课程 量子力学
清华大学精品课程 量子力学清华大学精品课程 量子力学
清华大学精品课程 量子力学
 
object-shapes
object-shapesobject-shapes
object-shapes
 
20090410 Gree Opentech Presentation (opening)
20090410 Gree Opentech Presentation (opening)20090410 Gree Opentech Presentation (opening)
20090410 Gree Opentech Presentation (opening)
 
ブラウザでMap Reduce風味の並列分散処理
ブラウザでMap Reduce風味の並列分散処理ブラウザでMap Reduce風味の並列分散処理
ブラウザでMap Reduce風味の並列分散処理
 
القرءان الكريم برواية أبي الحارث عن الكسائي من موقع الشبكة الإسلامية
القرءان الكريم برواية أبي الحارث عن الكسائي من موقع الشبكة الإسلامية القرءان الكريم برواية أبي الحارث عن الكسائي من موقع الشبكة الإسلامية
القرءان الكريم برواية أبي الحارث عن الكسائي من موقع الشبكة الإسلامية
 
081210 Idcon 04 Itoh Peopleservice
081210 Idcon 04 Itoh Peopleservice081210 Idcon 04 Itoh Peopleservice
081210 Idcon 04 Itoh Peopleservice
 
Webken 03: Project Design for Optimaizing User Experience
Webken 03: Project Design for Optimaizing User ExperienceWebken 03: Project Design for Optimaizing User Experience
Webken 03: Project Design for Optimaizing User Experience
 
Green IT
Green ITGreen IT
Green IT
 
Ohp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 MojiretsuOhp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 Mojiretsu
 
Shibuya.abc - Gnashで遊ぼう
Shibuya.abc - Gnashで遊ぼうShibuya.abc - Gnashで遊ぼう
Shibuya.abc - Gnashで遊ぼう
 
CSS Nite In Ginza, Vol.36
CSS Nite In Ginza, Vol.36CSS Nite In Ginza, Vol.36
CSS Nite In Ginza, Vol.36
 
Ltdd For Xp2008 検閲版
Ltdd For Xp2008 検閲版Ltdd For Xp2008 検閲版
Ltdd For Xp2008 検閲版
 
技術トレンディセミナー フレームワークとしてのTrac
技術トレンディセミナー フレームワークとしてのTrac技術トレンディセミナー フレームワークとしてのTrac
技術トレンディセミナー フレームワークとしてのTrac
 
オブジェクト指向スクリプト言語 Ruby
オブジェクト指向スクリプト言語 Rubyオブジェクト指向スクリプト言語 Ruby
オブジェクト指向スクリプト言語 Ruby
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 

Plus de toyoshi

Style Share
Style ShareStyle Share
Style Share
toyoshi
 
サーバ/インフラ構築入門(1)
サーバ/インフラ構築入門(1)サーバ/インフラ構築入門(1)
サーバ/インフラ構築入門(1)
toyoshi
 
FlashMediaServer3開発環境の準備
FlashMediaServer3開発環境の準備FlashMediaServer3開発環境の準備
FlashMediaServer3開発環境の準備
toyoshi
 

Plus de toyoshi (11)

猫でもできるRailsデプロイ
猫でもできるRailsデプロイ猫でもできるRailsデプロイ
猫でもできるRailsデプロイ
 
Capistranoで自動デプロイ
Capistranoで自動デプロイCapistranoで自動デプロイ
Capistranoで自動デプロイ
 
Rubyで作る奇妙なプログラミング言語
Rubyで作る奇妙なプログラミング言語Rubyで作る奇妙なプログラミング言語
Rubyで作る奇妙なプログラミング言語
 
Rubyで作る奇妙なプログラミング言語
Rubyで作る奇妙なプログラミング言語Rubyで作る奇妙なプログラミング言語
Rubyで作る奇妙なプログラミング言語
 
Start physical computing with Ruby + Arduino
Start physical computing with Ruby + ArduinoStart physical computing with Ruby + Arduino
Start physical computing with Ruby + Arduino
 
コンクリートブロックのキツジブロック カタログ2008
コンクリートブロックのキツジブロック カタログ2008コンクリートブロックのキツジブロック カタログ2008
コンクリートブロックのキツジブロック カタログ2008
 
Style Share
Style ShareStyle Share
Style Share
 
サーバ/インフラ構築入門(1)
サーバ/インフラ構築入門(1)サーバ/インフラ構築入門(1)
サーバ/インフラ構築入門(1)
 
CSNagoya コンパイラを作ろう
CSNagoya コンパイラを作ろうCSNagoya コンパイラを作ろう
CSNagoya コンパイラを作ろう
 
GainerとRubyで行うサーバ監視
GainerとRubyで行うサーバ監視GainerとRubyで行うサーバ監視
GainerとRubyで行うサーバ監視
 
FlashMediaServer3開発環境の準備
FlashMediaServer3開発環境の準備FlashMediaServer3開発環境の準備
FlashMediaServer3開発環境の準備
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Dernier (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

dRuby