57
Discussion on the P2P Distributed Search System Yusuke FUJISAKA, CyberAgent inc. 2011618日土曜日

Discussion on the Distributed Search Engine

Embed Size (px)

Citation preview

Page 1: Discussion on the Distributed Search Engine

Discussion on the P2P Distributed

Search SystemYusuke FUJISAKA, CyberAgent inc.

2011年6月18日土曜日

Page 2: Discussion on the Distributed Search Engine

自己紹介• 藤坂 祐介(フジサカ ユウスケ)• 秋田県横手市生まれ

• 計算工学専攻 金子研究室• いちおう研究は符号化技術

• サイバーエイジェント内定者• 秋葉原インキュベーションオフィス所属

• 身分はアルバイト2011年6月18日土曜日

Page 3: Discussion on the Distributed Search Engine

Agenda

• 検索ってなあに

• いままでの検索システム

• 自作検索システムのご紹介• 特徴

• 動作の流れ

2011年6月18日土曜日

Page 4: Discussion on the Distributed Search Engine

情報検索とは

• ある語句に対して紐づけられたデータを取り出すこと

• (今回は:)ある単語が含まれる文章を取り出すこと

2011年6月18日土曜日

Page 5: Discussion on the Distributed Search Engine

検索って大変

• ブログデータ2億件• 1日100万件ずつ増加→10件/sec.

• 文章だけでTBオーダ

• こんなにたくさん!

2011年6月18日土曜日

Page 6: Discussion on the Distributed Search Engine

システムを作ろう• 故障対策・バックアップ

• スケールアップ・スケールアウト

• インデックス構造の作り方

• データ構造

• ...

2011年6月18日土曜日

Page 7: Discussion on the Distributed Search Engine

いいシステムとは?• たくさんのデータ(~TBクラス)を一手に管理できる

• たくさんのリクエストに耐える

• 素早くリクエストに応える

• 将来拡張できる

• …

2011年6月18日土曜日

Page 8: Discussion on the Distributed Search Engine

既存の検索システム• Namazu

• Senna

• Lucene

• Solr

• Hyper Estraier

• etc. ...

2011年6月18日土曜日

Page 9: Discussion on the Distributed Search Engine

既存のシステム例• Solrによる検索システム(概観)

Master

Slave

Broker

Index Data

Application

Search

Index

2011年6月18日土曜日

Page 10: Discussion on the Distributed Search Engine

既存のシステム例• Solrによる検索システム(概観)

Master

Slave

Broker

Index Data

Application

Search

Index

2011年6月18日土曜日

Page 11: Discussion on the Distributed Search Engine

既存のシステム例• Solrによる検索システム(概観)

Master

Slave

Broker

Index Data

Application

Search

Index

2011年6月18日土曜日

Page 12: Discussion on the Distributed Search Engine

既存の弱点

• マスターサーバの存在• クリティカルポイント

• ダウンするとサービスが止まる!

• マルチマスターなどの対策もあるけど

2011年6月18日土曜日

Page 13: Discussion on the Distributed Search Engine

リアルタイム検索

• いまどき記事投稿→結果に反映が数分ではイケナイ

• 「すぐに検索結果に出て欲しい」というサービス的な要請

2011年6月18日土曜日

Page 14: Discussion on the Distributed Search Engine

リアルタイム検索

• 既存のリアルタイム検索システム• Zoie (with Lucene)

• Caffeine (Google)

• ...

2011年6月18日土曜日

Page 15: Discussion on the Distributed Search Engine

FARE system

• 自作のリアルタイム検索エンジン

• Fast Autonomous Retrieval Engine• 高速・自律・検索エンジン

2011年6月18日土曜日

Page 16: Discussion on the Distributed Search Engine

特徴1.No Master-Slave

• 全ノードが横並び、同じ機能を有する

2.Peer to Peer• ノード同士で連携、制御ノードがない

3.Realtime indexing• ため込んだデータがすぐ検索できる

2011年6月18日土曜日

Page 17: Discussion on the Distributed Search Engine

No Master-Slave

• 起動時…

• 1台で起動する→Primary mode

