43
©2016 Couchbase Inc. Picking the right API for the right Job 1

Picking the right API for the right job – Couchbase Connect 2016

Embed Size (px)

Citation preview

©2016 Couchbase Inc. 1

Picking the right API for the right Job

©2016 Couchbase Inc. 2

Michael NitschingerSenior Software Engineer, [email protected]

daschl

IMAGE GOES HERE

©2016 Couchbase Inc. 3

Michael NitschingerSenior Software Engineer, [email protected]

daschl

http://www.wienerwald.at/wp-content/uploads/2016/01/schnitzel_pommes.jpg

©2016 Couchbase Inc. 4

Michael NitschingerSenior Software Engineer, [email protected]

daschl

http://www.wienerwald.at/wp-content/uploads/2016/01/schnitzel_pommes.jpg

©2016 Couchbase Inc. 5

One SDK API to rule them all

©2016 Couchbase Inc. 6

One SDK API to rule them all

http://vignette3.wikia.nocookie.net/lotr/images/e/e1/Gollum_Render.png/revision/20141216091433

©2016 Couchbase Inc.©2016 Couchbase Inc.

Services

STORAGE

Couchbase Server 1

SHARD7

SHARD9

SHARD5

SHARDSHARDSHARD

Managed Cache

Cluster ManagerCluster Manager

Data Service STORAGE

Couchbase Server 2

Managed Cache

Cluster ManagerCluster Manager

Data Service STORAGE

Couchbase Server 3

SHARD7

SHARD9

SHARD5

SHARDSHARDSHARD

Managed Cache

Cluster ManagerCluster Manager

Data Service STORAGE

Couchbase Server 4

SHARD7

SHARD9

SHARD5

SHARDSHARDSHARD

Managed Cache

Cluster ManagerCluster Manager

Index Service STORAGE

Couchbase Server 5

SHARD7

SHARD9

SHARD5

SHARDSHARDSHARD

Managed Cache

Cluster ManagerCluster Manager

STORAGE

Couchbase Server 6

SHARD7

SHARD9

SHARD5

SHARDSHARDSHARD

Managed Cache

Cluster ManagerCluster Manager

Query Service

FTS Service

Index Service

©2016 Couchbase Inc.©2016 Couchbase Inc.

Services

Data Views N1QL FTS Analytics

©2016 Couchbase Inc.©2016 Couchbase Inc.

Services

DataBinary11210

ViewsJSON8092

N1QLJSON8093

FTSJSON8094

AnalyticsJSON8095

©2016 Couchbase Inc.©2016 Couchbase Inc.

Balance

10https://upload.wikimedia.org/wikipedia/commons/b/b7/Unico_Anello.png

Language Specifics Uniformity across SDKs

©2016 Couchbase Inc.©2016 Couchbase Inc.

Balance

11https://upload.wikimedia.org/wikipedia/commons/b/b7/Unico_Anello.png

©2016 Couchbase Inc.©2016 Couchbase Inc.

Balance

12https://upload.wikimedia.org/wikipedia/commons/b/b7/Unico_Anello.png

©2016 Couchbase Inc.©2016 Couchbase Inc.

Balance

13https://upload.wikimedia.org/wikipedia/commons/b/b7/Unico_Anello.png

©2016 Couchbase Inc.©2016 Couchbase Inc.

Balance

14https://upload.wikimedia.org/wikipedia/commons/b/b7/Unico_Anello.png

©2016 Couchbase Inc. 15©2016 Couchbase Inc.

RFCs

• Semi-Formal process to advance SDKs in both API and behavior• One Shepherd• Collaborative consensus (hard!) compromises• Public: https://github.com/couchbaselabs/sdk-rfcs

©2016 Couchbase Inc. 16©2016 Couchbase Inc.

Prioritizing Uniformity

• Program Flow

©2016 Couchbase Inc. 17©2016 Couchbase Inc.

Prioritizing Uniformity

©2016 Couchbase Inc. 18©2016 Couchbase Inc.

Prioritizing Language Specifics

©2016 Couchbase Inc. 19

Navigating the API Landscape

©2016 Couchbase Inc. 20©2016 Couchbase Inc.

Key/Value

• Fastest way to access & mutate documents• Access by Document ID only• Includes subdocument manipulation• Efficient binary protocol

