The event, held on 27th April 2019, was part of the Global Azure Bootcamp and covered Microsoft's Cosmos DB, more specifically:
- Introduction to Cosmos DB, its features, internals, resource models, and request units.
- DEMO: Create an SQL API. Download sample .NET app. Simple queries.
- Covered Change Feed and showcased various use case scenarios.
- Detailed Global Distribution and Consistency Models implications.
- DEMO: Mongo - Lift and shift. Run simple .NET code against a MongoDB (in docker container) and cosmos.
- Introduction to Tinkerpop graphs
- DEMO: Graphs API. Download sample .NET app. Simple queries.
https://techspark.mt/global-azure-bootcamp-27th-april-2019/
3. Agenda: Exploring Cosmos DB
What is it?
Internals
Resource Model
Try it out!
DEMO: Create an SQL API & Download sample .NET app
Change Feed
Global Distribution
Use Cases
Consistency Models
Request Units
DEMO: Mongo - Lift and shift
Tinkerpop graphs
DEMO: Graphs
4.
5. 2010 2014 2015 2017
DocumentDB Cosmos DBProject Florence
• Originally started to address
the problems faced by large
scale apps inside Microsoft
• Built from the ground up for
the cloud
• Used extensively inside
Microsoft
• One of the fastest growing
services on Azure
Azure Cosmos DB
6. Turnkey global distribution
Elastic scale out
of storage & throughput
Guaranteed low latency at the 99th percentile
Comprehensive SLAs
Five well-defined consistency models
A globally distributed, massively scalable, multi-model database service
Azure Cosmos DB
7. Turnkey global distribution
Elastic scale out
of storage & throughput
Guaranteed low latency at the 99th percentile
Comprehensive SLAs
Five well-defined consistency models
A globally distributed, massively scalable, multi-model database service
Azure Cosmos DB
Column-family Document
Graph
Key-value
8. Column-family Document
Graph
Turnkey global distribution
Elastic scale out
of storage & throughput
Guaranteed low latency at the 99th percentile
Comprehensive SLAs
Five well-defined consistency models
Table API
Key-value
A globally distributed, massively scalable, multi-model database service
Cosmos DB’s API for
MongoDB
Azure Cosmos DB
9. Your application
Database
client
library
Your app
logic
Graph API
MongoDB API
Any other API …
Open-source
driver of choice*
Change of
connection string*
* Depending on feature supportability
Your app
A globally distributed, massively scalable, multi-model database service
Azure Cosmos DB
12. Resource Hierarchy
CONTAINERS
Logical resources “surfaced” to APIs as tables,
collections or graphs, which are made up of one or
more physical partitions or servers.
RESOURCE PARTITIONS
• Consistent, highly available, and resource-governed
coordination primitives
• Consist of replica sets, with each replica hosting an
instance of the database engine
Containers
Resource Partitions
CollectionsTables Graphs
Tenants
Leader
Follower
Follower
Forwarder
Replica Set
To remote resource partition(s)
29. Multi-Master – Read/Write in any region
Benefits
• Write scalability around the world
• Low latency (<10ms P99 for 1kb document)
writes around the world
• 99.999% High Availability around the world
• Well-defined consistency models
• Automatic conflict management
34. Azure IoT Hub
Apache Storm on
Azure HDInsight
Azure Cosmos DB
(telemetry and
device state)
events
Azure Web Jobs
(Change feed
processor)
Azure Function
latest state
Azure Data Lake
(archival)
Internet of Things – Telemetry & Sensor Data
35. Azure Web App
(e-commerce app)
Azure Cosmos DB
(product catalog)
Azure Cosmos DB
(session state)
Azure Search
(full-text index)
Azure Storage
(logs, static
catalog content)
Retail Product Catalogs
37. Azure Cosmos DB
(Low-latency User Profile Store)
Azure API Apps Azure Machine Learning
Azure Data Lake Storage
(Archive of Events)
Azure Cosmos DB
(Event Store)
Azure Web Jobs
(Change feed processor)
Real-time Personalization / Recommendations
38.
39. Consistency Level Guarantees
Strong Linearizability (once operation is complete, it will be visible to all)
Bounded Staleness Consistent Prefix.
Reads lag behind writes by at most k prefixes or t interval
Similar properties to strong consistency (except within staleness window), while preserving 99.99%
availability and low latency.
Session Consistent Prefix.
Within a session: monotonic reads, monotonic writes, read-your-writes, write-follows-reads
Predictable consistency for a session, high read throughput + low latency
Consistent Prefix Reads will never see out of order writes (no gaps).
Eventual Potential for out of order reads. Lowest cost for reads of all consistency levels.
Well-Defined Consistency Models
41. string sessionToken;
using (DocumentClient client = new DocumentClient(new Uri(""), ""))
{
ResourceResponse<Document> response = client.CreateDocumentAsync(
collectionLink,
new { id = "an id", value = "some value" }
).Result;
sessionToken = response.SessionToken;
}
using (DocumentClient client = new DocumentClient(new Uri(""), ""))
{
ResourceResponse<Document> read = client.ReadDocumentAsync(
documentLink,
new RequestOptions { SessionToken = sessionToken }
).Result;
}
Session Consistency: Session is controlled using a “session token”.
• Session tokens are automatically cached by the Client SDK
• Can be pulled out and used to override other requests (to preserve session between multiple clients)
Well-Defined Consistency Models
44. Billing Model
2 components: Storage + Throughput
You are billed on consumed storage and provisioned throughput
Collections in a database can share throughput
Unit Price (for most Azure regions)
SSD Storage (per GB) $0.25 per month
Provisioned Throughput (single region
writes)
$0.008/hour per 100 RU/s
Provisioned Throughput (multi-region
writes)
$0.016/hour per 100 multi-master RU/s
* pricing may vary by region; for up-to-date pricing, see: https://azure.microsoft.com/pricing/details/cosmos-db/
45. Request Units
Request Units (RUs) is a rate-based currency – e.g. 1000 RU/second
Abstracts physical resources for performing requests
% IOPS% CPU% Memory
46. Request Units
Each request consumes # of RU
Approx. 1 RU = 1 read of 1 KB document
Approx. 5 RU = 1 write of a 1KB document
Query: Depends on query & documents involved
GET
POST
PUT
Query
…
=
=
=
=
47. Request Units- Provisioned throughput
Provisioned in terms of RU/sec – e.g. 1000 RU/s
Billed for highest RU/s in 1 hour
Easy to increase and decrease on demand
Rate limiting based on amount of throughput provisioned
Background processes like TTL expiration, index
transformations scheduled when quiescent
Storage: 40RU per 1GB of data
Min RU/sec
Max
RU/sec
IncomingRequests
No rate limiting,
process background
operations
Rate limiting –
SDK retry
No rate limiting
54. Microsoft Confidential
Kobe
Bryant
vertex
label: person
properties:
- age: 39
- height: 6'6”
NBA
Champion
2000
edge
label: isPartOf
edge
label: hasNbaChampionship
Los
Angeles
Lakers
vertex
label: team
properties:
- state: CA
NBA
Champion
2002
NBA
Champion
2001
NBA
Champion
2010
NBA
Champion
2009
vertex
label: award
properties:
- obtained: 2010
vertex
label: award
properties:
- obtained: 2009
vertex
label: award
properties:
- obtained: 2002
vertex
label: award
properties:
- obtained: 2001
vertex
label: award
properties:
- obtained: 2000
55. Microsoft Confidential
Kobe
Bryant
vertex
label: person
properties:
- age: 39
- height: 6'6”
Oscar
2018
NBA
Champion
2000
edge
label: isPartOf
edge
label: hasNbaChampionship
vertex
label: award
properties:
- obtained: 2018
- category: Best Animated
Short Film
Los
Angeles
Lakers
vertex
label: team
properties:
- state: CA
NBA
Champion
2002
NBA
Champion
2001
NBA
Champion
2010
NBA
Champion
2009
vertex
label: award
properties:
- obtained: 2010
vertex
label: award
properties:
- obtained: 2009
vertex
label: award
properties:
- obtained: 2002
vertex
label: award
properties:
- obtained: 2001
vertex
label: award
properties:
- obtained: 2000
edge
label: hasAcademyAward
56. Microsoft Confidential
Kobe
Bryant
vertex
label: person
properties:
- age: 39
- height: 6'6”
Oscar
2018
NBA
Champion
2000
edge
label: isPartOf
edge
label: hasNbaChampionship
vertex
label: award
properties:
- obtained: 2018
- category: Best Animated
Short Film
Los
Angeles
Lakers
vertex
label: team
properties:
- state: CA
NBA
Champion
2002
NBA
Champion
2001
NBA
Champion
2010
NBA
Champion
2009
vertex
label: award
properties:
- obtained: 2010
vertex
label: award
properties:
- obtained: 2009
vertex
label: award
properties:
- obtained: 2002
vertex
label: award
properties:
- obtained: 2001
vertex
label: award
properties:
- obtained: 2000
Tom
Cruise
vertex
label: person
properties:
- awards: null
edge
label: hasAcademyAward
57. Microsoft Confidential
Kobe
Bryant
vertex
label: person
properties:
- age: 39
- height: 6'6”
Oscar
2018
NBA
Champion
2000
edge
label: isPartOf
edge
label: hasNbaChampionship
vertex
label: award
properties:
- obtained: 2018
- category: Best Animated
Short Film
Los
Angeles
Lakers
vertex
label: team
properties:
- state: CA
NBA
Champion
2002
NBA
Champion
2001
NBA
Champion
2010
NBA
Champion
2009
vertex
label: award
properties:
- obtained: 2010
vertex
label: award
properties:
- obtained: 2009
vertex
label: award
properties:
- obtained: 2002
vertex
label: award
properties:
- obtained: 2001
vertex
label: award
properties:
- obtained: 2000
Tom
Cruise
vertex
label: person
properties:
- awards: null
Hollywood
Celebrity
edge
label: hasAcademyAward
vertex
label: status
edge
label: status
edge
label: status
Notas do Editor
Azure Cosmos DB offers the first globally distributed, multi-model database service for building planet scale apps. It’s been powering Microsoft’s internet-scale services for years, and now it’s ready to launch yours.
Only Azure Cosmos DB makes global distribution turn-key.
You can add Azure locations to your database anywhere across the world, at any time, with a single click. Cosmos DB will seamlessly replicate your data and make it highly available.
Cosmos DB allows you to scale throughput and storage elastically, and globally! You only pay for the throughput and storage you need – anywhere in the world, at any time.
Azure Cosmos DB offers the first globally distributed, multi-model database service for building planet scale apps. It’s been powering Microsoft’s internet-scale services for years, and now it’s ready to launch yours.
Only Azure Cosmos DB makes global distribution turn-key.
You can add Azure locations to your database anywhere across the world, at any time, with a single click. Cosmos DB will seamlessly replicate your data and make it highly available.
Cosmos DB allows you to scale throughput and storage elastically, and globally! You only pay for the throughput and storage you need – anywhere in the world, at any time.
Azure Cosmos DB offers the first globally distributed, multi-model database service for building planet scale apps. It’s been powering Microsoft’s internet-scale services for years, and now it’s ready to launch yours.
Only Azure Cosmos DB makes global distribution turn-key.
You can add Azure locations to your database anywhere across the world, at any time, with a single click. Cosmos DB will seamlessly replicate your data and make it highly available.
Cosmos DB allows you to scale throughput and storage elastically, and globally! You only pay for the throughput and storage you need – anywhere in the world, at any time.
11
The number of RU’s each operation consumes depends on many factors which include:
Document size
Number of indexed fields
Type of indexes
Consistency model choice
Not all queries will consume equal numbers of RU’s. Some operations are more computationally complex or require scans through more documents and therefore use more RU’s.