[email protected] table storage azure cosmos db: table storage (preview) latency fast, but no...

118

Upload: others

Post on 09-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed
Page 3: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

About me

Page 4: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Agenda:

Page 5: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

What is Cosmos DB

Page 6: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

What is Azure Cosmos DB

Page 7: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

What is Azure Cosmos DB

Global Distribution

Worldwide presence

Automatic multi-region replication

Multi-homing APIs

Manual and automatic failovers

Page 8: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

What is Azure Cosmos DB

Elastically Scale-out

Partition management is automatically taken care of for you

Independently scale storage and throughput

Scale storage from Gigabytes to Petabytes

Scale throughput from 100's to 100,000,000's of requests/second

Dial up/down throughput and provision only what is needed

Pro

visi

oned

req

uest

/ s

ec

Time

12000000

10000000

8000000

6000000

4000000

2000000

Nov 2016 Dec 2016

Black Friday

Hourly throughput (request/sec)

Page 9: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

What is Azure Cosmos DB

Guaranteed low latency

Globally distributed with requests served from local region

Write optimized, latch-free database

Automatic Indexing

Page 10: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

What is Azure Cosmos DB

Five Consistency Models

Helps navigate Brewer's CAP theorem

Intuitive Programming

• Tunable well-defined consistency levels

• Override on per-request basis

Clear PACELC tradeoffs

• Partition – Availability vs Consistency

• Else – Latency vs Consistency

Page 11: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

What is Azure Cosmos DB

Comprehensive SLAs

99.99% availability

Durable quorum committed writes

Latency, consistency, and throughput also covered by

financially backed SLAs

Made possible with highly-redundant architecture

Operation

type Single region

Multi-region (single

region writes)

Multi-region (multi-

region writes)

Writes 99.99 99.99 99.999

Reads 99.99 99.999 99.999

Page 12: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Data Formats

Page 13: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Data Formats

Page 14: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Data Formats

• The query syntax is geared at navigating

graphs – you could say e.g. .has(‘person’, ‘name’,

‘Thomas’).outE(‘Knows’) to find people who

Thomas knows.

Page 15: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Data Formats

Page 16: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Data Formats

Page 17: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DBKey Features & Design

Page 18: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Containers and Databases

Page 19: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB key capabilities and benefits

Page 20: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Storage

Page 21: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Indexing

Indexing on by default

Index only specific paths in your document

Page 22: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Page 23: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Page 24: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Page 25: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Page 26: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB

Resources

Page 27: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Container

Page 28: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

• Database Account:

• Regions

• API

Page 29: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

• The container that houses your data

• /dbs/{id} is not your ID• Hash known as a “Self Link”

Page 30: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

• Video

• Audio

• Blob

• Etc.

Page 31: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

• Invite in an existing azure account

• Allows you to set permissions on each concept of the database

Page 32: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

• Authorization token

• Associated with a user

• Grants access to a given resource

Page 33: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

• Most like a “table”

• Structure is not defined

• Dynamic shapes based on what you put in it

Page 34: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

• A blob of JSON representing your data

• Can be a deeply nested shape

• No specialty types

• No specific encoding types

Page 35: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

• Think media – at the document level!

The maximum size for a document

and it's attachment in CosmosDB now is 2 MB.

In DocumentDB the maximum size of document

and it’s attachment was 512KB

Media size – 2GB

Page 36: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

• Written in JavaScript!

• Is transactional

• Executed by the database engine

• Can live in the store

• Can be sent over the wire

Page 37: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

• Can be Pre or Post (before or after)

• Can operate on the following actions

• Create

• Replace

• Delete

• All

• Also written in javascript!

+ Azure

Functions

Page 38: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

• Can only be ran on a query

• Modifies the result of a given query

• mathSqrt()

Page 39: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Page 40: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

JSON array {"exports": [{"city": “Moscow"}, {"city": Athens"}]} correspond to the paths

/"exports"/0/"city"/"Moscow" and /"exports"/1/"city"/"Athens".

Page 41: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Page 42: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Page 43: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Page 44: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Page 45: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Property User settable or system generated? Purpose

