new server, new clients: taking your couchbase 3.0 apps to the next level

54
New Server, New Clients: Taking your Couchbase 3.0 apps to the next level Jeff Morris | Software Engineer, Couchbase

Upload: couchbase

Post on 21-Aug-2015

465 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

Jeff Morris | Software Engineer, Couchbase

Page 2: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 2

Use SSL in SDK 2.0 to secure client-server communication Build rich and more powerful applications Learn document-oriented APIs & reactive language interfaces

Agenda

Page 3: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

Securing Client-Server Communication with SSL

Page 4: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

Why SSL?

Installing certificates

Configuring the client

Overview

Page 5: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 5

Data sent between client and server is in plain text

Cloud and hybrid cloud deployments more and more common

Hackers and the tools are becoming more and more sophisticated

Gaining customer trust

Protecting from “man-in-the-middle” attacks

Why SSL?

Page 6: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

Encrypted Admin & Data Access

Data Access Encryption SSL based Client-server Communications SSL based View Access

https://couchbase_server:18092/…

Admin Access Encryption – REST, CLI and HTTPShttps://couchbase_server:18091/…

Encrypted Client-Server Communication

SERVER 3SERVER 1 SERVER 2

Couchbase Server

Page 7: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 7

Three Steps:

1. Copy the certificate 2. Install it into the certificate store3. Enable SSL on the client

That’s It!

How do we use SSL in our Couchbase Applications?

Page 8: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 8

Step 1: Copy the Certificate

Page 9: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 9

Varies from OS to OS On Windows:

Step 2: Install it in the Ceritificate Store

Copy the “.crt” file from Step 1 to your app serverOpen the Certificate Manager (certmgr.msc)Locate the “Trusted Root Certification Authority”Right click on it and then All Tasks -> ImportFollow the wizard to finish the installation

Page 10: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 10

Each SDK has it’s own implementation of “UseSsl” Once enabled, the client will send all traffic on the following ports:

Step 3: Enable “UseSsl” on the client:

All data sent between the Application and the Cluster will be encrypted All ports are configurable! Supported by Enterprise Edition 3.0+

UseSsl: true UseSsl:false

Management API 18091 8091

View API 18092 8092

Binary Memcached 11207 11210

Page 11: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 11

Configuring the Client: Programmatic configuration

Page 12: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 12

Configuring the Client: using a Config file

Page 13: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

Couchbase SDK 2.0 Overview

©2014 Couchbase, Inc. 13

Page 14: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

Motivation

From past to present

Page 15: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 15

Couchbase Server evolved from a cache to a document oriented database.

SDK APIs Programing model in place since the cache era “Memcached-like” Enhanced for views and config management

The 2.0 SDK initiative Provide document oriented APIs to the developer Supporting current and future evolvements (3.0+) Interoperability

Motivation

Page 16: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 16

2.0 GA Availability Java .NET Node.js PHP

Full Document support Interoperability Very similar programming model Embracing language specifics

Current State

Page 17: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

The “New” Object Model

©2014 Couchbase, Inc. 17

Page 18: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

The client SDKs are comprised of the following components: Cluster Buckets Documents Queries Operations

The components

Page 19: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

The Components

Page 20: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 20

The components: example (C#)

Page 21: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 21

Connecting to a Cluster

Page 22: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 22

Opening a Bucket

Page 23: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

Documents

Our first-class citizens

Page 24: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 24

Documents are integral to the SDKs. There are many implementations, depending on the content type. A Document contains:

The Document

Property Description

ID The bucket-unique identifier

Content The value that is stored

Expiry An expiration time

CAS The Compare-And-Swap identifier

Page 25: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 25

The Document: C#

Page 26: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 26

Document implementations are language specific. All support JSON in its different forms. In addition, some support:

Serialized objects Unquoted Strings Binary pass-through Legacy …

Document Implementations

Page 27: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 27

Example Document - Java

Page 28: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 28

Example Document - .NET

Page 29: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

API

Page 30: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 30

Modifying Documents

Method Description

Insert(…) Inserts the document it does not exist

Replace(…) Replaces the document if it exists

Upsert(…) Updates or Inserts the document

Remove(…) Removes the document

Append(…) Append data to the document

Prepend(…) Prepend data to the document

Increment(…) Increments the counter

Decrement(…) Decrements the counter

Page 31: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 31

Insert .NET

Page 32: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 32

Replace Java

Page 33: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 33

Retrieving Documents

Method Description

Get(…) Gets the document

GetFromReplica() If the master is not available

GetAndLock() Loads the document with a write-lock

GetAndTouch() Loads the document and resets the expiry

Page 34: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 34

Get PHP

Page 35: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 35

Get NodeJS

Page 36: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 36

query() is possible for Views N1QL (experimental)

Streams N response rows as they arrive from the server Loads more than one Document based on Criteria Typically used to satisfy secondary and advanced querying use cases

Querying

Page 37: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 37

Sync Querying Java

Page 38: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 38

Querying .NET

Page 39: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

New Reactive and Asynchronous API’s

Page 40: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 40

Tough challenges for applications nowadays Hard to overcome with traditional solutions

Modern applications need to React to user load React to failure Be responsive all the time

Decoupled, event-driven architectures are the foundation. Resources need to be utilized as best as possible.

Waiting for IO is bad.

Page 41: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 41

Asynchronous Programming Models are the key… But, which model to chose?

Reactive Programming (RX) Traditional Asynchronous Programming (call backs) Task Parallel Library & Task Asynchrony Pattern Event Loops

The Couchbase approach is to use what idiomatic to the platform!

Reactive and Asynchronous Programming Models

Page 42: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

Task-based Asynchronous Patternwith .NET

©2014 Couchbase, Inc. 42

Page 43: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

Takes advantage of the C# language keywords async/await

Uses a single method to represent initiation and completion of an

asynchronous operation

Supports common idioms such as futures, pipelining, composition and

continuations on antecedents

Comes “built-in” with .NET 4.5

What is the Task Asynchronous Pattern?

Page 44: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 44

Currently supported:

Asynchronous Views Asynchronous N1QL queries

Coming soon:

Asynchronous operations on documents Asynchronous Management API

Async/await support in the .NET SDK 2.0

Page 45: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 45

Example: Asynchronous Views

Page 46: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 46

Example: Asynchronous N1QL Queries

Page 47: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. 47

Task Parallel Library: Multi Get/Upsert

Page 48: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

Reactive with the Java SDK

Page 49: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 49

Connecting Async

Page 50: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 50

Storing a Document

Page 51: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 51

Loading a Document

Page 52: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 52

Querying

Page 53: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

©2014 Couchbase, Inc. — Proprietary and Confidential 53

Querying

Page 54: New Server, New Clients: Taking your Couchbase 3.0 apps to the next level

Thank you!

http://couchbase.com/developer

Twitter: @jeffrysmorris

Skype: jeffscottmorris

http://blog.couchbase.com/jeff

©2014 Couchbase, Inc. 54