comparison of transactional libraries for hbase

100
Comparison of Transactional Libraries for HBase Toshihiro Suzuki Solutions Engineer, Hortonworks © Hortonworks Inc. 2011 – 2015. All Rights Reserved

Upload: dataworks-summithadoop-summit

Post on 16-Apr-2017

865 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Comparison of Transactional Libraries for HBase

ComparisonofTransactionalLibrariesforHBaseToshihiroSuzukiSolutionsEngineer,Hortonworks

©HortonworksInc.2011– 2015.AllRightsReserved

Page 2: Comparison of Transactional Libraries for HBase

2 ©HortonworksInc.2011– 2016.AllRightsReserved

⾃⼰紹介

鈴⽊ 俊裕(すずき としひろ)à Solutions Engineer, Hortonworksà 7⽉からHortonworksにジョインà 前職は⼤⼿Web企業

– Hadoop/Hiveを⽤いたログ解析基盤の開発・運⽤(5年)– HBaseを⽤いたソーシャルグラフDB(3年)

à 著書「HBase徹底⼊⾨」à 最近はScalaを勉強しようと思っているà Twitter: @brfrn169

Page 3: Comparison of Transactional Libraries for HBase

3 ©HortonworksInc.2011– 2016.AllRightsReserved

アジェンダ

à 背景– トランザクションについて– HBaseについて– HBaseにおけるトランザクションについて

à Tephraについてà Omidについてà Tephra vs Omid– 機能– ベンチマーク

à まとめ

Page 4: Comparison of Transactional Libraries for HBase

4 ©HortonworksInc.2011– 2016.AllRightsReserved

背景

Page 5: Comparison of Transactional Libraries for HBase

5 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクション処理とは

à トランザクション– データに対する⼀連の操作を⼀つにまとめた単位のこと

à ⼀般的なOLTPでは、複数のトランザクションが同時並⾏で処理される

à 複数のトランザクションが整合性を守って⾛るように管理する機構が必要– RDBMSでは標準的に⼊っている機構

Page 6: Comparison of Transactional Libraries for HBase

6 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクション処理とは

à 例– ⼝座Aから⼝座Bに1,000ドル移動させたいという銀⾏のトランザ

クション• (1)⼝座Aに1000ドル以上⼊っていたら、(2)⼝座Aから-1000ドル、(3)

⼝座Bに+1000ドル• 起こりうる不整合ケースの例

–引き落としが成功して、⼊⾦が失敗した場合–同時に上記のトランザクションが発⽣し、(1)を同時に実⾏してし

まった場合に⼝座Aの残⾦がマイナスになる可能性»⼝座Aの残⾦が1000ドルだった場合

• T1: (1) ok (2) A – 1000 (3) B + 1000• T2: (1)ok (2) A – 1000 (3) B + 1000

»結果として⼝座Aの残⾦は-1000ドルになってしまう

Page 7: Comparison of Transactional Libraries for HBase

7 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクション処理とは

à ACIDというトランザクションが満たすべき技術要件– Atomicity

• 結果がAll-or-Nothingとなること– Consistency

• ⼀貫性を守ること– Isolation

• 過程が他のトランザクションから⾒えないこと– Durability• (障害が発⽣したとしても)結果が永続化されること

Page 8: Comparison of Transactional Libraries for HBase

8 ©HortonworksInc.2011– 2016.AllRightsReserved

なぜトランザクション管理機構が必要なのか

à アプリケーションの開発を容易にする– すべてのクライアントが整合性のとれたデータを⾒ることを保証– 同時に実⾏される更新からデータを保護– 更新が失敗した時などのハンドリング– インデックスとデータの整合性も保証

à 逆にトランザクション管理機構がなかったら上記の保証を全てアプリケーションでやる必要がある

Page 9: Comparison of Transactional Libraries for HBase

9 ©HortonworksInc.2011– 2016.AllRightsReserved