Latency Flexibility

©2016 Couchbase Inc. 21©2016 Couchbase Inc.

Key/Value – Full Doc Access

©2016 Couchbase Inc. 22©2016 Couchbase Inc.

Key/Value – Full Doc Access

©2016 Couchbase Inc. 23©2016 Couchbase Inc.

Key/Value – Sub Doc Access

©2016 Couchbase Inc. 24©2016 Couchbase Inc.

Views

• Distributed Map-Reduce• Great for Aggregations (fast)• Spatial Support

Latency Flexibility

©2016 Couchbase Inc. 25©2016 Couchbase Inc.

Views

©2016 Couchbase Inc. 26©2016 Couchbase Inc.

N1QL

• Very flexible, but get your index right• Global Index instead of Map/Reduce• Similar to SQL

Latency Flexibility

©2016 Couchbase Inc. 27©2016 Couchbase Inc.

N1QL

©2016 Couchbase Inc. 28©2016 Couchbase Inc.

Full Text Search

• Very Flexible, but more concepts to learn initially• Inverted Index• Still Developer Preview• Similar to Elasticsearch

Latency Flexibility

©2016 Couchbase Inc. 29©2016 Couchbase Inc.

Full Text Search

©2016 Couchbase Inc. 30©2016 Couchbase Inc.

Analytics

• Highly capable analytical storage engine• Similar to N1QL for querying• Performs great on huge datasets and aggregations• Developer Preview announced at Connect!

Latency Flexibility

©2016 Couchbase Inc. 31©2016 Couchbase Inc.

Streaming/Changes Feed

• Based on the DCP protocol• Very fast and efficient• Low level -> Building Block

Latency Flexibility

©2016 Couchbase Inc. 32©2016 Couchbase Inc.

Michael’s Super Sophisticated Flowchart to Success

Know the Doc ID(s)? SuccessUse KV

Pre GroupedAggregations?

Use Views

Need Full Text Queries?

Use FTS Use N1QL

©2016 Couchbase Inc. 33©2016 Couchbase Inc.

Michael’s Super Sophisticated Flowchart to Success

Know the Doc ID(s)? SuccessUse KV

Pre GroupedAggregations?

Use Views

Need Full Text Queries?

Use FTS Use N1QL

©2016 Couchbase Inc. 34©2016 Couchbase Inc.

Michael’s Super Sophisticated Flowchart to Success

Know the Doc ID(s)? SuccessUse KV

Pre GroupedAggregations?

Use Views

Need Full Text Queries?

Use FTS Use N1QL

©2016 Couchbase Inc. 35©2016 Couchbase Inc.

Michael’s Super Sophisticated Flowchart to Success

Know the Doc ID(s)? SuccessKV

Pre GroupedAggregations?

Views

Need Full Text Queries?

FTS N1QL

©2016 Couchbase Inc. 36

(Not So) Dirty Tricks for Fun and Profit

©2016 Couchbase Inc. 37©2016 Couchbase Inc.

The “Cache It While Its Hot”

• Transparently cache expensive N1QL/FTS/View results with a TTL and load while hot

©2016 Couchbase Inc. 38©2016 Couchbase Inc.

The “Cache It While Its Hot”

• Transparently cache expensive N1QL/FTS/View results with a TTL and load while hot

©2016 Couchbase Inc. 39©2016 Couchbase Inc.

The “Custom Bulk Loader”

• Perform a N1QL, FTS or View query to just fetch the doc IDs, then perform a bulk KV fetch

©2016 Couchbase Inc. 40©2016 Couchbase Inc.

The “Custom Bulk Loader”

• Perform a N1QL, FTS or View query to just fetch the doc IDs, then perform a bulk KV fetch

©2016 Couchbase Inc. 41©2016 Couchbase Inc.

The “Tarzan of the Docs”

• “Leap” from Doc to Doc via references and use bulk fetches for higher throughput

• Scales with increasing batch size• Allows to “code” intermediate steps with UDFs

©2016 Couchbase Inc. 42©2016 Couchbase Inc.

Summary

TradeoffLatency vs. Flexibility

RememberPowerful Patterns

Unsure?Think of the Flowchart

Participatein the RFCs!

©2016 Couchbase Inc. 43

Thank You!