_rid System generated System generated, unique and hierarchical

identifier of the resource.

_etag System generated etag of the resource required for

optimistic concurrency control.

_ts System generated Last updated timestamp of the resource.

_self System generated Unique addressable URI of the resource.

id User settable User defined unique name of the

resource.

Page 46: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Value of the _self Description

/dbs Feed of databases under a database account.

/dbs/{_rid-db} Database with the unique id property with the value {_rid-db}.

/dbs/{_rid-db}/colls/ Feed of collections under a database.

/dbs/{_rid-db}/colls/{_rid-coll} Collection with the unique id property with the value {_rid-coll}.

/dbs/{_rid-db}/users/ Feed of users under a database.

/dbs/{_rid-db}/users/{_rid-user} User with the unique id property with the value {_rid-user}.

/dbs/{_rid-db}/users/{_rid-user}/permissions Feed of permissions under a database.

/dbs/{_rid-db}/users/{_rid-user}/permissions/{_rid-permission} Permission with the unique id property with the value {_rid-permission}.

Page 47: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Page 48: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Page 49: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Resources

Partitioned

collection

Single partition

collection (only via

SDK v.2) S1 S2 S3

Maximum

throughput

Unlimited 10K RU/s 250 RU/s 1 K RU/s 2.5 K RU/s

Minimum

throughput

2.5K

400 RU/s

400 RU/s 250 RU/s 1 K RU/s 2.5 K RU/s

Maximum storage Unlimited 10 GB 10 GB 10 GB 10 GB

Price Throughput: $6 /

100 RU/s

Storage: $0.25/GB

Throughput: $6 /

100 RU/s

Storage: $0.25/GB

$25 USD $50 USD $100 USD

Page 50: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Partitioning inAzure Cosmos DB

Page 51: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Partitioning in Cosmos DB

Page 52: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Partitioning in Cosmos DB

Page 53: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Partitioning in Cosmos DB

Page 54: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Partitioning in Cosmos DB

p

p1 p2

Page 55: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Partitioning in Cosmos DB

API Partition Key Row Key

DocumentDB custom partition key path fixed id

MongoDB custom shard key fixed _id

Graph custom partition key

property

fixed id

Table fixed PartitionKey fixed RowKey

Page 56: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Developing againstCosmos DB (SQL API)

Page 57: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Developing against Cosmos DB SQL API

Page 58: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB APIs Support

Page 59: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Developing against Cosmos DB SQL API

using Microsoft.Azure.Documents; using Microsoft.Azure.Documents.Client; using System.Net; using Newtonsoft.Json;

private static string EndpointUrl = "<your endpoint URI>"; private static string PrimaryKey = "<your key>";

Page 60: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Developing against Cosmos DB SQL API

private static async Task GetStartedDemo() {

// Create a new instance of the DocumentClient.var client = new DocumentClient(new Uri(EndpointUrl), PrimaryKey);

}

Page 61: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

awaitclient.CreateDocumentAsync(documentCollection.SelfLink, listing);

Page 62: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

var client = GetClient();var collection = await GetCollection(client, Keys.ListingsDbName,Keys.ListingDbCollectionName);

string sql = String.Format("SELECT * FROM {0}", Keys.ListingDbCollectionName);

var jeepsQuery = client.CreateDocumentQuery<Listing>(collection.SelfLink,sql).ToArray();var jeeps = jeepsQuery.ToArray();

Page 63: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

var client = GetClient();var collection = await GetCollection(client, Keys.ListingsDbName,Keys.ListingDbCollectionName);

string sql = String.Format(@"SELECT l.Color, l.Options, l.Package, l.Type, l.Image,l.Dealer, l.IdFROM {0} lJOIN o IN l.OptionsWHERE o.Name = 'hard top'", Keys.ListingDbCollectionName);var hardtopQuery = client.CreateDocumentQuery<Listing>(collection.SelfLink,sql).ToArray();

Page 64: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

Page 65: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

SELECT

AS

AS

AS

AS

FROM

JOIN IN

JOIN IN

Page 66: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

var

id: "contains",

function {

if (arr.indexOf(obj) > -1) {

return true;

}

return false;

}

