© 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores...

22
© 2012 IBM Corporation 1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1 , Sandeep Tata 2 , Yuzhe Tang 3 , Liana Fong 1 1 IBM T. J. Watson Research Center 2 Google Inc 3 Georgia Tech

Transcript of © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores...

Page 1: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation1

Diff-Index: Differentiated Index in DistributedLog-Structured Data Stores

Wei Tan1, Sandeep Tata2, Yuzhe Tang3, Liana Fong1

1 IBM T. J. Watson Research Center2 Google Inc3 Georgia Tech

Page 2: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation2

Agenda

Background: NoSQL, LSM and HBase

Diff-Index schemes

ACID properties

System

Performance

Related work & Summary

Page 3: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation3

Background: Apache HBase

HBase is a widely used NoSQL store– Table-like and flexible schema, scale-out on commodity HW, integration with

Hadoop– Use log-structure and good for high ingestion rate workload

Gap: HBase is slow for ad hoc queries–Has no secondary index; query w/ table scan

Two options for index in a partitioned data store like HBase– Global

• index on entire table, partitioned on its own• no need to broadcast good for selective queries

– Local• one index co-located with each partition• need broadcast queries to each partition costly; update fast, though

ACIDSchemes System PerformanceBackground

Page 4: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation4

Log Structure Merge (LSM) Trees

Write (sub ms)

Commit log

Mem Store

C1

C2

memory

disk

Flush(memstore disk store)

Commit log’

Mem Store’

C1

C2

memory

disk

C3

merge

Read (~10ms)

LSM Tree = a in-memory store + several on-disk stores

Writes go to a commit log (seq. IO) and in-memory store – update not in-place, FAST

Memstore periodically pushed to disk

Reads go to mem+disk stores (random IO)-- SLOW

On-disk stores periodically compacted to save space & speedup read write/inserts

read

s

Slow FastSlo

w

Fast

B+tree (RDB)

logging

LSM tree (HBase)

[O'Neil, Acta Informatica’96]

v1

v2

v3

Commit log’

Mem Store’

C1’

memory

disk

compact(merge disk

stores)

V1,2,3

ACIDSchemes System PerformanceBackground

Page 5: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation5

HBase architecture

Records range partitioned into regions

Each region stores data in LSM

Used in Facebook, Meetup, Splice Machine, …

ACIDSchemes System PerformanceBackground

Page 6: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation6

Challenges of index maintenance in LSM

1 LSM Tree

2 CAP3 failure recovery

1. Log Structured Merge tree: a reviving interest in it a) Write workload 10~20% > 50%: click streams, sensors, mobile…b) With non in-place update and slow read, index update can be slow

2. Distributed systemsa) Distributed index maintenance needs coordinationb) Performance/consistency tradeoff: CAP theorem

3. Failure recovery: adding another log?

Diff-Index -- differentiated secondary Indexa global index scheme on LSM-Tree with balanced performance and lightweight failure recovery cost

ACIDSchemes System PerformanceBackground

Page 7: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation7

Index update operations in LSM

Rev1/3, t1Rev2/4, t1

3/Rev1, t14/Rev2, t1

Data table(Review)

Index table(ReviewByStar)

Rev1/5, t2

5/Rev1, t2

Start from an empty table, at time t1– Insert two new reviews -- Rev1 and Rev2– Insert two index records for Rev1 and Rev2

At a later time t2: change the star of Rev1 to 5– HBase has only one put() API for insert and update --

different from RDBMS & SQL– Insert <Rev1/5> auto-invalidates <Rev1/3> -- t1 < t2– Index record insert: <5/Rev1>– <5/Rev1> does NOT invalidate stale index <3/Rev1>

Vanilla solution: read data table to get old value (“3”) and delete index <3/Rev1>

index_update = insert + read + del (read is costly!) Tune the above equation to shorten the latency (see next slides)?

Task: index review by starsBoth data and index are stored as HBase tables

ReviewID Text Stars …Rev1 … 3 …Rev2 … 4 …

Stars ReviewID3 Rev14 Rev2

Key/Value

ACIDSchemes System PerformanceBackground

Page 8: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation8

Put a new <k/v’> when an old <k/v> exists (think of k as ReviewID, v as Star in Yelp)

ReviewID Text Stars …R00001 … 5 …

… … … …

Index schemes by revisiting the equation: index_update = insert + read + del

2. sync-insert: let old (<v/k>) in index; lazy clean: only when a query uses it

1) Query “v” and get “k”3) Del “v/k”

2) Find k is not with “v”;

k/v’k/v

v’/kv/k

Data

Index

sync-insert = insert3. async: add (insert + read + del) into

asynchronous update queue (AUQ)

k/v’k/v

v’/kv/k

Data

Index

async = 0 (insert + read + del)

k/v’k/v

v’/kv/k

Data

Index

1. sync-full: read data tbl to get old value “v”; del index <v/k> using it sync-full = insert + read + del

ACIDSchemes System PerformanceBackground

Page 9: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation9

method index operation data insert data read index insert index readno-index update 1 0 0 0

read -- -- -- --1 sync-full update 1 1 1+1 0

read 0 0 0 12 sync-insert update 1 0 1 0

read 0 M (M) 13 async update 1 1 (Def.) 1+1 (Def.) 0

read 0 0 0 1

Operation complexity analysis of Diff-Index schemes

Operation update=put a record into HBaseOperation read=point query with index access onlyDef.=deferredM=#rows matching the search key

sync-full = insert + read + delsync-insert = insertasync = 0 (insert + read + del)

ACIDSchemes System PerformanceBackground

Page 10: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation10

Session consistency: read-your-own-write