なぜトランザクション管理機構が必要なのか

à アプリケーションの開発を容易にする– すべてのクライアントが整合性のとれたデータを⾒ることを保証– 同時に実⾏される更新からデータを保護– 更新が失敗した時などのハンドリング– インデックスとデータの整合性も保証

à 逆にトランザクション管理機構がなかったら上記の保証を全てアプリケーションでやる必要がある

HBaseでこれを実現するためのライブラリを調査した

Page 10: Comparison of Transactional Libraries for HBase

10 ©HortonworksInc.2011– 2016.AllRightsReserved

HBaseについて

à Googleの「Bigtable」のオープンソースクローンà いわゆる「NoSQL」の⼀つà ペタバイトスケールの分散ストレージ– ⾼可⽤性– スケーラブル– 低レイテンシー

à よく使われるユースケース– ユーザのセッションDB– オブジェクトストア/メッセージストア– センサー系のアプリケーションのストレージ– グラフデータのためのストレージ

Page 11: Comparison of Transactional Libraries for HBase

11 ©HortonworksInc.2011– 2016.AllRightsReserved

HBaseのアーキテクチャ

Master

RegionServer RegionServer RegionServer

HDFS

Zookeeper

Client

Page 12: Comparison of Transactional Libraries for HBase

12 ©HortonworksInc.2011– 2016.AllRightsReserved

HBaseのアーキテクチャ

à TableのデータはRegionに分割– RegionはいずれかのRegionServer

に割り当てられるÃ RegionServerがダウンした場合

は割り当てられていたRegionはフェイルオーバされる

à サイズが⼤きくなったRegionは分割することが可能

Region1

RegionServers

Region2

Region3

Region4

Region4

Region6

Page 13: Comparison of Transactional Libraries for HBase

13 ©HortonworksInc.2011– 2016.AllRightsReserved

HBaseのデータモデル

à 分散ソートマップ– (row key, column, timestamp) -> value

• columnはcolumn familyとcolumn qualifierで構成される• row key, columnでソートされている• timestampはバージョンを表している

– Regionはrow keyの範囲で分割される

row key column timestamp valuerow1 cf:col1 1000 value2row1 cf:col2 1200 value4row2 cf:col1 2000 value6row3 cf:col1 1000 value3row3 cf:col1 300 value1row3 cf:col2 1500 value5

Page 14: Comparison of Transactional Libraries for HBase

14 ©HortonworksInc.2011– 2016.AllRightsReserved

HBaseにおけるトランザクションについて

à Row内の更新はアトミックに⾏われる– 複数columnを同時に変更しても途中の状態が⾒えることはない– IncrementやCASも可能

à Region内のバッチ処理もアトミックに⾏うことが可能à 複数Regionにまたがる更新をアトミックに⾏うことはできないà 複数Tableにまたがる更新もアトミックに⾏うことはできないà 複数RPCの更新もアトミックに⾏うことはできない

Page 15: Comparison of Transactional Libraries for HBase

15 ©HortonworksInc.2011– 2016.AllRightsReserved

HBaseにおけるトランザクションについて

à Row内の更新はアトミックに⾏われる– 複数columnを同時に変更しても途中の状態が⾒えることはない– IncrementやCASも可能

à Region内のバッチ処理もアトミックに⾏うことが可能à 複数Regionにまたがる更新をアトミックに⾏うことはできないà 複数Tableにまたがる更新もアトミックに⾏うことはできないà 複数RPCの更新もアトミックに⾏うことはできない

HBaseは限定されたトランザクション管理機構しかない

Page 16: Comparison of Transactional Libraries for HBase

16 ©HortonworksInc.2011– 2016.AllRightsReserved

HBase上でトランザクションを実現しているライブラリ

à Tephraà Omidà Trafodionà Themis

Page 17: Comparison of Transactional Libraries for HBase

17 ©HortonworksInc.2011– 2016.AllRightsReserved

