Slides for my talk which overviews new(ish) product of Microsoft - multi-model, cloud database known as CosmosDB.
Recorded talk (in Polish) is available here: https://youtu.be/ZWpJne0kcds?t=1h52m45s
7. Agenda
Cosmos DB origin and (very brief) story
Why Cosmos DB
Available data models
Consistency levels
Scaling, Pricing and Georeplication
Service Level Agreements
Getting started (for free)
8. Glossary - ACID
A – Atomicity
C – Consistency
I – Isolation
D - Durability
9. Glossary – CAP Theorem
C – Consistency
A – Availability
P – Partition Tolerant
27. Database tools we all love
Stored Procedures
Triggers
User Defined Functions (can be used in SQL syntax)
All in JavaScript
28. Four models, Four APIs
Document Database with Document DB SQL(like) API
Document Database with Mongo DB API
Key-Value Database with Azure Table Storage API
Graph database with (Tinkerpop) Gremlin API
31. Document DB – query sample
SELECT * FROM Collection c
SELECT * FROM Collection c WHERE c.gender = 'female’
SELECT c["firstName"] AS FirstName, c["lastName"] AS
LastName FROM Collection c
SELECT {"FirstName" : c.firstName, "LastName": c.lastName}
AS PersonalData FROM Collection c
46. Non-Azure Equivalents
Document DB - Mongo DB
Mongo DB – Mongo DB (Captain obvious to the rescue!)
Azure Table Storage – Cassandra, HBase
Graph API - Neo4J, Titan
50. Strong consistency & eventual consistency
Strong Consistency – always reading current data
Eventual Consistency – data will be consistent... eventually
51. There are other consistency levels? Like what?
Somewhat consistent?
52. 5 of them in Cosmos DB
https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels
53. Strong consistency
+ B
A + C
A
ABA ABC
ABC
https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels
54. Strong consistency
You can use only one Azure region with strong consistency
https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels
55. Bounded-staleness
+ B
A + C
A
AA ABC
ABAB
https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels
56. Bounded-staleness
Introduces acceptable lag for time or number of item versions
Data will manage consistent ordering except while in
staleness window
Georeplication to other Azure region is available if staleness
window is more than 100 000 operations or 5 minutes
https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels
57. Session
+ B
A + C
AB
AA AC
AB
https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels
ACB
58. Session
Scoped to a client session
Reading own writes in consistent order in own session
Better throughput and latency than strong and bounded
staleness consistency levels while managing great session-
scoped consistency
https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels
59. Consistent prefix
+ B
A + C
AB
ABCA ABC
ABCD
https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels
AB
+ D
60. Consistent prefix
Data may not be consistent, but will always be readed in
updates order
https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels
61. Eventual consistency
+ B
A + C
AD
ACA AC
ABD
https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels
AB
+ D
ABCD
62. Eventual consistency
Cheapest writes
Best in terms of latency and throughput
You can read data older than you’ve seen just a second ago
But data will be consinstent...eventually
https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels
63. Consistency can be changed per request
Just add x-ms-consistency-level header to your request
Or look for this option in your SDK
65. Request Units
Every request costs certain amount of Request Units
It depends on consistency and request itself
You’re paying for provisioning n RU per second
Request Unit is throughput metric
66. How much is request unit
~1kb read – 1RU
~1kb query by id – 2,5 RU
~1kb create – 15RU
67. ~1kb worth of JSON data
{"id": "59b413f6112b5af91a117944",
"guid": "cf9aa26f-f863-4adf-b6bd-
f4419427219c",
"isActive": false,
"balance": "$1,053.74",
"picture": "http://placehold.it/32x32.jpg",
"age": 32,
"eyeColor": "blue",
"name": "Lynette Campos",
"gender": "female",
"company": "XURBAN",
"email": "lynettecampos@xurban.com",
"secondaryEmail":"lynettecampos@seconda
ry.com"
"phone": "+1 (826) 428-2753",
"address": "511 Rodney Street, Libertytown,
Guam, 5768",
"about": "Sit sunt est Lorem dolore id
magna. Irure non proident culpa dolor enim.
Ex veniam laborum consectetur pariatur
mollit elit non commodo incididunt Lorem
labore. Qui labore ut excepteur id laboris
adipisicing ullamco et nulla irure nostrud
exercitation adipisicing excepteur.
Commodo duis incididunt ea in anim veniam
eiusmod deserunt. In incididunt duis
laborum in.rn",
"registered": "2015-12-15T08:48:18 -01:00",
"tags":
["lorem","ipsum","dolor","nisi","magna","cul
pa","pariatur","tempor"],
"favoriteFruit": "banana",
"favouriteProgrammingLanguage":"C#"}
69. How much does it cost?
100 RU/s – ~5,02 EUR monthly
1 GB of storage (SSD) - ~0.21 EUR monthly
Minimum 400RU/s (~20.08 EUR monthly)
Each replica multiples the amount!
73. What’s the limit
Minimum request units that can be provisioned is 400RU/s
After 2500 RU/s – partition key is required
After 10000 RU/s – you need to contact support
80. SLA
SLA – Service Level Agreement
Service Credit - Service Fee * Service Credit Percent
https://azure.microsoft.com/en-us/support/legal/sla/cosmos-db/v1_0/
81. Availability SLA
SLA for failed requests percent
99,99% Availability or 10% Service Credit
99% Availability or 25% Service Credit
https://azure.microsoft.com/en-us/support/legal/sla/cosmos-db/v1_0/
82. Throughput SLA
You will be available to use RU/s that you’ve provisioned
99,99% Throughput or 10% Service Credit
99% Throughput or 25% Service Credit
https://azure.microsoft.com/en-us/support/legal/sla/cosmos-db/v1_0/
83. Consistency SLA
Your reads and writes will be executed within chosen
consistency level
99,99% Consistency Attainment or 10% Service Credit
99% Consistency Attainment or 25% Service Credit
https://azure.microsoft.com/en-us/support/legal/sla/cosmos-db/v1_0/
84. Latency SLA
Guarantees 10ms latency for reading up to 1kb document in
same region
Guarantees 15ms latency for writing up to 1kb document in
same region
99,99% Latency Attainment or 10% Service Credit
99% Latency Attainment or 25% Service Credit
https://azure.microsoft.com/en-us/support/legal/sla/cosmos-db/v1_0/