Josh Carlisle
@joshcarlisle
Introduction to Azure’s CosmosDB
#CosmosDB #Serverless #Azure
Who Am I
• Raleigh North Carolina
• Developer x 20 years
• Twitter: @joshcarlisle
• Web: www.joshcarlisle.io
• Github: https://github.com/joshdcar
• Email: joshc@viewfusion.com
Azure Cosmos DB
No SQL Cloud Managed Database (think MongoDB, Cassandra, CouchDB)
Turnkey Global Distribution
Multiple Models
High Availability (up to 99.999%)
Very Low Latency Reads (median 2ms, SLA 10ms*)
Very Low Latency Writes (median 6ms, SLA 15ms*)
Configurable Throughput (how many readswrites per second) (RUs)
* same region @joshcarlisle
CosmosDB  No SQL– Another Tool in the Toolkit
Pros:
• Semi-Structured Data (JSON)
• Flexible Schema
• Reduced Impedance Mismatch
• Supports VERY large data stores
• Very Fast (No Joins)
• High concurrency
• Scales very well
• Auto Indexing
Cons:
• Not relational
• Denormalized Data (duplicate)
• Less Transaction Support (same partition)
• No “referential integrity” and constraints
• Limited SQL Support
• No Schema Enforcements
• Different Paradigm Shift
• Not as mature
@joshcarlisle
Turnkey Global Distribution
• Master Write Region OR
multiple write regions
• Change Write region
dynamically “Follow the Clock”
• Designate Failover Regions
• Transparent to Applications
(API manages “closest” region)
• Various Consistency Options
@joshcarlisle
CosmosDB Consistency Models
Strong Consistency Eventual Consistency
Latency
Strong Bounded-
staleness
Session Consistent
Prefix
Eventual
https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels
@joshcarlisle
Multiple Models
mongoDB
SQL
Table API
Azure Cosmos DB
@joshcarlisle
Request Units
• An abstraction of Memory, CPU, and IOPS
• Used to reserve throughput to ensure SLA
• 1 RU = 1 read of 1KB Document
• Applies to activities (reads, writes, queries, stored procedures)
• Background processes (TTL, Indexing) scheduled during low RU utilization.
• Requests > RUs = Throttling (rate-limiting)
• SDK handles auto-retry on rate limit responses
• Can be adjusted dynamically through the CosmosDB API
@joshcarlisle
Practical Guidance - Modeling
• Self Contained Entities
• Accept Denormalization
• Consider Partition Key Carefully
@joshcarlisle
Practical Guidance – Modeling (cont)
• Careful about unbounded collections in model (One to Few = good , One to Many = bad)
• Use reference to other related entities
@joshcarlisle
.Net Development with CosmosDB & SQL Model
• Local CosmosDB Emulator Available
• Nuget Packages for .Net Framework and Core (in addition to other languages)
• SQL Query Syntax andor Linq Query Support
• Use the SDK vs REST – it provides built in capabilities such as automatic retry when throttled.
@joshcarlisle
Azure Search + CosmosDB = Awesome!
If you have heavy search requirements or you are find that you
are struggling with performance or modeling impact of search
consider using Azure Search.
 Azure Search has a native CosmosDB search indexer
 Supports SQL API Only (MongoDB in Preview)
 Transform your data for optimizations (e.g. flatten)
Missing Features
• Tools are always improving but feel limited in comparison to relational tools such as SQL
Management Studio and official tools are generally portal based.
• Group By and Distinct Aggregation Still Missing (Coming). Currently supports Count, Sum, Min,
Max, Avg) and then only one at a time.
• Limited Order By (Properties not derived values)
• No Partial Updates (Coming)
• No Batch Operation Support (stored procedure work arounds)
• AutoScale Reserved Units Throughput (RUs) (Planned)
• More granular billing options (currently RU at the container level)
@joshcarlisle
Additional Resources
• Source Code: https://github.com/joshdcar
• Twitter: @joshcarlisle
• Blog : http://www.joshcarlisle.io
• Twitter Users to follow:
 @AzureCosmsosDB
 @crandycodes
 @rimmanehme
• Tools
 Storage Explorer - https://azure.microsoft.com/en-us/features/storage-explorer/