HBase上でトランザクションを実現しているライブラリ

à Tephraà Omidà Trafodionà Themis

Page 18: Comparison of Transactional Libraries for HBase

18 ©HortonworksInc.2011– 2016.AllRightsReserved

Tephraについて

Page 19: Comparison of Transactional Libraries for HBase

19 ©HortonworksInc.2011– 2016.AllRightsReserved

Tephra

à Apache Incubatorプロジェクトà Snapshot Isolationを実現– Multi Version Concurrency Control– Optimistic Concurrency Control

à Phoenixのトランザクション機能を実現するために⽤いられている

Page 20: Comparison of Transactional Libraries for HBase

20 ©HortonworksInc.2011– 2016.AllRightsReserved

Snapshot Isolation

à 分離レベルの⼀つà 以下の性質を持つ– トランザクションは⼀貫性のあるデータベースのスナップショッ

ト(トランザクション開始時に存在していた最後にコミットされた値)を読む

– トランザクションの更新がスナップショット以降に他のトランザクションがコミットした更新と競合しない場合に限りトランザクションが成功する

Page 21: Comparison of Transactional Libraries for HBase

21 ©HortonworksInc.2011– 2016.AllRightsReserved

Multi Version Concurrency Control

à トランザクションを開始時点のスナップショットを読むというやり⽅なので複数バージョンが存在できなければならない

à HBaseのバージョン(timestamp)を利⽤した実装à トランザクション内すべての更新は同じバージョン(トランザ

クションID)を使って書き込まれるÃ トランザクション内の読み込みは、コミットされてないトラ

ンザクションを除外する– データ取得時にtimestampの範囲を指定する

à ⾃分のコミットされていない更新は⾒える

Page 22: Comparison of Transactional Libraries for HBase

22 ©HortonworksInc.2011– 2016.AllRightsReserved

Optimistic Concurrency Control

à いわゆる楽観ロックà トランザクションの開始時には特に排他制御を⾏わず、コ

ミット時に競合の検出を⾏うやり⽅Ã 対照的なやり⽅としてはPessimistic Concurrency Control– いわゆる悲観ロック– トランザクション開始時に排他制御(主にロック等)を⾏う⽅法

à メリット– Tableやrowに対するロックのコストの回避– デットロックやロックエスカレーションの回避– 短いトランザクションにおいてコストが低くなる

Page 23: Comparison of Transactional Libraries for HBase

23 ©HortonworksInc.2011– 2016.AllRightsReserved

Tephraのアーキテクチャ

Client1

Client2

・・

ClientN

HBase

Zookeeper

Tx Server(active)

Tx Server(stanby)

TransactionProcessorCoprocessor

Page 24: Comparison of Transactional Libraries for HBase

24 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションのライフサイクル

starttx

inprogress

Client Tx serverRPCAPI

dowork

trycommit

tryabort

starttx

checkconflicts

complete

invalid

start

commit

noneabort

invalidate

timeout

rollback

failed

failed

succeeded

Page 25: Comparison of Transactional Libraries for HBase

25 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1002read=1001

Client2

rowkey

column timestamp

value

row cf:col 1001 10

HBase

Page 26: Comparison of Transactional Libraries for HBase

26 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1002read=1001

write=1002read=1001

Client2

start

rowkey

column timestamp

value

row cf:col 1001 10

HBase

Page 27: Comparison of Transactional Libraries for HBase

27 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1003read=1001

inprogress=[1002]

write=1002read=1001

Client2

start

rowkey

column timestamp

value

row cf:col 1001 10

HBase

Page 28: Comparison of Transactional Libraries for HBase

28 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1003read=1001

inprogress=[1002]

rowkey

column timestamp

value

row cf:col 1001 10

HBase

write=1002read=1001

Client2

increment

Page 29: Comparison of Transactional Libraries for HBase

29 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1003read=1001