Page 67: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

SELECT FROM Families WHERE

contains "Andersen" false

Page 68: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

Page 69: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

var createDocumentStoredProc = {

id: "createCustomDocument",

body: function createCustomDocument(documentToCreate) {

var context = getContext();

var collection = context.getCollection();

var accepted = collection.createDocument(collection.getSelfLink(),

documentToCreate,

function (err, documentCreated) {

if (err) throw new Error('Error' + err.message);

context.getResponse().setBody(documentCreated.id)

});

if (!accepted) return;

}}

Page 70: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

var result =

client.ExecuteStoredProcedureAsync(

createdStoredProcedure._self);

Page 71: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

Page 72: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

var validateDocumentContentsTrigger = {

name: "validateDocumentContents",

body: function validate() {

var context = getContext();

var request = context.getRequest();

// document to be created in the current operation

var documentToCreate = request.getBody();

// validate properties

if (!("timestamp" in documentToCreate)) {

var ts = new Date();

documentToCreate["doc timestamp"] = ts.getTime();

}

// update the document that will be created

request.setBody(documentToCreate);

},

triggerType: TriggerType.Pre,

triggerOperation: TriggerOperation.Create

}

Page 73: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

var updateMetadataTrigger = {

name: "updateMetadata",

body: function updateMetadata() {

var context = getContext();

var collection = context.getCollection();

var response = context.getResponse();

var createdDocument = response.getBody();

var filterQuery = 'SELECT * FROM c WHERE c.id = "_metadata"';

var accept = collection.queryDocuments(collection.getSelfLink(),

filterQuery,

updateMetadataCallback);

if(!accept) throw "Unable to update metadata, abort";

….

},

triggerType: TriggerType.Post,

triggerOperation: TriggerOperation.All

}

Page 74: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

function updateMetadataCallback(err, documents, responseOptions) {

var metadataDocument = documents[0];

// update metadata

metadataDocument.createdDocuments += 1;

metadataDocument.createdNames += " " + createdDocument.id;

var accept = collection.replaceDocument(metadataDocument._self,

metadataDocument, function(err, docReplaced) {

if(err) throw "Unable to update metadata, abort";

});

if(!accept) throw "Unable to update metadata, abort";

return;

}

Page 75: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

Page 76: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Querying Cosmos DB SQL API

Page 77: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB and Table Storage

Page 78: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB: Table API

Page 79: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB: Table API

Page 80: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB: Table API

Azure Table Storage

Azure Cosmos DB: Table storage

(preview)

Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and

writes, backed with <10-ms latency reads

and <15-ms latency writes at the 99th

percentile, at any scale, anywhere in the

world

Throughput variable throughput model. Tables have a

scalability limit of 20,000 operations/s

Highly scalable with dedicated reserved

throughput per table, that is backed by

SLAs. Accounts have no upper limit on

throughput, and support >10 million

operations/s per table

Global Distribution Single region with one optional readable

secondary read region for HA. You cannot

initiate failover

Turn-key global distribution from one to 30+

regions, Support for automatic and manual

failovers at any time, anywhere in the world

Indexing Only primary index on PartitionKey and

RowKey. No secondary indexes

Automatic and complete indexing on all

properties, no index management

Page 81: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB: Table API

Azure Table Storage

Azure Cosmos DB: Table storage

(preview)

Query Query execution uses index for primary

key, and scans otherwise.

Queries can take advantage of

automatic indexing on properties for

fast query times. Azure Cosmos DB's

database engine is capable of

supporting aggregates, geo-spatial, and

sorting.

Consistency Strong within primary region, Eventual

with secondary region

Five well-defined consistency levels to

trade off availability, latency,

throughput, and consistency based on

your application needs

Pricing Storage-optimized Throughput-optimized

SLAs 99.9% availability 99.99% availability within a single

region, and ability to add more regions

for higher availability. Industry-leading

comprehensive SLAs on general

availability

Page 82: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB: Table API

https://<mytableendpoint>/People

(PartitionKey='Harp',RowKey='Walter')

https://<mytableapi-endpoint>/People()?$filter=