A fine tuning of async = 0 (insert + read + del) Recall the Yelp example

ReviewID Text Stars UserID BusinessID

… … … … …

BusinessID ReviewID… …… …

User 1t1.View reviews for business At2.Post review for business At3.View reviews for business A

User 2t1.View reviews for business B

t3.View reviews for business A

async

BusinessID ReviewIDA R01… …

BusinessID ReviewID… …… …

time

line

ReviewID Text Stars UserID BusinessIDR01 … 5 U1 A… … … … …

Cannot see R01Cannot see R01Can see R01

Session cache “local” to a user

async-session ACIDSchemes System PerformanceBackground

Page 11: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation11

ACID properties

Atomicity – Individual operations PB, PI, RB, DI, are atomic

Consistency – Sync-full and sync-insert: causal consistent– If any of PI, RB, DI fails, causal consistent eventual consistent by AUQ

Isolation: read committed

Durability – Guaranteed by WAL and AUQ failure handling protocol

IBM Confidential

ACIDSchemes System PerformanceBackground

Page 12: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation12

Failure recovery for Asynchronous Update Queue (AUQ) Index update fails in sync- or async- schemes

– Append failed operation to AUQ: casual consistent eventual consistent

What if AUQ fails, e.g., during a server failure?– Option 1: add a log to AUQ– Option 2: leverage the Write-ahead-Log (WAL) of base table

WALput

MemTable

1

2.1HTable

3.1 flush

3.2 roll-forward

HBase

AUQ2.2 Index

tables

4 PI, RB, DI

Diff-Index 3.0 pause& drain AUQ

x

Durability is guaranteed ifEnforce 3.0 before 3.1 flush

Replay index update after WAL replay

Index uses base’s timestamp

PI: insert indexRB: read baseDI: delete index

ACIDSchemes System PerformanceBackground

Page 13: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation13

Diff-Index system: global, server-managed index with configurable schemes

Index Table

AUQ

Coprocessors AsyncObserver

Session cache

Index Utility (create, destroy, bulk load,

cleanse)

getByIndex API

Client Library

TPC-W table

YCSB 0.14

Regions

SyncFullObserver

SyncInsertObserver

Data Table

Async

Sync

BigSQL/BigInights

DDL, Catalog, query engine …

DDL: define indexesCatalog: store index def.Query engine: use index

Client query API; index mgtFunction and

performance testing

index putfailure

Regions

[In IBM InfoSphere BigInsights v2.1]

ACIDSchemes System PerformanceBackground

Page 14: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation14

data update only; 1xsync-full = insert + read + del high >5x

sync-insert = insert ~2xasync = 0 (insert + read + del) low and grows with load

Performance of index update

ACIDSchemes System PerformanceBackground

Page 15: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation15

Performance of index read

Fast

Slow due to double check

As fast as sync-full but inconsistent

You can trade read for update, or vice versa

Performance of index update

ACIDSchemes System PerformanceBackground

Page 16: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation16

Consistency in async: index-after-data time lag

Staleness of async index grows with tranx rate of the system

Measure the distribution of the time-lag, under different transaction rate

async = 0 (insert + read + del)

0%

10%

20%

30%

40%

50%

60%

70%

80%

90%

100%

1 4 7 10 40 70 100 400 700 1000 4000 7000 10000 40000 70000 100000 400000

cum

ulati

ve d

istr

ibuti

on

index staleness (ms)

throughput (TPS) 600 1500 2000 2700 3000 4000

<100 ms

>100 s

ACIDSchemes System PerformanceBackground

Page 17: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation17

Diff-Index schemes: experiments coherent with analysis

SchemeFeature

1 Sync-full 2 Sync-insert

3 Async-session

4 Async

Update latency High Medium Low Low

Read latency Low High/Low Low Low

Consistent read Yes Yes/No No/Session No

Better consistency Better (update) performance

ACIDSchemes System PerformanceBackground

Page 18: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation18

Related Work

HBase index– Salesforce Phoenix: global index

• Has only “sync-full” scheme• Kill region server when index update fails (vs. drop to AUQ)

– Huawei: local index

Transactions in NoSQL– Percolator: 2PC in BigTable– Spanner: 2PC + Paxos + GPS TrueTime– OMID: check R-W (instead of W-W) conflicts to ensure serializability

LSM– bLSM: a better LSM compaction scheduler + BloomFilter

IBM Confidential

Page 19: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation19

Diff-Index–Consistency configurable index for HBase–Lightweight failure recovery by exploiting LSM features–Other product features

• Indexing row key/indexing dense column/composite index• Incremental index maintenance

Future work– Enhance consistency and isolation, e.g., using Percolator or OMID protocol– Workload-aware scheme selection

Summary and future work

Page 20: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation20

Backup slides

IBM Confidential

Page 21: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation21

Range query latency:with different selectivity (i.e., how many records returned by it)

low latency

Double check can be costly

ACIDSchemes System PerformanceBackground

Page 22: © 2012 IBM Corporation1 Diff-Index: Differentiated Index in Distributed Log-Structured Data Stores Wei Tan 1, Sandeep Tata 2, Yuzhe Tang 3, Liana Fong.

© 2012 IBM Corporation22

The basic idea behind Diff-Index: CAP Theorem

Eventual

Lower latencyMore inconsistencies

Higher latencyFewer inconsistencies

Serializable

per-key sequential(HBase out-of-box)

Diff-Index: schemes to balance performance & consistency for LSM-Tree index , by tuning the equation:index_update = insert + read + del

CAP theorem: achieve two out of three in a dist envC: consistencyA: availability (latency)P: partition tolerance

Diff-IndexChallenge System PerformanceMotivation