inprogress=[1002]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11

HBase

write=1002read=1001

Client2

increment

Page 30: Comparison of Transactional Libraries for HBase

30 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1003read=1001

inprogress=[1002]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11

HBase

write=1002read=1001

Client2

start

write=1003read=1001

exclude=[1002]

Page 31: Comparison of Transactional Libraries for HBase

31 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1004read=1001

inprogress=[1002,1003]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11

HBase

write=1002read=1001

Client2

start

write=1003read=1001

exclude=[1002]

Page 32: Comparison of Transactional Libraries for HBase

32 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1004read=1001

inprogress=[1002,1003]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11row cf:col 1003 11

HBase

write=1002read=1001

Client2

write=1003read=1001

exclude=[1002]

increment

Page 33: Comparison of Transactional Libraries for HBase

33 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1004read=1001

inprogress=[1002,1003]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11row cf:col 1003 11

HBase

write=1002read=1001

Client2

write=1003read=1001

exclude=[1002]

commit

Page 34: Comparison of Transactional Libraries for HBase

34 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1004read=1001

inprogress=[1002]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11row cf:col 1003 11

HBase

write=1002read=1001

Client2

write=1003read=1001

exclude=[1002]

commit

Page 35: Comparison of Transactional Libraries for HBase

35 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1004read=1001

inprogress=[1002]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11row cf:col 1003 11

HBase

write=1002read=1001

Client2

commit

Page 36: Comparison of Transactional Libraries for HBase

36 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1004read=1001

inprogress=[1002]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11row cf:col 1003 11

HBase

write=1002read=1001

Client2

conflict!

Page 37: Comparison of Transactional Libraries for HBase

37 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1004read=1001

inprogress=[1002]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11row cf:col 1003 11

HBase

write=1002read=1001

Client2

rollback

Page 38: Comparison of Transactional Libraries for HBase

38 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1004read=1001

inprogress=[1002]

rowkey

column timestamp

value

row cf:col 1001 10

row cf:col 1003 11

HBase

write=1002read=1001

Client2

rollback

Page 39: Comparison of Transactional Libraries for HBase

39 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1004read=1001

inprogress=[1002]

rowkey

column timestamp

value

row cf:col 1001 10

row cf:col 1003 11

HBase

write=1002read=1001

Client2

abort

Page 40: Comparison of Transactional Libraries for HBase

40 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1004read=1001inprogress=[]

rowkey

column timestamp

value

row cf:col 1001 10

row cf:col 1003 11

HBase

write=1002read=1001

Client2

abort

Page 41: Comparison of Transactional Libraries for HBase

41 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1004read=1003inprogress=[]

rowkey

column timestamp

value

row cf:col 1001 10

row cf:col 1003 11

HBase

write=1002read=1001

Client2

abort

Page 42: Comparison of Transactional Libraries for HBase

42 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1005read=1003inprogress=[]

rowkey

column timestamp

value

row cf:col 1001 10

row cf:col 1003 11

HBase

Client2

write=1004read=1003

start

Page 43: Comparison of Transactional Libraries for HBase

43 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

Tx Server

write=1005read=1003inprogress=[]

rowkey

column timestamp

value

row cf:col 1001 10

row cf:col 1003 11

HBase

Client2

write=1004read=1003

read

Page 44: Comparison of Transactional Libraries for HBase

44 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(ロールバックに失敗した時)

Client1

Tx Server

write=1004read=1001

inprogress=[1002]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11row cf:col 1003 11

HBase

write=1002read=1001

Client2

conflict!

Page 45: Comparison of Transactional Libraries for HBase

45 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(ロールバックに失敗した時)

Client1

Tx Server

write=1004read=1001

inprogress=[1002]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11row cf:col 1003 11

HBase

write=1002read=1001

Client2

rollback

Page 46: Comparison of Transactional Libraries for HBase

46 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(ロールバックに失敗した時)