PartitionKey%20eq%20'Smith'%20and%20Email%20eq%20'[email protected]

'

Page 83: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB andMongoDB

Page 84: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB: API for MongoDB

Page 85: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB: API for MongoDB

Page 86: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB: API for MongoDB

Page 87: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB andGraph API

Page 88: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB: Graph API

Page 89: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Performance

Page 90: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Performance: SQL API

Use direct connection mode for better performance

Page 91: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Performance: SQL API

var client =DocumentClient client = new DocumentClient

(serviceEndpoint, authKey,

new ConnectionPolicy

{

ConnectionMode = ConnectionMode.Direct,

ConnectionProtocol = Protocol.Tcp

});

Page 92: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Performance: SQL API

Page 93: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Performance: SQL API

Page 94: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Performance: SQL API

Document document = await

client.ReadDocumentAsync("/dbs/1234/colls/1234354/docs/2332435465");

Page 95: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB Regional Failover

Page 96: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Multi-master at global scale with Azure Cosmos DB

Page 97: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Multi-master at global scale with Azure Cosmos DB

Page 98: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Multi-master at global scale with Azure Cosmos DB

Page 99: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Cosmos DB and EF Core

Page 100: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Entity Framework Core

Page 101: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed
Page 102: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

MS Ignite Announcements

Page 103: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Latest Cosmos DB announcemens

Page 104: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Scenarios to use Cosmos DB & Power BI in IoT

Page 105: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Azure IoT Reference Architecture

Page 106: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Azure IoT Architecture [Alternatives]

Page 107: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

IoTHub, Blob Storage, and Function Apps: Building Hot and

Cold Paths

Page 108: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

IoT Data Ingression Event Hub

[Cheaper Alternative]

Persist DataCosmos DBEvent Hubs

Capture Storage (Azure)

Power Bi Dashboard

1CollectData

2Event Hub

Capture

Collect DataClean Up Data Account

PersistData

Processing Function

Analyze

IoT Data Ingression – Event Hub, Azure Storage, Azure Function, Cosmos DB, Power BI [Cheaper Alternative]

1. Devices send messages to Event Hub2. Event Hub Captures data to Azure Blob Storage3. Data update in the storage triggers Azure Function4. Azure Function persists data into Cosmos DB5. Power BI Dashboard visualize data from Cosmos DB

Page 109: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

IoT Data Ingression IoT Hub

[Cheaper Alternative]

Persist DataCosmos DBEvent Hubs

Capture Storage (Azure)

Power Bi Dashboard

1CollectData

2Event Hub

Capture

Collect DataClean Up Data Account

PersistData

Processing Function

Analyze

IoT Data Ingression – Event Hub, Azure Storage, Azure Function, Cosmos DB, Power BI [Cheaper Alternative]

1. Devices send messages to Event Hub2. Event Hub Captures data to Azure Blob Storage3. Data update in the storage triggers Azure Function4. Azure Function persists data into Cosmos DB5. Power BI Dashboard visualize data from Cosmos DB

Page 110: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

IoT Data Ingression – IoT Hub, Azure Function, Cosmos DB,

Power BI

Persist DataCosmos DB

Power Bi Dashboard

1CollectData

2Azure Function

read messages from IoT Hub

PersistData

Processing Function

Analyze

IoT Data Ingression – IoT Hub, Azure Function, Cosmos DB, Power BI

1. Devices send messages to IoT Hub2. IoT Hub Routes data to Azure Blob Storage 3. Data update in the storage triggers Azure Function4. Azure Function persists data into Cosmos DB5. Power BI Dashboard visualize data from Cosmos DB

IoT Hub

Page 111: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

IoT : ASA, Cosmos DB, Power BI – v.1

Page 112: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

IoT : Azure databricks, Cosmos DB, Power BI

Page 113: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Missing Features

Page 114: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Missing Features in Cosmos DB

Page 115: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Demo

Page 116: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Questions?

Page 117: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed

Thank you!

Page 118: mihail@mateev...Azure Table Storage Azure Cosmos DB: Table storage (preview) Latency Fast, but no upper bounds on latency Single-digit millisecond latency for reads and writes, backed