Introduction to Azure DocumentDB

23

Transcript of Introduction to Azure DocumentDB

Introduction to Microsoft Azure DocumentDB

Radenko Zec - Lanaco

Agenda

• NoSQL• Introduction to Azure DocumentDB• Storing data • Querying data • Transactions over data

No SQL in Database what ???

Is DocumentDB NoSQL database?

• database management system that is non relational

• schema less, avoids joins & easy to scale

• NoSQL =

DocumentDB at MSN.com

• over 425 million unique users• store 20TB of JSON document data• available globally to serve all markets• under 15ms writes and single digit ms reads

• designed, built and optimized for JSON• schema-free and queryable

Resource Model• Entities addressable by logical URI• Partitioned for scale out • Replicated for HA• Entities represented as JSON• Accounts scale out through addition of

capacity units

Interaction Model• RESTful interaction

over HTTP

• HTTP and TCP connectivity

Attachments

• Store large blobs/media outside core storage• Document DB managed– Submit raw content in POST– Document DB stores into Azure Blob storage

(2GB today)– Document DB manages lifecycle

DEMO - Getting Started

Indexing in DocumentDB

• By default everything is indexed• Indexing is not a B-Tree (based on BWTree used in

Hackaton) and works really well under write pressure and at scale

DocumentDBConsistency options

DocumentDBConsistency options

Tunning indexesPOST https://<REST URI>/colls HTTP/1.1

...

Accept: application/json

{

"id":"customIndexCollection",

"indexingPolicy":{

"automatic":true,

"indexingMode":"Consistent",

"IncludedPaths":[

{

"IndexType":"Hash",

"Path":"/"

}

],

"ExcludedPaths":[

"/\"nonIndexedContent\"/*"

]

}

}

...

Indexing modes:• synchronous (Consistent) • asynchronous (Lazy)

Index types:• Hash• Range

Sharding

Fan-Out queries (map-reduce)

Multi Document JavaScript Transactions

• Execution wrapped in an implicit transaction • Preregistered and scoped to a collection• Performed with ACID guarantees• If exceptions are thrown through the server side

execution of JavaScript application code, the entire transaction is rolled back.

DEMO – Queries, CRUD, Stored Procedures

Known limits

• Stored procedure 5 second execution timeout• Index policies can be specified only at collection creation

time• no aggregate functions for now, no datetime type• no joins between documents and collections• Maximum request size of document and attachment 512KB• Maximum response size - 1MB• Maximum Request Units / sec per collection 2000etc…

The End

• Radenko Zec – Lanaco• http://blog.developers.ba• @radenkozec

Ne zaboravite ispuniti upitnike.Čekaju vas vrijedne nagrade!