Client1

Tx Server

write=1004read=1001

inprogress=[1002]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11row cf:col 1003 11

HBase

write=1002read=1001

Client2

rollback

Page 47: Comparison of Transactional Libraries for HBase

47 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(ロールバックに失敗した時)

Client1

Tx Server

write=1004read=1003inprogress=[]invalid=[1002]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11row cf:col 1003 11

HBase

write=1002read=1001

Client2

invalidate

Page 48: Comparison of Transactional Libraries for HBase

48 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(ロールバックに失敗した時)

Client1

Tx Server

write=1005read=1003inprogress=[]invalid=[1002]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11row cf:col 1003 11

HBase

Client2

start

write=1004read=1003

exclude=[1002]

Page 49: Comparison of Transactional Libraries for HBase

49 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(ロールバックに失敗した時)

Client1

Tx Server

write=1005read=1003inprogress=[]invalid=[1002]

rowkey

column timestamp

value

row cf:col 1001 10row cf:col 1002 11row cf:col 1003 11

HBase

Client2 read

write=1004read=1003

exclude=[1002]

invisible!

Page 50: Comparison of Transactional Libraries for HBase

50 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れのポイントÃ Transaction Server– トランザクションIDを管理

• Writeポインタ、Readポインタ– トランザクションの状態を管理

• in-progress, committed, invalidà トランザクション開始時にクライアントは以下を受け取る– Writeポインタ: HBaseへ書き込むtimestamp– Readポインタ: HBaseから読み込む上限のtimestamp– Excludes: 読み込まないtimestamp

à 競合の検出はTransaction Serverが⾏うà 競合が検出されたらクライアントがロールバックする

Page 51: Comparison of Transactional Libraries for HBase

51 ©HortonworksInc.2011– 2016.AllRightsReserved

Omidについて

Page 52: Comparison of Transactional Libraries for HBase

52 ©HortonworksInc.2011– 2016.AllRightsReserved

Omid

à Apache Incubatorプロジェクトà Snapshot Isolation– Multi Version Concurrency Control– Lock-free

à HiveのMetastoreの実装に⽤いられているà Yahooの本番環境で使われている

Page 53: Comparison of Transactional Libraries for HBase

53 ©HortonworksInc.2011– 2016.AllRightsReserved

Omidのアーキテクチャ

TransactionalClient

HBase

TheServerOracle/TimestampOracle

CommitTable

AppTable/ShadowCells

Compactor(Coprocessor)

Page 54: Comparison of Transactional Libraries for HBase

54 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

Page 55: Comparison of Transactional Libraries for HBase

55 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

shadowcell

CommitTable

committime

Page 56: Comparison of Transactional Libraries for HBase

56 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1003begin

Page 57: Comparison of Transactional Libraries for HBase

57 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1004begin

starttime=1003

Page 58: Comparison of Transactional Libraries for HBase

58 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1004

increment

starttime=1003

Page 59: Comparison of Transactional Libraries for HBase

59 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1004

increment

starttime=1003取得したいcellに対応する(timestampが一致する)

shadowcellを取得

Page 60: Comparison of Transactional Libraries for HBase

60 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1004

increment

starttime=1003そのshadowcellのvalue (1002)よりstarttime(1003)が大きいのでスナップショットに入れること

ができる

Page 61: Comparison of Transactional Libraries for HBase

61 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1004

increment

starttime=1003

Page 62: Comparison of Transactional Libraries for HBase

62 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1004commit

starttime=1003

Page 63: Comparison of Transactional Libraries for HBase

63 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1004

starttime=1003

競合の検出何もなければ…

commit

Page 64: Comparison of Transactional Libraries for HBase

64 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

1003 1004

TSO/TO

Client2

AppTable

CommitTable

starttime=1003

timestamp=1005

CommitTableへ書き込み

Page 65: Comparison of Transactional Libraries for HBase

65 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

