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

Post on 21-Aug-2015

465 views 2 download

Tags:

Transcript of 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

©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

Securing Client-Server Communication with SSL

Why SSL?

Installing certificates

Configuring the client

Overview

©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?

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

©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?

©2014 Couchbase, Inc. 8

Step 1: Copy the Certificate

©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

©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

©2014 Couchbase, Inc. 11

Configuring the Client: Programmatic configuration

©2014 Couchbase, Inc. 12

Configuring the Client: using a Config file

Couchbase SDK 2.0 Overview

©2014 Couchbase, Inc. 13

Motivation

From past to present

©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

©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

The “New” Object Model

©2014 Couchbase, Inc. 17

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

The components

The Components

©2014 Couchbase, Inc. 20

The components: example (C#)

©2014 Couchbase, Inc. 21

Connecting to a Cluster

©2014 Couchbase, Inc. 22

Opening a Bucket

Documents

Our first-class citizens

©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

©2014 Couchbase, Inc. 25

The Document: C#

©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

©2014 Couchbase, Inc. — Proprietary and Confidential 27

Example Document - Java

©2014 Couchbase, Inc. — Proprietary and Confidential 28

Example Document - .NET

API

©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

©2014 Couchbase, Inc. — Proprietary and Confidential 31

Insert .NET

©2014 Couchbase, Inc. — Proprietary and Confidential 32

Replace Java

©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

©2014 Couchbase, Inc. — Proprietary and Confidential 34

Get PHP

©2014 Couchbase, Inc. — Proprietary and Confidential 35

Get NodeJS

©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

©2014 Couchbase, Inc. — Proprietary and Confidential 37

Sync Querying Java

©2014 Couchbase, Inc. — Proprietary and Confidential 38

Querying .NET

New Reactive and Asynchronous API’s

©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.

©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

Task-based Asynchronous Patternwith .NET

©2014 Couchbase, Inc. 42

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?

©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

©2014 Couchbase, Inc. 45

Example: Asynchronous Views

©2014 Couchbase, Inc. 46

Example: Asynchronous N1QL Queries

©2014 Couchbase, Inc. 47

Task Parallel Library: Multi Get/Upsert

Reactive with the Java SDK

©2014 Couchbase, Inc. — Proprietary and Confidential 49

Connecting Async

©2014 Couchbase, Inc. — Proprietary and Confidential 50

Storing a Document

©2014 Couchbase, Inc. — Proprietary and Confidential 51

Loading a Document

©2014 Couchbase, Inc. — Proprietary and Confidential 52

Querying

©2014 Couchbase, Inc. — Proprietary and Confidential 53

Querying

Thank you!

http://couchbase.com/developer

Twitter: @jeffrysmorris

Skype: jeffscottmorris

http://blog.couchbase.com/jeff

©2014 Couchbase, Inc. 54