@joshcarlisle

Introduction to CosmosDB - Azure Bootcamp 2018

  • 1.
    Josh Carlisle @joshcarlisle Introduction toAzure’s CosmosDB #CosmosDB #Serverless #Azure
  • 2.
    Who Am I •Raleigh North Carolina • Developer x 20 years • Twitter: @joshcarlisle • Web: www.joshcarlisle.io • Github: https://github.com/joshdcar • Email: joshc@viewfusion.com
  • 3.
    Azure Cosmos DB NoSQL Cloud Managed Database (think MongoDB, Cassandra, CouchDB) Turnkey Global Distribution Multiple Models High Availability (up to 99.999%) Very Low Latency Reads (median 2ms, SLA 10ms*) Very Low Latency Writes (median 6ms, SLA 15ms*) Configurable Throughput (how many readswrites per second) (RUs) * same region @joshcarlisle
  • 4.
    CosmosDB NoSQL– Another Tool in the Toolkit Pros: • Semi-Structured Data (JSON) • Flexible Schema • Reduced Impedance Mismatch • Supports VERY large data stores • Very Fast (No Joins) • High concurrency • Scales very well • Auto Indexing Cons: • Not relational • Denormalized Data (duplicate) • Less Transaction Support (same partition) • No “referential integrity” and constraints • Limited SQL Support • No Schema Enforcements • Different Paradigm Shift • Not as mature @joshcarlisle
  • 5.
    Turnkey Global Distribution •Master Write Region OR multiple write regions • Change Write region dynamically “Follow the Clock” • Designate Failover Regions • Transparent to Applications (API manages “closest” region) • Various Consistency Options @joshcarlisle
  • 6.
    CosmosDB Consistency Models StrongConsistency Eventual Consistency Latency Strong Bounded- staleness Session Consistent Prefix Eventual https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels @joshcarlisle
  • 7.
  • 8.
    Request Units • Anabstraction of Memory, CPU, and IOPS • Used to reserve throughput to ensure SLA • 1 RU = 1 read of 1KB Document • Applies to activities (reads, writes, queries, stored procedures) • Background processes (TTL, Indexing) scheduled during low RU utilization. • Requests > RUs = Throttling (rate-limiting) • SDK handles auto-retry on rate limit responses • Can be adjusted dynamically through the CosmosDB API @joshcarlisle
  • 9.
    Practical Guidance -Modeling • Self Contained Entities • Accept Denormalization • Consider Partition Key Carefully @joshcarlisle
  • 10.
    Practical Guidance –Modeling (cont) • Careful about unbounded collections in model (One to Few = good , One to Many = bad) • Use reference to other related entities @joshcarlisle
  • 11.
    .Net Development withCosmosDB & SQL Model • Local CosmosDB Emulator Available • Nuget Packages for .Net Framework and Core (in addition to other languages) • SQL Query Syntax andor Linq Query Support • Use the SDK vs REST – it provides built in capabilities such as automatic retry when throttled. @joshcarlisle
  • 12.
    Azure Search +CosmosDB = Awesome! If you have heavy search requirements or you are find that you are struggling with performance or modeling impact of search consider using Azure Search.  Azure Search has a native CosmosDB search indexer  Supports SQL API Only (MongoDB in Preview)  Transform your data for optimizations (e.g. flatten)
  • 13.
    Missing Features • Toolsare always improving but feel limited in comparison to relational tools such as SQL Management Studio and official tools are generally portal based. • Group By and Distinct Aggregation Still Missing (Coming). Currently supports Count, Sum, Min, Max, Avg) and then only one at a time. • Limited Order By (Properties not derived values) • No Partial Updates (Coming) • No Batch Operation Support (stored procedure work arounds) • AutoScale Reserved Units Throughput (RUs) (Planned) • More granular billing options (currently RU at the container level) @joshcarlisle
  • 14.
    Additional Resources • SourceCode: https://github.com/joshdcar • Twitter: @joshcarlisle • Blog : http://www.joshcarlisle.io • Twitter Users to follow:  @AzureCosmsosDB  @crandycodes  @rimmanehme • Tools  Storage Explorer - https://azure.microsoft.com/en-us/features/storage-explorer/ @joshcarlisle