1003 1004

TSO/TO

Client2

AppTable

CommitTable

starttime=1003committime=1004

timestamp=1005committime

Page 66: Comparison of Transactional Libraries for HBase

66 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1003 1004row cf:col_sc 1001 1002

starttime

committime

1003 1004

TSO/TO

Client2

AppTable

CommitTable

starttime=1003committime=1004

timestamp=1005

shadowcellの書き込み

Page 67: Comparison of Transactional Libraries for HBase

67 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1003 1004row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

starttime=1003committime=1004

timestamp=1005

CommitTableから削除

Page 68: Comparison of Transactional Libraries for HBase

68 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1004

increment

starttime=1003

Page 69: Comparison of Transactional Libraries for HBase

69 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1004

starttime=1003begin

Page 70: Comparison of Transactional Libraries for HBase

70 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1005

starttime=1003begin

starttime=1004

Page 71: Comparison of Transactional Libraries for HBase

71 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1005

starttime=1003

starttime=1004

increment

Page 72: Comparison of Transactional Libraries for HBase

72 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1005

starttime=1003

starttime=1004

increment

取得したいcellに対応するshadowcellが存在しない

Page 73: Comparison of Transactional Libraries for HBase

73 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1005

starttime=1003

starttime=1004increment

CommitTableに存在するかも確認する

Page 74: Comparison of Transactional Libraries for HBase

74 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1005

starttime=1003

starttime=1004increment

CommitTableにも存在しないのでスナップショットに入れることはできない

Page 75: Comparison of Transactional Libraries for HBase

75 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1005

starttime=1003

starttime=1004

increment

取得したいcellに対応するshadowcellが存在する

Page 76: Comparison of Transactional Libraries for HBase

76 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1005

starttime=1003

starttime=1004

そのshadowcellのvalue (1002)よりstarttime(1004)が大きいのでスナップショットに入れること

ができる

increment

Page 77: Comparison of Transactional Libraries for HBase

77 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1004 11row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1005

starttime=1003

starttime=1004

increment

Page 78: Comparison of Transactional Libraries for HBase

78 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1004 11row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1005

starttime=1003

starttime=1004

commit

競合の検出何もなければ…

Page 79: Comparison of Transactional Libraries for HBase

79 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1004 11row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

1004 1005

TSO/TO

Client2

AppTable

CommitTable

timestamp=1006

starttime=1003

starttime=1004

CommitTableへ書き込み

Page 80: Comparison of Transactional Libraries for HBase

80 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1004 11row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1001 1002

starttime

committime

1004 1005

TSO/TO

Client2

AppTable

CommitTable

timestamp=1006

starttime=1003

starttime=1004committime=1005

committime

Page 81: Comparison of Transactional Libraries for HBase

81 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1004 11row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1004 1005row cf:col_sc 1001 1002

starttime

committime

1004 1005

TSO/TO

Client2

AppTable

CommitTable

timestamp=1006

starttime=1003

starttime=1004committime=1005

shadowcellの書き込み

Page 82: Comparison of Transactional Libraries for HBase

82 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1004 11row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1004 1005row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1006

starttime=1003

starttime=1004committime=1005

CommitTableから削除

Page 83: Comparison of Transactional Libraries for HBase

83 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1004 11row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1004 1005row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1006

starttime=1003

commit

Page 84: Comparison of Transactional Libraries for HBase

84 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1004 11row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1004 1005row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1006

starttime=1003

commit

競合発生!

Page 85: Comparison of Transactional Libraries for HBase

85 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れ(競合が発⽣した時)

Client1

rowkey

column timestamp

value

row cf:col 1004 11row cf:col 1003 11row cf:col 1001 10row cf:col_sc 1004 1005row cf:col_sc 1001 1002

starttime

committime

TSO/TO

Client2

AppTable

CommitTable

timestamp=1006

トランザクションはabortされrollbackする

