Azure DocumentDB: Advanced Features for Large-Scale Apps {

Slides:



Advertisements
Similar presentations
Windows 8 (1) (2) (3) Windows 8 (1) (2) (3)
Advertisements

Feature: Purchase Requisitions - Requester © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Understanding Active Directory
Session 1.
Building Android Apps with Mobile Services Speaker Name Speaker Title Speaker Company Twitter:
Windows 8 (1) (2) (3) Windows 8 (1) (2) (3)
Getting Started with Windows Azure Name Title Microsoft Corporation.
demo Cloud Storage WA Blobs Schema Management APIs & Portal Web Roles Integration Pipeline 3 rd Party Web Services 3 rd Party Store 3 rd Party.
Ronnie Saurenmann Principal Architect Microsoft Switzerland.
Operating System for the Cloud Runs applications in the cloud Provides Storage Application Management Windows Azure ideal for applications needing:
CONNECTING PHONE APPLICATIONS TO THE CLOUD Nick Randolph (Built to Roam) SESSION CODE: COS-WPH208 (c) 2011 Microsoft. All rights reserved.
demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
Travis Sansome NoSQL PaaS in Azure through DocumentDB DAT332.
Sage Franch | Technical Evangelist Susan Ibach | Technical Evangelist.
{ "name": "SmugMug", "permalink": "smugmug", "homepage_url": " "blog_url": " "category_code": "photo_video",
Migrate SQL Server Apps to SQL Azure Cloud DB
Azure.
Use relational database as a service
Data Platform and Analytics Foundational Training
Build /26/2018 6:17 AM Building Resilient, Scalable Services with Microsoft Azure Service Fabric Érsek © 2015 Microsoft Corporation.
Delivering enterprise BI with Azure Analysis Services
System Center Marketing
Mobile App Trends: lifecycle, functions, and cognitive
Globally distributed, secure MongoDB with Azure Cosmos DB
Microsoft Dynamics NAV 2017
Developing an app for SharePoint autohosted in Azure
Create and publish reports with Power BI for desktop
Azure.
Microsoft Intune MAM without Device Enrollment
Cloud Database Based on SQL Server 2012 Technologies
Hybrid Apps: Azure Mobile Engagement and the App Economy
Microsoft Build /20/2018 5:17 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Building real-time web apps with WebSockets using IIS, ASP.NET and WCF
Melbourne Azure Meetup
Windows Azure 講師: 李智樺, Ruddy Lee
The Challenges of moving Document Creation to the Cloud
Melbourne Azure Meetup
The Internet of Things (IoT) from the back-end perspective
Title of Presentation 12/2/2018 3:48 PM
Building event-driven, long-running apps with Windows workflow
Building Windows 8 and Windows Azure apps
Power-up NoSQL with Azure Cosmos DB
Getting started with Windows Azure
TechEd /15/2019 8:08 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
1/16/2019 8:14 PM SAC-863T Delivering notifications with the Windows Push Notification Service and Windows Azure Darren Louie, Nick Harris Program Manager,
TechEd /18/ :01 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered.
Building and running HPC apps in Windows Azure
Developing for Windows Azure
Building device & cloud apps
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Windows Azure Overview
Using tiles and notifications
Building global and highly-available services using Windows Azure
Developing Windows Azure Applications with Visual Studio
The complete developer's guide to the SkyDrive API
Cloud-powered Load Testing with Team Foundation Service
Title of Presentation 5/24/2019 1:26 PM
Server-Side Programming
Global Distribution.
Sessions about to start – Get your rig on!
Making Windows Azure Relevant to IT Professionals
Erik Porter Program Manager ASP.NET Microsoft Corporation
Building Windows Store Apps with Windows Azure Mobile Services
New, Old or Pink - it is all good
Microsoft Virtual Academy
Server & Tools Business
Cosmic DBA Cosmos DB for SQL Server Admins and Developers
Presentation transcript:

Azure DocumentDB: Advanced Features for Large-Scale Apps { "name": "Andrew Liu", "e-mail": "andrl@microsoft.com", "twitter": "@aliuy8" }

First… a Story

Indexing JSON and fighting zombies at SCALE

Next Games The Walking Dead TV show Drama about a zombie walker apocalypse on AMC First cable drama to beat broadcast shows Most watched cable TV show in the US (16M users) Game Development Studio Based in Helsinki, Finland 65 employees Develop F2P mobile games for iOS and Android Based on own & licensed IP

The Challenge More Users, More Problems Scale with expectation of millions of users on Day 1 Deliver real time responsiveness for a lag-free, gaming experience Highly competitive – high scores and global leaderboards critical

The Results #1 in Apple app store free apps during launch week >1M downloads ~1B queries per day 99p queries served under 10ms

How?

Just throw some data in a database!

Just throw some data in a database!

Not that easy…

Why is this such a hard problem? Caches Scoreboard keeps updating… SQL database Need to shard Schema and Index Management Loss of relational benefits Azure Table Storage Secondary Indexes Latency Throughput

Azure DocumentDB

Perfect for these Documents schema-agnostic JSON store for { "name": "SmugMug", "permalink": "smugmug", "homepage_url": "http://www.smugmug.com", "blog_url": "http://blogs.smugmug.com/", "category_code": "photo_video", "products": [ "permalink": "smugmug" } ], "offices": [ "description": "", "address1": "67 E. Evelyn Ave", "address2": "", "zip_code": "94041", "city": "Mountain View", "state_code": "CA", "country_code": "USA", "latitude": 37.390056, "longitude": -122.067692 ] Perfect for these Documents schema-agnostic JSON store for hierarchical and de-normalized data at scale

Not these documents

Perfect for these Documents schema-agnostic JSON store for 10/12/2018 { "name": "SmugMug", "permalink": "smugmug", "homepage_url": "http://www.smugmug.com", "blog_url": "http://blogs.smugmug.com/", "category_code": "photo_video", "products": [ "permalink": "smugmug" } ], "offices": [ "description": "", "address1": "67 E. Evelyn Ave", "address2": "", "zip_code": "94041", "city": "Mountain View", "state_code": "CA", "country_code": "USA", "latitude": 37.390056, "longitude": -122.067692 ] Perfect for these Documents schema-agnostic JSON store for hierarchical and de-normalized data at scale Well nested, multiple properties and values © 2015 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Why? Horizontal Scaling for storage and throughput High performance with SSDs and automatic indexing Operating on a global scale

Fully managed as a service 10/12/2018 Fully managed as a service Predictable Performance Hourly Billing 99.95% Availability Adjustable Performance Levels database users, permissions S1 S2 S3 collections … Image licensed under the Creative Commons Attribution 2.0 Generic license: http://en.wikipedia.org/wiki/File:A_smiling_baby.jpg © 2015 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Fully managed as a service 10/12/2018 Fully managed as a service Predictable Performance Hourly Billing 99.95% Availability Adjustable Performance Levels database users, permissions S1 S2 S3 collections … Image licensed under the Creative Commons Attribution 2.0 Generic license: http://en.wikipedia.org/wiki/File:A_smiling_baby.jpg I’m not crying anymore © 2015 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Request Units Predictable Performance 10/12/2018 Request Units % CPU GET Resource READ % IOPS Resource set Resource POST % Memory INSERT Request Unit (RU) is the normalized currency Replica gets a fixed budget of Request Units Resource PUT Resource REPLACE Predictable Performance Most import metric in DocumentDB! DELETE Resource DELETE Documents SQL POST Query args POST sprocs EXECUTE © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Microsoft Build 2016 10/12/2018 11:23 PM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Mobile games – cloud backend 10/12/2018 11:23 PM Mobile games – cloud backend Powerful clients, backend used to connect users and enhance play Store data outside mobile device (levels, scores, badges) Facilitate multiplayer games & social gameplay Manage the leaderboard Orchestrate push notifications Facilitate in-game purchases Deliver dynamic game content iOS Windows Android © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Mobile games – cloud backend 10/12/2018 11:23 PM Mobile games – cloud backend Simplified TWD architecture Mobile Game Backend Services Queues iOS Cloud Endpoints Storage Windows Logging / Analytics NoSQL Database Push Notifications Android © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Mobile games – cloud backend 10/12/2018 11:23 PM Mobile games – cloud backend Simplified TWD architecture iOS Storage Queues Cloud Services Storage, CDN Traffic Manager Windows Gaming Analytics Service DocumentDB Notification Hubs Android © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Backend services and state 10/12/2018 11:23 PM Backend services and state Worker roles proffering services over game data In-app purchases Service Game Frontend (SignalR Hub) Leaderboard Service Social & Guild Service Admin Service Notification Service Logging / Analytics Service Gaming storage with DocumentDB Player data and scores Guild and social data © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Scaling player data store 10/12/2018 11:23 PM Scaling player data store { "id": "G02-D06-5d085b11", "CountryCode": "hk", "Nickname": "DannyBoy", "NicknameLower": "dannyboy", "Score": 0, "SecondaryScore": 18, "IndexScore": 0.18, "Level": 1, "HashedId": "b134bd5c5b5748f", "LastSaveUnixTime": 1446591499, "LastLoadUnixTime": 1446590552, "DisconnectedUnixTime": 1446591499, "FacebookId": "FB_1010006092353214", "GameCenterId": "GC_G:1939511430" } Partitioned on composite id for scale out Low latency (<10 ms) queries Player data – nickname, high scores, alternative IDs Query by alternative social IDs © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Player data APIs AddPlayer UpdatePlayer GetPlayerJsonById 10/12/2018 11:23 PM Player data APIs AddPlayer UpdatePlayer GetPlayerJsonById GetPlayerJsonByHashedId GetPlayerDataSubsetByHashedIds GetPlayerDataByFacebookId GetPlayerDataByGamecenterId GetPlayerDataByGoogleId { "id": "G02-D06-5d085b11", "CountryCode": "hk", "Nickname": "DannyBoy", "NicknameLower": "dannyboy", "Score": 0, "SecondaryScore": 18, "IndexScore": 0.18, "Level": 1, "HashedId": "b134bd5c5b5748f", "LastSaveUnixTime": 1446591499, "LastLoadUnixTime": 1446590552, "DisconnectedUnixTime": 1446591499, "FacebookId": "FB_1010006092353214", "GameCenterId": "GC_G:1939511430" } © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Guild APIs for social GetGuildJsonById GetGuildMembersById 10/12/2018 11:23 PM Guild APIs for social { "id":"67879d8e", "GuildMembers": [ { "MemberId": "75c14f1d", "Name": "RickGrimes", "PlayerLevel": 7, "Role": "Leader", "State": "Normal", "CurrentChallengeStars": 0, "TotalChallengeStars": 5 }], "GuildMembersPending": [ ], "ChatMessages": [ { "PlayerId": "67879d8e", "Name": "lee", "Message": "hi", "Time": 760455049, "NotificationType": "None" }] } GetGuildJsonById GetGuildMembersById AddGuildMember AddPendingGuildMember AddChatMessage © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Data partitioning and re-partitioning 10/12/2018 11:23 PM Data partitioning and re-partitioning Distributing throughput over partitions Data spread with consistent hashing HashFn(N) HashFn(N+1) HashFn(N) HashFn(N+1) © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

There isn’t always time for partition management 10/12/2018 11:23 PM There isn’t always time for partition management © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Partitioned collections 10/12/2018 11:23 PM Partitioned collections Scale throughput (RUs) and storage independently Scale beyond current single partition collection limits Adjust reserved throughput based on application requirements © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Creating partitioned collections 10/12/2018 11:23 PM Creating partitioned collections //pre-defined collections DocumentCollection collectionSpec = new DocumentCollection { Id = "Walkers" }; RequestOptions options = new RequestOptions { OfferType = "S3" }; DocumentCollection documentCollection = await client.CreateDocumentCollectionAsync("dbs/" + database.Id, collectionSpec, options); //partitioned collections collectionSpec.PartitionKey.Paths.Add(“/walkerId”); int collectionThroughput = 100000; RequestOptions options = new RequestOptions { OfferThroughput = collectionThroughput }; © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

DocumentDB global databases (Preview) 10/12/2018 11:23 PM DocumentDB global databases (Preview) For applications with global reach Replicated, multi-region databases Access data with low latency Develop multi-region apps with well defined consistency levels Dynamically configure write region © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

App defined regional preferences 10/12/2018 11:23 PM App defined regional preferences ConnectionPolicy docClientConnectionPolicy = new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp }; docClientConnectionPolicy.PreferredLocations.Add(LocationNames.EastUS2); docClientConnectionPolicy.PreferredLocations.Add(LocationNames.WestUS); docClient = new DocumentClient( new Uri("https://myglobaldb.documents.azure.com:443"), "PARvqUuBw2QTO4rRXr6d1GnLCR7VinERcYrBQvDRh6EDTJLOHtZxgjTS4pv8nQv2Lg1QQLBLfO6TVziOZKvYow==", docClientConnectionPolicy); © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

One more thing…

A few One more thing… s

Automatic Indexing

Query over schema-free JSON 10/12/2018 Query over schema-free JSON SQL Query Grammar -- Nested lookup against index SELECT Books.Author FROM Books WHERE Books.Author.Name = "Leo Tolstoy" -- Transformation, Filters, Array access SELECT { Name: Books.Title, Author: Books.Author.Name } WHERE Books.Price > 10 AND Books.Languages[0] = "English" -- Joins, User Defined Functions (UDF) SELECT CalculateRegionalTax(Books.Price, "USA", "WA") JOIN LanguagesArr IN Books.Languages WHERE LanguagesArr.Language = "Russian" Query over heterogeneous documents without defining schema or managing indexes Query arbitrary paths, properties and values without specifying secondary indexes or indexing hints Execute queries with consistent results in the face of sustained writes Query through fluent language integration including LINQ for .NET developers and a “document oriented“ SQL grammar for traditional SQL developers Extend query execution through application supplied JavaScript UDFs Supported SQL features include; predicates, iterations (arrays), sub-queries, logical operators, UDFs, intra-document JOINs, JSON transforms © 2015 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Indexing Example How it works 10/12/2018 Indexing How it works Automatic indexing of documents JSON documents are represented as trees Structural information and instance values are normalized into a JSON-Path Fixed upper bound on index size (typically 20% in real production data) Example {"headquarters": "Belgium"}  /"headquarters"/"Belgium" {"exports": [{"city": “Moscow"}, {"city": Athens"}]}  /"exports"/0/"city"/"Moscow" and /"exports"/1/"city"/"Athens". © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Indexing Policies Configuration Level Options Automatic Per collection 10/12/2018 Indexing Policies Configuration Level Options Automatic Per collection True (default) or False Override with each document write Indexing Mode Consistent or Lazy Lazy for eventual updates/bulk ingestion Included and excluded paths Per path Individual path or recursive includes (? And *) Indexing Type Support Hash and Range Hash for equality, range for range queries Indexing Precision Supports 3 – 7 per path Tradeoff storage, query RUs and write RUs © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Indexing Paths Path Description/use case / 10/12/2018 Indexing Paths Path Description/use case / Default path for collection. Recursive and applies to whole document tree. /"prop"/? Serve queries like the following (with Hash or Range types respectively): SELECT * FROM collection c WHERE c.prop = "value" SELCT * FROM collection c WHERE c.prop > 5 /"prop"/* All paths under the specified label. /"prop"/"subprop"/ Used during query execution to prune documents that do not have the specified path. /"prop"/"subprop"/? Serve queries (with Hash or Range types respectively): SELECT * FROM collection c WHERE c.prop.subprop = "value" SELECT * FROM collection c WHERE c.prop.subprop > 5 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Tunable Consistency

Tunable Consistency Levels 10/12/2018 11:23 PM Tunable Consistency Levels Brewer’s CAP Theorem Consistency In theoretical computer science, the CAP theorem, also known as Brewer's theorem, states that it is impossible for a distributed computer system to simultaneously provide all three of the following guarantees:[1][2][3] Consistency (all nodes see the same data at the same time) Availability (a guarantee that every request receives a response about whether it succeeded or failed) Partition tolerance (the system continues to operate despite arbitrary message loss or failure of part of the system) Availability Partition Tolerance © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Tunable Consistency Levels 10/12/2018 11:23 PM Tunable Consistency Levels Brewer’s CAP Theorem DocumentDB offers 4 consistency levels Consistency Strong: guarantees that a write is only visible after it is committed durably by the majority quorum of replicas and reads are always acknowledged by the majority read quorum Session: Provides predictable read consistency for a session while offering the low latency writes. Reads are also low latency as it read will be served by a single replica Bounded Staleness: Bounded Staleness consistency guarantees the total order of propagation of writes but reads may lag writes by N seconds or operations (configurable) Eventual: Eventual consistency is the weakest form of consistency wherein a client may get the values which are older than the ones it had seen before, over time Image licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license: http://commons.wikimedia.org/wiki/File:Fale_F1_Monza_2004_73.jpg Availability Partition Tolerance © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Transaction Integrated JavaScript

Transactional Integrated JavaScript 10/12/2018 Transactional Integrated JavaScript Stored Procedures and Triggers Familiar programming model constructs for executing application logic Registered as named, URI addressable, durable resources Scoped to a DocumentDB collection JavaScript as a procedural language to express business logic Language integration JavaScript throw statement results into aborting the transaction Execution JavaScript runtime is hosted on each replica Pre-compiled on registration The entire procedure is wrapped in an implicit database transaction Fully resource governed and sandboxed execution © 2015 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Transactional Integrated JavaScript 10/12/2018 Transactional Integrated JavaScript Stored Procedures and Triggers Familiar programming model constructs for executing application logic Registered as named, URI addressable, durable resources Scoped to a DocumentDB collection JavaScript as a procedural language to express business logic Language integration JavaScript throw statement results into aborting the transaction Execution JavaScript runtime is hosted on each replica Pre-compiled on registration The entire procedure is wrapped in an implicit database transaction Fully resource governed and sandboxed execution © 2015 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Transactional Integrated JavaScript 10/12/2018 Transactional Integrated JavaScript client.executeStoredProcedureAsync ("procs/1234", ["MasterChief", "SolidSnake“])  .then(function (response) {     console.log(“success!");   }, function (err) {    console.log("Failed to swap!", error);  } ); function(playerId1, playerId2) {     var playersToSwap = __.filter (function (document) {         return (document.id == playerId1 || document.id == playerId2);     });     var player1 = playersToSwap[0], player2 = playersToSwap[1];       var player1ItemTemp = player1.item;     player1.item = player2.item;     player2.item = player1ItemTemp;     __.replaceDocument(player1)         .then(function() { return __.replaceDocument(player2); })         .fail(function(error){ throw 'Unable to update players, abort'; }); } Stored Procedures and Triggers Familiar programming model constructs for executing application logic Registered as named, URI addressable, durable resources Scoped to a DocumentDB collection JavaScript as a procedural language to express business logic Language integration JavaScript throw statement results into aborting the transaction Execution JavaScript runtime is hosted on each replica Pre-compiled on registration The entire procedure is wrapped in an implicit database transaction Fully resource governed and sandboxed execution Client Database © 2015 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Quick Tips

Quick Tips De-normalize where appropriate (see other session) 10/12/2018 Quick Tips De-normalize where appropriate (see other session) Collections != Tables General Use a single instance of the DocumentDB client instance Handle server throttles/request rate too large (HTTP Status Code 429) Use point-reads for lookup by id Pre-aggregate where possible Use TTL for expiring data (new) © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Quick Tips Networking .NET SDK usage Non-JSON Data Types 10/12/2018 Quick Tips Networking Use direct connectivity and TCP for performance Collocate clients in same Azure region Debug with HTTPS/Fiddler .NET SDK usage Call OpenAsync() to prevent first call latency Debug: ToString() for LINQ to SQL query translation Non-JSON Data Types DateTimes – use epochs or split up in to year, month, day, etc. Geo-Spatial Indexing via GeoJSON © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Thank You Get started with Azure DocumentDB http://www.documentdb.com Query Demo: https://www.documentdb.com/sql/demo { "name": "Andrew Liu", "e-mail": "andrl@microsoft.com", "twitter": "@aliuy8" }