Josh Carlisle introduces Azure Cosmos DB, a globally distributed, multi-model database service. Cosmos DB offers turnkey global distribution, high availability up to 99.999%, and low latency reads and writes typically under 10ms. It uses request units to reserve throughput and ensure service level agreements. Cosmos DB supports multiple APIs including MongoDB, SQL, Cassandra, and table storage and scales elastically.
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
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
4. 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
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
8. 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
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 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
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
• 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