Page 86: Comparison of Transactional Libraries for HBase

86 ©HortonworksInc.2011– 2016.AllRightsReserved

トランザクションの流れのポイントÃ トランザクション開始時にTSO/TOからstart timeを受け取

る– それがトランザクションを表すトラザクションIDとなる– 読み込みにも書き込みにも使われる

à Shadow Cell– そのデータがコミットされているかどうかの判定– どのtimestmapにコミットされたか(commit time)

à 競合の検出はTSO/TOで⾏われるà 競合が検出されたらクライアントはロールバックを⾏う

Page 87: Comparison of Transactional Libraries for HBase

87 ©HortonworksInc.2011– 2016.AllRightsReserved

TephravsOmid

Page 88: Comparison of Transactional Libraries for HBase

88 ©HortonworksInc.2011– 2016.AllRightsReserved

TephraとOmidの⽐較表

Tephra Omidバージョン 0.7.1 0.8.2.0プロジェクト ApacheIncubator ApacheIncubator実装言語 Java Java分離レベル SnapshotIsolation SnapshotIsolation実装 MVCC+OCC MVCC +lock-freeAPI JavaAPI(Phoenix経由でJDBC,REST等) JavaAPI

対応している操作 get,put,delete,exists,scan,batch get,put,delete,scanHA 対応 対応

ReadOnlyTransaction 非対応 対応

大きなユースケース Phoenix HiveMetastoreドキュメント

(個人的な感想)△ △

Page 89: Comparison of Transactional Libraries for HBase

89 ©HortonworksInc.2011– 2016.AllRightsReserved

ベンチマーク

à ※結果はあくまでも参考値です。環境や設定、ワークロードによって結果は⼤きく変わる可能性があります。もしこれらのライブラリを使う場合は別途検証することをお勧めします

à 環境– Master × 1 CPU 4core, Memory 8GB– RegionServer × 3 CPU 4core, Memory 8GB– Transaction Server, TSO × 1 CPU 4core, Memory 8GB– 負荷を掛けるサーバ × 1 CPU 4core, Memory 8GB

Page 90: Comparison of Transactional Libraries for HBase

90 ©HortonworksInc.2011– 2016.AllRightsReserved

ベンチマーク

à ワークロード– トランザクション開始– 1000個のRowの中からランダムに選択– 選択したRowに対してGet– 選択したRowに対してPut– トランザクション終了

– 100スレッドで上記ワークロードを30分間実⾏• HBase直接(ライブラリなし)、Tephra、 Omid

– 競合は3〜15%位発⽣していた

Page 91: Comparison of Transactional Libraries for HBase

91 ©HortonworksInc.2011– 2016.AllRightsReserved

ベンチマーク

à 結果 HBase直接 スループット (req/sec)

0

1000

2000

3000

4000

5000

6000

7000

8000

9000

10000

0 30 60 90 120

150

180

210

240

270

300

330

360

390

420

450

480

510

540

570

600

630

660

690

720

750

780

810

840

870

900

930

960

990

1020

1050

1080

1110

1140

1170

1200

1230

1260

1290

1320

1350

1380

1410

1440

1470

1500

1530

1560

1590

1620

1650

1680

1710

1740

1770

1800

hbasethroughput(req/sec)

Page 92: Comparison of Transactional Libraries for HBase

92 ©HortonworksInc.2011– 2016.AllRightsReserved

ベンチマーク

à 結果 HBase直接 レイテンシ (ms)

0

5

10

15

20

25

30

35

40

45

50

0 30 60 90 120

150

180

210

240

270

300

330

360

390

420

450

480

510

540

570

600

630

660

690

720

750

780

810

840

870

900

930

960

990

1020

1050

1080

1110

1140

1170

1200

1230

1260

1290

1320

1350

1380

1410

1440

1470

1500

1530

1560

1590

1620

1650

1680

1710

1740

1770

1800