• 起動したノードにアタッチ→Secondary mode

2011年6月18日土曜日

Page 18: Discussion on the Distributed Search Engine

Primary mode

• 設定を読み込んで起動

<Setting>...Content = TitleContent = BodyAppendix = PostIDAppendix = URLAppendix = PostTime

2011年6月18日土曜日

Page 19: Discussion on the Distributed Search Engine

Primary mode

• 設定を読み込んで起動

<Setting>

./fare --primary SETTING

2011年6月18日土曜日

Page 20: Discussion on the Distributed Search Engine

Secondary mode

./fare --secondary 10.0.1.1

10.0.1.2

10.0.1.3

10.0.1.1

2011年6月18日土曜日

Page 21: Discussion on the Distributed Search Engine

Secondary mode

./fare --secondary 10.0.1.1

10.0.1.2

10.0.1.3

10.0.1.1

Setting, Data

2011年6月18日土曜日

Page 22: Discussion on the Distributed Search Engine

Secondary mode

./fare --secondary 10.0.1.2

10.0.1.2

10.0.1.3

10.0.1.1

2011年6月18日土曜日

Page 23: Discussion on the Distributed Search Engine

Secondary mode

./fare --secondary 10.0.1.2

10.0.1.2

10.0.1.3

10.0.1.1

Setting, Data

2011年6月18日土曜日

Page 24: Discussion on the Distributed Search Engine

Secondary mode

./fare --secondary 10.0.1.2

10.0.1.2

10.0.1.3

10.0.1.1

Setting, Data

2011年6月18日土曜日

Page 25: Discussion on the Distributed Search Engine

レプリケーション• 複数のノードにデータを持たせて消失を防ぐ

• レプリケーションの仕方は色々と工夫があるはず

• ここではConsistent hashingの考え方でレプリケートする

2011年6月18日土曜日

Page 26: Discussion on the Distributed Search Engine

レプリケーション• Chord chain

A

F

B

C

E

D2011年6月18日土曜日

Page 27: Discussion on the Distributed Search Engine

レプリケーション• Chord chain

A

F

B

C

E

D

Hash: 0xEF459AB...

2011年6月18日土曜日

Page 28: Discussion on the Distributed Search Engine

レプリケーション• Chord chain

A

F

B

C

E

D

Hash: 0xEF459AB...

Hash: 0x6D137EA...

2011年6月18日土曜日

Page 29: Discussion on the Distributed Search Engine

レプリケーション• Fの受け持ち範囲

A

F

B

C

E

D2011年6月18日土曜日

Page 30: Discussion on the Distributed Search Engine

レプリケーションF

E

D

責任範囲(replication=3)

A

B

C

2011年6月18日土曜日

Page 31: Discussion on the Distributed Search Engine

レプリケーション

• 原則的に自分の直前の範囲を受け持つ

• それと他のノードの受け持ち範囲も含める

2011年6月18日土曜日

Page 32: Discussion on the Distributed Search Engine

仮想ノード

• 1台につき1個ずつハッシュを振ると偏ることがある!

2011年6月18日土曜日

Page 33: Discussion on the Distributed Search Engine

仮想ノード

2

3

1Node 1: 56%

Node 3: 24%

Node 2: 20%

2011年6月18日土曜日

Page 34: Discussion on the Distributed Search Engine

仮想ノード

2

3

1Node 1: 56%

Node 3: 24%

Node 2: 20%過大な負荷

2011年6月18日土曜日

Page 35: Discussion on the Distributed Search Engine

2

3

1

3

1

1

2

1

2

3

121

2

Node 1 56% 42%

Node 2 20% 32%

Node 3 24% 26%

2011年6月18日土曜日

Page 36: Discussion on the Distributed Search Engine

2

3

1

3

1

1

2

1

2

3

121

2

Node 1 56% 42%

Node 2 20% 32%

Node 3 24% 26%

平準化!

2011年6月18日土曜日

Page 37: Discussion on the Distributed Search Engine

Indexing

• RPCを受け取ったノード(サーバ役)が形態素解析• 単語ごとにハッシュ計算→インデックス要求