hbaselatency(ms)

mean p50 p75 p95 p98 p99

Page 93: Comparison of Transactional Libraries for HBase

93 ©HortonworksInc.2011– 2016.AllRightsReserved

ベンチマーク

à 結果 Tephra スループット (req/sec)

0

200

400

600

800

1000

1200

1400

1600

0 30 60 90 120

150

180

210

240

270

300

330

360

390

420

450

480

510

540

570

600

630

660

690

720

750

780

810

840

870

900

930

960

990

1020

1050

1080

1110

1140

1170

1200

1230

1260

1290

1320

1350

1380

1410

1440

1470

1500

1530

1560

1590

1620

1650

1680

1710

1740

1770

1800

tephrathroughput(req/sec)

Page 94: Comparison of Transactional Libraries for HBase

94 ©HortonworksInc.2011– 2016.AllRightsReserved

ベンチマーク

à 結果 Tephra レイテンシ (ms)

0

20

40

60

80

100

120

140

0 30 60 90 120

150

180

210

240

270

300

330

360

390

420

450

480

510

540

570

600

630

660

690

720

750

780

810

840

870

900

930

960

990

1020

1050

1080

1110

1140

1170

1200

1230

1260

1290

1320

1350

1380

1410

1440

1470

1500

1530

1560

1590

1620

1650

1680

1710

1740

1770

1800

tephralatency(ms)

mean p50 p75 p95 p98 p99

Page 95: Comparison of Transactional Libraries for HBase

95 ©HortonworksInc.2011– 2016.AllRightsReserved

ベンチマーク

à 結果 Omid スループット (req/sec)

0

500

1000

1500

2000

2500

0 30 60 90 120

150

180

210

240

270

300

330

360

390

420

450

480

510

540

570

600

630

660

690

720

750

780

810

840

870

900

930

960

990

1020

1050

1080

1110

1140

1170

1200

1230

1260

1290

1320

1350

1380

1410

1440

1470

1500

1530

1560

1590

1620

1650

1680

1710

1740

1770

1800

omidthroughput(req/sec)

Page 96: Comparison of Transactional Libraries for HBase

96 ©HortonworksInc.2011– 2016.AllRightsReserved

ベンチマーク

à 結果 Omid レイテンシ (ms)

0

20

40

60

80

100

120

140

160

180

200

0 30 60 90 120

150

180

210

240

270

300

330

360

390

420

450

480

510

540

570

600

630

660

690

720

750

780

810

840

870

900

930

960

990

1020

1050

1080

1110

1140

1170

1200

1230

1260

1290

1320

1350

1380

1410

1440

1470

1500

1530

1560

1590

1620

1650

1680

1710

1740

1770

1800

omidlatency(ms)

mean p50 p75 p95 p98 p99

Page 97: Comparison of Transactional Libraries for HBase

97 ©HortonworksInc.2011– 2016.AllRightsReserved

ベンチマーク

à 考察– HBase直接と⽐較して、Tephra, Omidを使うとスループットが数

分の1まで遅くなる– TephraとOmidを⽐較すると若⼲Omidの⽅がパフォーマンスが良

かった• 今回はパフォーマンスチューニングまではできていないので、今後やっ

てみたい– TephraのTransaction Serverと⽐較して、OmidのTSOの⽅が負

荷が⾼かった

Page 98: Comparison of Transactional Libraries for HBase

98 ©HortonworksInc.2011– 2016.AllRightsReserved

まとめ

Page 99: Comparison of Transactional Libraries for HBase

99 ©HortonworksInc.2011– 2016.AllRightsReserved

まとめÃ HBase上でトランザクションを実現するライブラリについて

解説– Tephra– Omid

à Tephra vs Omid– 機能の違い– 簡単なベンチマーク

Page 100: Comparison of Transactional Libraries for HBase

100 ©HortonworksInc.2011– 2016.AllRightsReserved

ThankYou