• 本文情報もハッシュ計算→インデックス

2011年6月18日土曜日

Page 38: Discussion on the Distributed Search Engine

Contents

インデックス構造

Queries

Invert Index

2011年6月18日土曜日

Page 39: Discussion on the Distributed Search Engine

インデックス構造…Skip pointer

…Dictionary

Invert index …

…Skip pointer

Content …Appendix…

ID

2011年6月18日土曜日

Page 40: Discussion on the Distributed Search Engine

Indexing

F

B

C

E

D

Content

Term

TermMessagePack-RPC

AID: 12345Title: ...Body: ...URL: ...Time:...

2011年6月18日土曜日

Page 41: Discussion on the Distributed Search Engine

Indexing

A

F

B Hash

E

D

直後のノードに保存

C

Content

Term

Hash

2011年6月18日土曜日

Page 42: Discussion on the Distributed Search Engine

Searching

A

F

B

C

E

D

Analyze

MessagePack-RPC

QueryTermTermTerm

2011年6月18日土曜日

Page 43: Discussion on the Distributed Search Engine

Searching

A

C

E

ID: 12, 24, 35, 49, ...

ID: 12, 30, 49, 55, ...

ID: 7, 12, 30, 49, ...

IntersectionF

B

D2011年6月18日土曜日

Page 44: Discussion on the Distributed Search Engine

Searching

F

C

D

ID: 12ID: 49

Output

A

B

ETitle:みんなのモーターショー

Body:...

2011年6月18日土曜日

Page 45: Discussion on the Distributed Search Engine

ノード間連携

• 1000台以下の中小規模ネットワークを想定• 全ノードへのコネクションを確保

• 定期的にノードに通信を試みる

• 大規模ならこうもいかないでしょうね…

2011年6月18日土曜日

Page 46: Discussion on the Distributed Search Engine

Beacon

F

B

C

E

D

beacon A

2011年6月18日土曜日

Page 47: Discussion on the Distributed Search Engine

Beacon

A

F

B

C

E

D

beacon“live”

2011年6月18日土曜日

Page 48: Discussion on the Distributed Search Engine

ノード不具合

A

B

C

E

D

ノード不具合が起こったら…?

2011年6月18日土曜日

Page 49: Discussion on the Distributed Search Engine

ノード不具合

A

B

C

E

D

Suspend

Running

2011年6月18日土曜日

Page 50: Discussion on the Distributed Search Engine

ノードの死亡宣告

A

B

C

E

D

Node dead

Suspend dead “F”

2011年6月18日土曜日

Page 51: Discussion on the Distributed Search Engine

ノードの死亡宣告

A

B

C

E

D

レプリケーション再構成

2011年6月18日土曜日

Page 52: Discussion on the Distributed Search Engine

ノード復活

A

B

C

E

D

F

Running

Suspend

2011年6月18日土曜日

Page 53: Discussion on the Distributed Search Engine

Beacon

F

B

C

E

D

A

未処理のレプリケートデータをコピー

2011年6月18日土曜日

Page 54: Discussion on the Distributed Search Engine

Future work

•まだまだ•複数システムの協調•もっと大規模なシステムに対するアプローチ

•早期のサービス化

2011年6月18日土曜日

Page 55: Discussion on the Distributed Search Engine

Source codes

• こちらからどうぞ:

• http://code.google.com/p/fujene/

2011年6月18日土曜日

Page 56: Discussion on the Distributed Search Engine

Bibliography

(1) I. Stoica, et al.; Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications; SIGCOMM 2001; October 2001

(2) D. Karger, et al.; Consistent Hashing and Random Trees: Distributed Caching Protocols for Relieving Hot Spots on the World Wide Web; STOC ’97; 1997

2011年6月18日土曜日

Page 57: Discussion on the Distributed Search Engine

Bibliography

(3) C. D. Manning, et al.; An Introduction to Information Retrieval; Cambridge UP; 2009

(4) T. Luu, et al.; ALVIS Peers: A Scalable Full-text Peer-to-Peer Retrieval Engine; P2PIR ’06; Nov. 2006

2011年6月18日土曜日