Cosmos DB - Database for Serverless era

Michał Jankowski
Michał JankowskiTeam Leader Senior Software Developer at Objectivity Bespoke Software Specialists | Scrum Master | .net Developer
Cosmos DB
Database for Serverless Era
Michał Jankowski
www.jankowskimichal.pl 2
about
me
2
Michał Jankowski
technical architect / team leader
traveller / photographer
www.jankowskimichal.pl
mail@jankowskimichal.pl
@JankowskiMichal
github.com/MichalJankowskii
aim.
Learn using Cosmos DB in
your Serverless solutions.
Improve performance of your
whole solution.
www.jankowskimichal.pl 4
way
of working
A bit of theory, then a lot of demos and practice.
I would encourage you to work together and exchange
your knowledge.
we should have fun
Steve Jobs, cofounder of Apple
Great things in business are
never done by one person.
They're done by a team of
people.
www.jankowskimichal.pl 6
presentation
agenda
Serverless & Cosmos DB
A short theoretical introduction
to these topics
SQL API
Let's learn how to use the main
feature of this database by
using SQL API
www.jankowskimichal.pl 7
presentation
agenda
Azure Functions
We will learn how Azure
Function can cooperate with
Cosmos DB.
Graph API
At the end, we will work with API
that allows storing data that are
connected with each other by
multiple relations.
www.jankowskimichal.pl 8
short
survey
Have you worked with Azure?
Have you worked with Azure Functions?
Have you worked with Cosmos DB?
serverless
the future compute
www.jankowskimichal.pl 10
serverless
characteristics
server abstraction
There is no server managing
tasks.
productivity
Reduce tasks related to
infrastructure. You can focus
on development activities.
event driven
Function does not work when
there is no event triggering it. It
can also instantly scale up.
focus on features
And then you are able to focus
on business logic of your app.
microbilling
Pay only when there are events.
But think about DDOS on your
wallet.
faster time to market
All items mentioned together
allow you to reduce time to
market.
www.jankowskimichal.pl 11
serverless
in Azure
An event-based serverless compute experience to
accelerate your development. Scale based on demand
and pay only for the resources you consume.
Azure Functions
A single service for managing routing of all events
from any source to any destination. Designed for high
availability, consistent performance and dynamic
scale. Event Grid lets you focus on your app logic
rather than infrastructure.
Event Grid
www.jankowskimichal.pl 12
serverless
in Azure
Provide a way to simplify and implement scalable
integrations and workflows in the cloud. It provides a
visual designer to model and automate your process
as a series of steps known as a workflow.
Logic Apps
Is a service that allows you to create automated
workflows between your favourite applications and
services to synchronize files, get notifications, collect
data, and more.
Flow
www.jankowskimichal.pl 13
serverless
in Azure
Was built from the ground up with global distribution
and horizontal scale at its core. It offers turnkey global
distribution with multi-master support across any
number of Azure regions by transparently scaling and
replicating your data wherever your users are.
Cosmos DB
cosmos db
database for applications
anywhere in the world
www.jankowskimichal.pl 15
DocumentDB
preview
21/08 2014
SQL grammar over schema-free JSON
Tuneable throughput, indexing, consistency
Server-side ACID transactions
microsoft
noSQL database evolution
Internal Microsoft
DocumentDB service
2010 - 2014
Office
OneNote
Xbox
Part of Azure portal
www.jankowskimichal.pl 16
Cosmos DB
…improvements
– May 2016
Partitioned collections
Geo-replication
MongoDB wire protocol support
microsoft
noSQL database evolution
08/04 2015
DocumentDB GA
ORDER BY
String range queries
Geospatial support
Partitioning support by SDK
10/05 2017
www.jankowskimichal.pl 17
azure
cosmos db
limitless elastic scale
around the globe
With Azure Cosmos DB, you pay
only for the throughput and storage
you need. Azure Cosmos DB allows
you to independently and elastically
scale storage and throughput at any
time, anywhere across the globe,
making it a perfect ally for your
serverless applications.
Only Azure Cosmos DB allows you to
use key-value, graph, column-family,
and document data in one service.
Azure Cosmos DB automatically
indexes all data and allows you to use
your favourite API including SQL,
JavaScript, Gremlin, MongoDB,
Apache® Cassandra, and Azure Table
Storage to access your data.
multi-model + multi-API
Easily build globally distributed applications
without the hassle of complex, multiple-
datacenter configurations. Designed as a
globally distributed database system, Azure
Cosmos DB automatically replicates your
data to any number of regions of your choice
for fast, responsive access. Azure Cosmos
DB supports transparent multi-homing and
guarantees 99.999% high availability.
turnkey global distribution
www.jankowskimichal.pl 18
azure
cosmos db
industry-leading,
enterprise-grade SLAs
Rest assured your apps are running
on a "battle-tested" database
service built on world-class
infrastructure. Azure Cosmos DB
gives you enterprise-grade security
and compliance, and is the first and
only service to offer industry-
leading comprehensive SLAs for
99.999% high availability, latency at
the 99th percentile, guaranteed
throughput, and consistency.
Serve read and write requests from
the nearest region while
simultaneously distributing data
across the globe. With its latch-free
and write-optimized database engine,
Azure Cosmos DB guarantees less
than 10-ms latencies on reads and
less than 15-ms latencies on
(indexed) writes at the 99th
percentile.
guaranteed low latency
at 99th percentile
Azure Cosmos DB offers five well-defined
consistency levels—strong, bounded
staleness, consistent-prefix, session, and
eventual—for an intuitive programming
model with low latency and high availability
for your planet-scale app.
multiple, well-defined
consistency choices
who does
use it???
Key benefits
• Cosmos DB supports fast ingestion
of message data from 1:1
communication, group chats
• Cosmos DB enables real-time query
over message and group
conversations, with custom filters
on when user enters/leaves thread
Business need
• Provide search capabilities over
TBs-PBs of Skype and Teams
conversations
• Fast ingestion with multiple writes,
overlay group memberships
• Secure & compliant data storage
with high privacy requirements
Azure Cosmos DB
Azure Cosmos DB
Azure Cosmos DB
USERS
GROUPS
MESSAGES
Skype Ingestion
service
Skype Query
service
44TB
Message data
Skype powers 1M searches per second
over conversation data
6TB
User data
1TB
Group data
Source: Building globally distributed applications with Azure Cosmos DB
Key benefits
• Cosmos DB can scale elastically
without operational overhead of
MongoDB
• Perform fast queries over events
to deliver recommended services,
safety notices to vehicles
• Perform staged migration via
MongoDB APIs
Business need
• Need to ingest massive volumes
of diagnostic data from vehicles
and take
real-time actions as part
of connected car platform
• Management and operations
of database infrastructure to
handle exponential growth
of data
8TB
Vehicle Telemetry
250K
Lexus Cars
Toyota drives connected car push forward
with Azure Cosmos DB
Azure Cosmos DBAzure HDInsight
Storm
Azure Storage
(archival)
Source: Building globally distributed applications with Azure Cosmos DB
Business need
• Handle millions of players on
Day 1 due to popularity of the
TV series
• Match-making of players for
competitive and lag-free
experience
• Provide new content weekly, and
iterate on social functionality
•
Key benefits
• Cosmos DB provides elastic scalability
for millions of users and flexible
schema to support social features
and gameplay
• Global distribution allows for low
latency for players spread worldwide
• Automatic indexing used to build
real-time leaderboards
Performance at massive scale allows
millions to play mobile game
Azure Traffic
Manager
Azure API Aps
(game backend)
Azure CDN
Azure Cosmos DB
Azure Functions
Azure Notification
Hubs (push
notifications)
Azure Storage
(game files)
1M
Peak Active
#1
iOS App Store
1B
Daily Queries
Source: Building globally distributed applications with Azure Cosmos DB
www.jankowskimichal.pl 23
maybe
we should start coding
www.jankowskimichal.pl 24
before
we start
We will be working with
expensive service. Use it wisely.
And after all, please remember
to clean your environment.
www.jankowskimichal.pl 25
prepare
your environment
www.jankowskimichal.pl 26
multiple
APIs
SQL API (json)
MongoDB API (bson)
document
Cassandra API
column-family
Gremlin API
(graph traversal language)
graph
Table API
(potential replacement for
Azure Table Storage)
key-value
demo
1.
www.jankowskimichal.pl 28
this is time
for you
It is time for you to start your journey with this product.
Play with Cosmos DB
jankowskimichal.pl/cosmosdb-list1
3… 2… 1…
lift off!!!!!
www.jankowskimichal.pl 30
data
in Cosmos DB
• denormalized data
• referential integrity NOT enforced
• mixed data in collections
• flexible schema
• SQL-like language as well as JavaScript and
others
Cosmos DB (document db)
• normalised data
• referential integrity enforced by
normalisation and relationships
• uniform data in tables
• schema is set
• SQL
Relational database
www.jankowskimichal.pl 31
document
vs relational database
Cosmos DB (document db) Relational database
www.jankowskimichal.pl 32
whole model
in one record
{
"lastName": "Cartwright",
"parents": [
{ "firstName": "Elvira", "role": "mother", "age": 64 },
{ "firstName": "Randolph", "role": "father", "age": 67 }
],
"children": [
{ "firstName": "Dana", "age": 15, "gender": "female“ },
{ "firstName": "Pat", "age": 13, "gender": "male“, "grade": 7,
"pets": [
{ "name": "Concepcion", "type": "guinea pig“ },
{ "name": "Haleigh", "type": "hamster“ }
]}],
"address": {
"state": "North Dakota",
"city": "West Bretthaven",
"country": "Guinea"
}
}
complex structure
one-to-many relation
different object schema
www.jankowskimichal.pl 33
database
creation
• create new one or use an existing one
• setup performance on database level – throughput
• there is no limit for it, but we need to contact
support when we need more than 1 000 000 RU/s
• we need to confirm higher costs
we can
www.jankowskimichal.pl 34
request units
normalized measure of request processing cost
Item
size
Reads /
second
Writes /
second
Request
units
1 KB 500 100 1,000 RU/s
1 KB 500 500 3,000 RU/s
4 KB 500 100 1,350 RU/s
4 KB 500 500 4,150 RU/s
64 KB 500 100 9,800 RU/s
64 KB 500 500 29,000 RU/s
Table that shows how many request units to provision for items with three different sizes (1 KB, 4 KB, and 64 KB)
and at two different performance levels (500 reads/second + 100 writes/second and 500 reads/second + 500
writes/second). In this example, the data consistency is set to Session, and the indexing policy is set to None.
• combines memory, CPU and IOPS into currency
rate
• each same request will always consume the
same amount of RUs
• each time we will get information about
operation cost
• we are paying for some capacity:
• when it is exhausted our operations will be
replanned
• we can increase or decrease the amount of
throughput instantaneously
• without capacity our service will stop
• cost of write operation is higher than read one
• pricing cost may be different per region
documentdb.com/capacityplanner
www.jankowskimichal.pl 36
collection
creation
option for start direction when we think about
something serious
www.jankowskimichal.pl 37
partition
key
Remember about some limits:
• A physical partition can store a maximum of 10GB of data
• A physical partition can facilitate at most 10,000 RU/s
partition key selection
is the most important
decision
Cosmos DB account
Database
Collections
Physical partition
Logical partition
Logical
partition
Physical
partition
Documents
how it
works?
Smith
Jones
Williams
Taylor
Davies
Brown
Wilson
Thomas
Johnson
Roberts
Evans
Container
Last name as partition key.
physical
partition
logical
partition
Evans logical partition
is growing
Smith
Jones
Williams
Taylor
Davies
Brown
Wilson
Thomas
Johnson
Roberts
Evans
Container
new physical
partition will
be created Smith
Jones
Williams
Taylor
Davies
Brown
Wilson
Thomas
Johnson
Container
Roberts
Evans
it is still
growingSmith
Jones
Williams
Taylor
Davies
Brown
Wilson
Thomas
Johnson
Container
Roberts
Evans
Smith
Jones
Williams
Taylor
Davies
Brown
Wilson
Thomas
Johnson
Container
Roberts London
Manchester
Container
Last name as partition key. Evans family with
city as partition key.
Liverpool
Leeds
Evans family
as separate
container
how to do it right?
• Choosing partition key purely depends on structure
of data.
• It is important to choose a partition key property
that has a number of distinct values.
• An ideal partition key is one that appears
frequently as a filter in your queries and has
sufficient cardinality to ensure your solution is
scalable.
• If chosen partition key doesn't have many distinct
values then all queries will get fired to a single
partition which may slow down performance.
• General:
• Do not be afraid of having too many partition
keys. In most cases, more partition keys mean
more scalability
demo
2.
www.jankowskimichal.pl 45
this is time
for you
1. Familiarise with presented queries.
2. Try to develop queries to a bigger database
Let's do something more serious
jankowskimichal.pl/cosmosdb-list2
demo
3.
what is your opinion?
www.jankowskimichal.pl 48
from
my perspective
quite simple product with some limitations and great potential
we need to change how we are thinking about data and database
can be very expensive when it is wrong designed or used
cosmos db
& serverless
www.jankowskimichal.pl 50
serverless
main benefits
cost
can be more cost-effective than
renting or purchasing a fixed quantity
of servers
operations / scalability
a serverless architecture means that
developers and operators do not need
to spend time setting up and tuning
autoscaling policies or system
productivity
simplifying the task of back-end
software development
www.jankowskimichal.pl 51
the
performance
latency
How fast is the response on
provided request?
throughput
How many requests can be
handled in a provided
period?
www.jankowskimichal.pl 52
know
the limits
The speed of light in vacuum is a universal physical constant important in many areas of
physics. Its exact value is 299,792,458 metres per second. The speed at which light propagates
through transparent materials, such as glass or air, is less than c.
www.jankowskimichal.pl 53
what does it mean
for us?
~ 200ms
~ 5ms
geo replication.
• it has never been so easy
• you can replicate your
data to as many data
centers as you need
• you can do it with just a
few clicks
www.jankowskimichal.pl 55
data
consistency
sessionbounded
staleness
consistent
prefix
strong eventual
• lower latency
• higher availability
• better read scalability
www.jankowskimichal.pl 56
bounded
staleness
Bounded staleness consistency guarantees that
the reads may lag behind writes by at most K
versions or prefixes of an item or t time-interval.
The cost of a read operation (in terms of RUs
consumed) with bounded staleness is higher than
session and eventual consistency, but the same as
strong consistency.
www.jankowskimichal.pl 57
session
Session consistency is ideal for all scenarios
where a device or user session is involved since it
guarantees monotonic reads, monotonic writes,
and read your own writes (RYW) guarantees.
Session consistency provides predictable
consistency for a session, and maximum read
throughput while offering the lowest latency writes
and reads.
www.jankowskimichal.pl 58
consistent
prefix
Consistent prefix guarantees that in absence of
any further writes, the replicas within the group
eventually converge.
Consistent prefix guarantees that reads never
see out of order writes. If writes were performed
in the order A, B, C, then a client sees either A or
A,B, or A,B,C, but never out of order like A,C or
B,A,C.
www.jankowskimichal.pl 59
eventual
Eventual consistency guarantees that in
absence of any further writes, the replicas
within the group eventually converge.
It is the weakest form of consistency a client
may get the values that are older than the ones
it had seen before.
Provides the weakest read consistency but
offers the lowest latency for both reads and
writes with the lowest cost of a read operation.
prefer
bounded staleness20%
Azure Cosmos DB tenants use
session consistency73%
experiment with various consistency
levels initially before settling on
a specific consistency
3%
www.jankowskimichal.pl 61
read – nothing to do
In the rare event of an Azure regional outage or data center
outage, Cosmos DB automatically triggers failovers of all Cosmos
DB accounts with a presence in the affected region.
write – automatic failover must be on
If the affected region is the current write region and automatic
failover is enabled for the Azure Cosmos DB account, then the
region is automatically marked as offline. Then, an alternative
region is promoted as the write region for the affected Azure
Cosmos DB account.
* manual failover
Can be used as follow the clock model.
regional
failover
www.jankowskimichal.pl 62
data
index
customisations
scope - include or exclude documents and paths to and from the
index
index types
- hash - supports efficient equality and JOIN queries
- range - supports efficient equality queries, range queries (using
>, <, >=, <=, !=), and ORDER BY queries
- spatial - supports efficient spatial (within and distance) queries
precision - make trade-offs between index storage overhead and
query performance
index update mode - consistent, lazy, and none
indexing everything by default
azure
functions.
By definition, synergy happens
when the interaction between
two elements produces an effect
greater than the individual
elements’ contribution.
demo
4.
www.jankowskimichal.pl 65
this is time
for you
1. Create a function that allows adding new ToDo
items to the database
2. Create a function that will list all ToDo items
assigned to list
Let’s build API for the application
jankowskimichal.pl/cosmosdb-list3
graph
api
www.jankowskimichal.pl 67
main
features
many-to-many
complex relations
typical usage of this type
of API
social networks
analyse interconnected
data and relationships
excessive JOINs
recommendation engines
knowledge graphs
denote discrete objects, such as a person, a place, or an event
Id: DEN
Label: airport
Properties:
• Code: DEN
• City: Denver
• Description: Denver International Airport
• Elevation: 5443
verticle
denote relationships between vertices
Id
Label: route
Properties:
• Distance: 542
edge
www.jankowskimichal.pl 69
sample
graph
label: route
properties:
• distance: 2249
id: United States
label: country
properties:
• code: US
• name: United States
label: contains
label: contains
id: DEN
label: airport
properties:
• code: DEN
• city: Denver
• elevation: 5443
id: ATL
label: airport
properties:
• code: ATL
• city: Atlanta
• elevation: 1026
demo
5.
www.jankowskimichal.pl 71
this is time
for you
1. Get all the details about your favourite airport.
2. Check how you can get to your vacation location.
Maybe you should plan your holidays
jankowskimichal.pl/cosmosdb-list4
summary.
We made a brief introduction
to serverless and its'
connections to Cosmos DB.
We learned how to use SQL
API and connect Cosmos DB
with Azure Functions.
You should know how you
can make optimisation of
your environment.
We tried graph API.
www.jankowskimichal.pl 73
do you have any
questions?
www.jankowskimichal.pl
@JankowskiMichal
mail@jankowskimichal.pl
github.com/MichalJankowskii
www.jankowskimichal.pl 74
more
information
• https://azure.microsoft.com/en-us/services/
cosmos-db/
• https://docs.microsoft.com/en-us/azure/cosmos-
db/
• https://docs.microsoft.com/en-us/azure/cosmos-
db/sql-api-introduction
• https://docs.microsoft.com/en-us/azure/azure-
functions/
• https://docs.microsoft.com/en-us/azure/cosmos-
db/serverless-computing-database
• https://docs.microsoft.com/en-us/azure/cosmos-
db/graph-introduction
www.jankowskimichal.pl 75
thank
you
www.jankowskimichal.pl
@JankowskiMichal
mail@jankowskimichal.pl
github.com/MichalJankowskii
1 of 75

Recommended

Zero to 60 with Azure Cosmos DB by
Zero to 60 with Azure Cosmos DBZero to 60 with Azure Cosmos DB
Zero to 60 with Azure Cosmos DBAdnan Hashmi
961 views95 slides
Cost Savings at High Performance with Redis Labs and AWS by
Cost Savings at High Performance with Redis Labs and AWSCost Savings at High Performance with Redis Labs and AWS
Cost Savings at High Performance with Redis Labs and AWSAmazon Web Services
1.8K views33 slides
Getting started with amazon aurora - Toronto by
Getting started with amazon aurora - TorontoGetting started with amazon aurora - Toronto
Getting started with amazon aurora - TorontoAmazon Web Services
4.8K views37 slides
AWS Webcast - Website Hosting in the Cloud by
AWS Webcast - Website Hosting in the CloudAWS Webcast - Website Hosting in the Cloud
AWS Webcast - Website Hosting in the CloudAmazon Web Services
2.3K views28 slides
Create cloud service on AWS by
Create cloud service on AWSCreate cloud service on AWS
Create cloud service on AWSAmazon Web Services
3.8K views58 slides
Getting Started with Amazon EC2 and AWS Compute Services by
Getting Started with Amazon EC2 and AWS Compute ServicesGetting Started with Amazon EC2 and AWS Compute Services
Getting Started with Amazon EC2 and AWS Compute ServicesAmazon Web Services
1.9K views59 slides

More Related Content

What's hot

Getting Started with Amazon Aurora by
Getting Started with Amazon AuroraGetting Started with Amazon Aurora
Getting Started with Amazon AuroraAmazon Web Services
955 views79 slides
Introduction to azure cosmos db by
Introduction to azure cosmos dbIntroduction to azure cosmos db
Introduction to azure cosmos dbRatan Parai
1.4K views26 slides
SRV406 How to Step Off the PC Refresh Treadmill with Amazon WorkSpaces by
SRV406 How to Step Off the PC Refresh Treadmill with Amazon WorkSpacesSRV406 How to Step Off the PC Refresh Treadmill with Amazon WorkSpaces
SRV406 How to Step Off the PC Refresh Treadmill with Amazon WorkSpacesAmazon Web Services
285 views25 slides
Gaming in the Cloud - Pop-up Loft Tel Aviv by
Gaming in the Cloud - Pop-up Loft Tel AvivGaming in the Cloud - Pop-up Loft Tel Aviv
Gaming in the Cloud - Pop-up Loft Tel AvivAmazon Web Services
896 views26 slides
Deep Dive on Amazon DynamoDB by
Deep Dive on Amazon DynamoDBDeep Dive on Amazon DynamoDB
Deep Dive on Amazon DynamoDBAmazon Web Services
3.5K views74 slides
Gaming on AWS - 3. DynamoDB 모델링 및 Streams 활용법 by
Gaming on AWS - 3. DynamoDB 모델링 및 Streams 활용법Gaming on AWS - 3. DynamoDB 모델링 및 Streams 활용법
Gaming on AWS - 3. DynamoDB 모델링 및 Streams 활용법Amazon Web Services Korea
1.7K views28 slides

What's hot(20)

Introduction to azure cosmos db by Ratan Parai
Introduction to azure cosmos dbIntroduction to azure cosmos db
Introduction to azure cosmos db
Ratan Parai1.4K views
SRV406 How to Step Off the PC Refresh Treadmill with Amazon WorkSpaces by Amazon Web Services
SRV406 How to Step Off the PC Refresh Treadmill with Amazon WorkSpacesSRV406 How to Step Off the PC Refresh Treadmill with Amazon WorkSpaces
SRV406 How to Step Off the PC Refresh Treadmill with Amazon WorkSpaces
클라우드 기반 데이터 분석 및 인공 지능을 위한 비지니스 혁신 - 윤석찬 (AWS 테크에반젤리스트) by Amazon Web Services Korea
클라우드 기반 데이터 분석 및 인공 지능을 위한 비지니스 혁신 - 윤석찬 (AWS 테크에반젤리스트)클라우드 기반 데이터 분석 및 인공 지능을 위한 비지니스 혁신 - 윤석찬 (AWS 테크에반젤리스트)
클라우드 기반 데이터 분석 및 인공 지능을 위한 비지니스 혁신 - 윤석찬 (AWS 테크에반젤리스트)
Streaming Data Analytics with Amazon Kinesis Firehose and Redshift by Amazon Web Services
Streaming Data Analytics with Amazon Kinesis Firehose and RedshiftStreaming Data Analytics with Amazon Kinesis Firehose and Redshift
Streaming Data Analytics with Amazon Kinesis Firehose and Redshift
Amazon Web Services1.5K views
Cloud Computing With Amazon Web Services, Part 3: Servers on Demand With EC2 by white paper
Cloud Computing With Amazon Web Services, Part 3: Servers on Demand With EC2Cloud Computing With Amazon Web Services, Part 3: Servers on Demand With EC2
Cloud Computing With Amazon Web Services, Part 3: Servers on Demand With EC2
white paper680 views
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks by Amazon Web Services
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksDeep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Amazon Web Services2.9K views
Building Analytic Apps for SaaS: “Analytics as a Service” by Amazon Web Services
Building Analytic Apps for SaaS: “Analytics as a Service”Building Analytic Apps for SaaS: “Analytics as a Service”
Building Analytic Apps for SaaS: “Analytics as a Service”
AWS re:Invent 2016: Turbocharge Your Microsoft .NET Developments with AWS (DE... by Amazon Web Services
AWS re:Invent 2016: Turbocharge Your Microsoft .NET Developments with AWS (DE...AWS re:Invent 2016: Turbocharge Your Microsoft .NET Developments with AWS (DE...
AWS re:Invent 2016: Turbocharge Your Microsoft .NET Developments with AWS (DE...
Optimize MySQL Workloads with Amazon Elastic Block Store - February 2017 AWS ... by Amazon Web Services
Optimize MySQL Workloads with Amazon Elastic Block Store - February 2017 AWS ...Optimize MySQL Workloads with Amazon Elastic Block Store - February 2017 AWS ...
Optimize MySQL Workloads with Amazon Elastic Block Store - February 2017 AWS ...
Amazon Web Services1.6K views
Experiences using CouchDB inside Microsoft's Azure team by Brian Benz
Experiences using CouchDB inside Microsoft's Azure teamExperiences using CouchDB inside Microsoft's Azure team
Experiences using CouchDB inside Microsoft's Azure team
Brian Benz5.6K views
Azure Cosmos DB + Gremlin API in Action by Denys Chamberland
Azure Cosmos DB + Gremlin API in ActionAzure Cosmos DB + Gremlin API in Action
Azure Cosmos DB + Gremlin API in Action
Denys Chamberland2.8K views
[WITH THE VISION 2017] IoT/AI時代を生き抜くためのデータ プラットフォーム (Leveraging Azure Data Se... by Naoki (Neo) SATO
[WITH THE VISION 2017] IoT/AI時代を生き抜くためのデータ プラットフォーム (Leveraging Azure Data Se...[WITH THE VISION 2017] IoT/AI時代を生き抜くためのデータ プラットフォーム (Leveraging Azure Data Se...
[WITH THE VISION 2017] IoT/AI時代を生き抜くためのデータ プラットフォーム (Leveraging Azure Data Se...
Naoki (Neo) SATO564 views
Deep Dive on Elastic File System - February 2017 AWS Online Tech Talks by Amazon Web Services
Deep Dive on Elastic File System - February 2017 AWS Online Tech TalksDeep Dive on Elastic File System - February 2017 AWS Online Tech Talks
Deep Dive on Elastic File System - February 2017 AWS Online Tech Talks
Amazon Web Services3.7K views
ENT309 scaling up to your first 10 million users by Amazon Web Services
ENT309 scaling up to your first 10 million usersENT309 scaling up to your first 10 million users
ENT309 scaling up to your first 10 million users
Amazon Web Services5.6K views

Similar to Cosmos DB - Database for Serverless era

Cosmos DB and Azure Functions A serverless database processing.pptx by
Cosmos DB and Azure Functions  A serverless database processing.pptxCosmos DB and Azure Functions  A serverless database processing.pptx
Cosmos DB and Azure Functions A serverless database processing.pptxicebeam7
152 views33 slides
DataWeekender 4_2 Cosmos DB and Azure Functions- A serverless database proces... by
DataWeekender 4_2 Cosmos DB and Azure Functions- A serverless database proces...DataWeekender 4_2 Cosmos DB and Azure Functions- A serverless database proces...
DataWeekender 4_2 Cosmos DB and Azure Functions- A serverless database proces...Luis Beltran
239 views33 slides
NoSQL Migration Technical Pitch Deck by
NoSQL Migration Technical Pitch DeckNoSQL Migration Technical Pitch Deck
NoSQL Migration Technical Pitch DeckNicholas Vossburg
100 views56 slides
WAZUG - Ring video doorbell meets Azure serverless by
WAZUG - Ring video doorbell meets Azure serverlessWAZUG - Ring video doorbell meets Azure serverless
WAZUG - Ring video doorbell meets Azure serverlessAnco Stuij
181 views30 slides
Azure Thursday - Ring video doorbell meets Azure serverless by
Azure Thursday - Ring video doorbell meets Azure serverlessAzure Thursday - Ring video doorbell meets Azure serverless
Azure Thursday - Ring video doorbell meets Azure serverlessAnco Stuij
269 views26 slides
2014.10.22 Building Azure Solutions with Office 365 by
2014.10.22 Building Azure Solutions with Office 3652014.10.22 Building Azure Solutions with Office 365
2014.10.22 Building Azure Solutions with Office 365Marco Parenzan
1K views74 slides

Similar to Cosmos DB - Database for Serverless era(20)

Cosmos DB and Azure Functions A serverless database processing.pptx by icebeam7
Cosmos DB and Azure Functions  A serverless database processing.pptxCosmos DB and Azure Functions  A serverless database processing.pptx
Cosmos DB and Azure Functions A serverless database processing.pptx
icebeam7152 views
DataWeekender 4_2 Cosmos DB and Azure Functions- A serverless database proces... by Luis Beltran
DataWeekender 4_2 Cosmos DB and Azure Functions- A serverless database proces...DataWeekender 4_2 Cosmos DB and Azure Functions- A serverless database proces...
DataWeekender 4_2 Cosmos DB and Azure Functions- A serverless database proces...
Luis Beltran239 views
WAZUG - Ring video doorbell meets Azure serverless by Anco Stuij
WAZUG - Ring video doorbell meets Azure serverlessWAZUG - Ring video doorbell meets Azure serverless
WAZUG - Ring video doorbell meets Azure serverless
Anco Stuij181 views
Azure Thursday - Ring video doorbell meets Azure serverless by Anco Stuij
Azure Thursday - Ring video doorbell meets Azure serverlessAzure Thursday - Ring video doorbell meets Azure serverless
Azure Thursday - Ring video doorbell meets Azure serverless
Anco Stuij269 views
2014.10.22 Building Azure Solutions with Office 365 by Marco Parenzan
2014.10.22 Building Azure Solutions with Office 3652014.10.22 Building Azure Solutions with Office 365
2014.10.22 Building Azure Solutions with Office 365
Marco Parenzan1K views
Microsoft Azure update by Karina Matos
Microsoft Azure updateMicrosoft Azure update
Microsoft Azure update
Karina Matos356 views
[「RDB技術者のためのNoSQLガイド」出版記念セミナー] Azure DocumentDB by Naoki (Neo) SATO
[「RDB技術者のためのNoSQLガイド」出版記念セミナー] Azure DocumentDB[「RDB技術者のためのNoSQLガイド」出版記念セミナー] Azure DocumentDB
[「RDB技術者のためのNoSQLガイド」出版記念セミナー] Azure DocumentDB
Naoki (Neo) SATO1.1K views
Microsoft Build 2020: Data Science Recap by Mark Tabladillo
Microsoft Build 2020: Data Science RecapMicrosoft Build 2020: Data Science Recap
Microsoft Build 2020: Data Science Recap
Mark Tabladillo196 views
NoSQL Migration to Azure Cosmos DB Pitch Deck by Nicholas Vossburg
NoSQL Migration to Azure Cosmos DB Pitch DeckNoSQL Migration to Azure Cosmos DB Pitch Deck
NoSQL Migration to Azure Cosmos DB Pitch Deck
Nicholas Vossburg151 views
Microsoft Azure News - November 2019 by Daniel Toomey
Microsoft Azure News - November 2019Microsoft Azure News - November 2019
Microsoft Azure News - November 2019
Daniel Toomey172 views
Ready for take-off - How to get your databases into the cloud by Andre Essing
Ready for take-off - How to get your databases into the cloudReady for take-off - How to get your databases into the cloud
Ready for take-off - How to get your databases into the cloud
Andre Essing114 views
Confluent On Azure: Why you should add Confluent to your Azure toolkit | Alic... by HostedbyConfluent
Confluent On Azure: Why you should add Confluent to your Azure toolkit | Alic...Confluent On Azure: Why you should add Confluent to your Azure toolkit | Alic...
Confluent On Azure: Why you should add Confluent to your Azure toolkit | Alic...
HostedbyConfluent395 views
Microsoft Azure Overview Infographic by Microsoft Azure
Microsoft Azure Overview InfographicMicrosoft Azure Overview Infographic
Microsoft Azure Overview Infographic
Microsoft Azure 2.8K views
Cosmos DB Conf - Cosmos DB + Azure Functions .pptx by Luis Beltran
Cosmos DB Conf - Cosmos DB + Azure Functions .pptxCosmos DB Conf - Cosmos DB + Azure Functions .pptx
Cosmos DB Conf - Cosmos DB + Azure Functions .pptx
Luis Beltran187 views

Recently uploaded

EV Charging App Case by
EV Charging App Case EV Charging App Case
EV Charging App Case iCoderz Solutions
9 views1 slide
FIMA 2023 Neo4j & FS - Entity Resolution.pptx by
FIMA 2023 Neo4j & FS - Entity Resolution.pptxFIMA 2023 Neo4j & FS - Entity Resolution.pptx
FIMA 2023 Neo4j & FS - Entity Resolution.pptxNeo4j
17 views26 slides
Using Qt under LGPL-3.0 by
Using Qt under LGPL-3.0Using Qt under LGPL-3.0
Using Qt under LGPL-3.0Burkhard Stubert
13 views11 slides
Playwright Retries by
Playwright RetriesPlaywright Retries
Playwright Retriesartembondar5
5 views1 slide
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionMárton Kodok
16 views55 slides
Agile 101 by
Agile 101Agile 101
Agile 101John Valentino
10 views20 slides

Recently uploaded(20)

FIMA 2023 Neo4j & FS - Entity Resolution.pptx by Neo4j
FIMA 2023 Neo4j & FS - Entity Resolution.pptxFIMA 2023 Neo4j & FS - Entity Resolution.pptx
FIMA 2023 Neo4j & FS - Entity Resolution.pptx
Neo4j17 views
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by Márton Kodok
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action
Márton Kodok16 views
tecnologia18.docx by nosi6702
tecnologia18.docxtecnologia18.docx
tecnologia18.docx
nosi67025 views
Ports-and-Adapters Architecture for Embedded HMI by Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMI
Burkhard Stubert29 views
Navigating container technology for enhanced security by Niklas Saari by Metosin Oy
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas Saari
Metosin Oy14 views
360 graden fabriek by info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info33492162 views
Electronic AWB - Electronic Air Waybill by Freightoscope
Electronic AWB - Electronic Air Waybill Electronic AWB - Electronic Air Waybill
Electronic AWB - Electronic Air Waybill
Freightoscope 5 views
Airline Booking Software by SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta9 views
Introduction to Git Source Control by John Valentino
Introduction to Git Source ControlIntroduction to Git Source Control
Introduction to Git Source Control
John Valentino7 views
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke35 views
Dapr Unleashed: Accelerating Microservice Development by Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski13 views
ADDO_2022_CICID_Tom_Halpin.pdf by TomHalpin9
ADDO_2022_CICID_Tom_Halpin.pdfADDO_2022_CICID_Tom_Halpin.pdf
ADDO_2022_CICID_Tom_Halpin.pdf
TomHalpin95 views

Cosmos DB - Database for Serverless era

  • 1. Cosmos DB Database for Serverless Era Michał Jankowski
  • 2. www.jankowskimichal.pl 2 about me 2 Michał Jankowski technical architect / team leader traveller / photographer www.jankowskimichal.pl mail@jankowskimichal.pl @JankowskiMichal github.com/MichalJankowskii
  • 3. aim. Learn using Cosmos DB in your Serverless solutions. Improve performance of your whole solution.
  • 4. www.jankowskimichal.pl 4 way of working A bit of theory, then a lot of demos and practice. I would encourage you to work together and exchange your knowledge. we should have fun
  • 5. Steve Jobs, cofounder of Apple Great things in business are never done by one person. They're done by a team of people.
  • 6. www.jankowskimichal.pl 6 presentation agenda Serverless & Cosmos DB A short theoretical introduction to these topics SQL API Let's learn how to use the main feature of this database by using SQL API
  • 7. www.jankowskimichal.pl 7 presentation agenda Azure Functions We will learn how Azure Function can cooperate with Cosmos DB. Graph API At the end, we will work with API that allows storing data that are connected with each other by multiple relations.
  • 8. www.jankowskimichal.pl 8 short survey Have you worked with Azure? Have you worked with Azure Functions? Have you worked with Cosmos DB?
  • 10. www.jankowskimichal.pl 10 serverless characteristics server abstraction There is no server managing tasks. productivity Reduce tasks related to infrastructure. You can focus on development activities. event driven Function does not work when there is no event triggering it. It can also instantly scale up. focus on features And then you are able to focus on business logic of your app. microbilling Pay only when there are events. But think about DDOS on your wallet. faster time to market All items mentioned together allow you to reduce time to market.
  • 11. www.jankowskimichal.pl 11 serverless in Azure An event-based serverless compute experience to accelerate your development. Scale based on demand and pay only for the resources you consume. Azure Functions A single service for managing routing of all events from any source to any destination. Designed for high availability, consistent performance and dynamic scale. Event Grid lets you focus on your app logic rather than infrastructure. Event Grid
  • 12. www.jankowskimichal.pl 12 serverless in Azure Provide a way to simplify and implement scalable integrations and workflows in the cloud. It provides a visual designer to model and automate your process as a series of steps known as a workflow. Logic Apps Is a service that allows you to create automated workflows between your favourite applications and services to synchronize files, get notifications, collect data, and more. Flow
  • 13. www.jankowskimichal.pl 13 serverless in Azure Was built from the ground up with global distribution and horizontal scale at its core. It offers turnkey global distribution with multi-master support across any number of Azure regions by transparently scaling and replicating your data wherever your users are. Cosmos DB
  • 14. cosmos db database for applications anywhere in the world
  • 15. www.jankowskimichal.pl 15 DocumentDB preview 21/08 2014 SQL grammar over schema-free JSON Tuneable throughput, indexing, consistency Server-side ACID transactions microsoft noSQL database evolution Internal Microsoft DocumentDB service 2010 - 2014 Office OneNote Xbox Part of Azure portal
  • 16. www.jankowskimichal.pl 16 Cosmos DB …improvements – May 2016 Partitioned collections Geo-replication MongoDB wire protocol support microsoft noSQL database evolution 08/04 2015 DocumentDB GA ORDER BY String range queries Geospatial support Partitioning support by SDK 10/05 2017
  • 17. www.jankowskimichal.pl 17 azure cosmos db limitless elastic scale around the globe With Azure Cosmos DB, you pay only for the throughput and storage you need. Azure Cosmos DB allows you to independently and elastically scale storage and throughput at any time, anywhere across the globe, making it a perfect ally for your serverless applications. Only Azure Cosmos DB allows you to use key-value, graph, column-family, and document data in one service. Azure Cosmos DB automatically indexes all data and allows you to use your favourite API including SQL, JavaScript, Gremlin, MongoDB, Apache® Cassandra, and Azure Table Storage to access your data. multi-model + multi-API Easily build globally distributed applications without the hassle of complex, multiple- datacenter configurations. Designed as a globally distributed database system, Azure Cosmos DB automatically replicates your data to any number of regions of your choice for fast, responsive access. Azure Cosmos DB supports transparent multi-homing and guarantees 99.999% high availability. turnkey global distribution
  • 18. www.jankowskimichal.pl 18 azure cosmos db industry-leading, enterprise-grade SLAs Rest assured your apps are running on a "battle-tested" database service built on world-class infrastructure. Azure Cosmos DB gives you enterprise-grade security and compliance, and is the first and only service to offer industry- leading comprehensive SLAs for 99.999% high availability, latency at the 99th percentile, guaranteed throughput, and consistency. Serve read and write requests from the nearest region while simultaneously distributing data across the globe. With its latch-free and write-optimized database engine, Azure Cosmos DB guarantees less than 10-ms latencies on reads and less than 15-ms latencies on (indexed) writes at the 99th percentile. guaranteed low latency at 99th percentile Azure Cosmos DB offers five well-defined consistency levels—strong, bounded staleness, consistent-prefix, session, and eventual—for an intuitive programming model with low latency and high availability for your planet-scale app. multiple, well-defined consistency choices
  • 20. Key benefits • Cosmos DB supports fast ingestion of message data from 1:1 communication, group chats • Cosmos DB enables real-time query over message and group conversations, with custom filters on when user enters/leaves thread Business need • Provide search capabilities over TBs-PBs of Skype and Teams conversations • Fast ingestion with multiple writes, overlay group memberships • Secure & compliant data storage with high privacy requirements Azure Cosmos DB Azure Cosmos DB Azure Cosmos DB USERS GROUPS MESSAGES Skype Ingestion service Skype Query service 44TB Message data Skype powers 1M searches per second over conversation data 6TB User data 1TB Group data Source: Building globally distributed applications with Azure Cosmos DB
  • 21. Key benefits • Cosmos DB can scale elastically without operational overhead of MongoDB • Perform fast queries over events to deliver recommended services, safety notices to vehicles • Perform staged migration via MongoDB APIs Business need • Need to ingest massive volumes of diagnostic data from vehicles and take real-time actions as part of connected car platform • Management and operations of database infrastructure to handle exponential growth of data 8TB Vehicle Telemetry 250K Lexus Cars Toyota drives connected car push forward with Azure Cosmos DB Azure Cosmos DBAzure HDInsight Storm Azure Storage (archival) Source: Building globally distributed applications with Azure Cosmos DB
  • 22. Business need • Handle millions of players on Day 1 due to popularity of the TV series • Match-making of players for competitive and lag-free experience • Provide new content weekly, and iterate on social functionality • Key benefits • Cosmos DB provides elastic scalability for millions of users and flexible schema to support social features and gameplay • Global distribution allows for low latency for players spread worldwide • Automatic indexing used to build real-time leaderboards Performance at massive scale allows millions to play mobile game Azure Traffic Manager Azure API Aps (game backend) Azure CDN Azure Cosmos DB Azure Functions Azure Notification Hubs (push notifications) Azure Storage (game files) 1M Peak Active #1 iOS App Store 1B Daily Queries Source: Building globally distributed applications with Azure Cosmos DB
  • 24. www.jankowskimichal.pl 24 before we start We will be working with expensive service. Use it wisely. And after all, please remember to clean your environment.
  • 26. www.jankowskimichal.pl 26 multiple APIs SQL API (json) MongoDB API (bson) document Cassandra API column-family Gremlin API (graph traversal language) graph Table API (potential replacement for Azure Table Storage) key-value
  • 28. www.jankowskimichal.pl 28 this is time for you It is time for you to start your journey with this product. Play with Cosmos DB jankowskimichal.pl/cosmosdb-list1
  • 30. www.jankowskimichal.pl 30 data in Cosmos DB • denormalized data • referential integrity NOT enforced • mixed data in collections • flexible schema • SQL-like language as well as JavaScript and others Cosmos DB (document db) • normalised data • referential integrity enforced by normalisation and relationships • uniform data in tables • schema is set • SQL Relational database
  • 31. www.jankowskimichal.pl 31 document vs relational database Cosmos DB (document db) Relational database
  • 32. www.jankowskimichal.pl 32 whole model in one record { "lastName": "Cartwright", "parents": [ { "firstName": "Elvira", "role": "mother", "age": 64 }, { "firstName": "Randolph", "role": "father", "age": 67 } ], "children": [ { "firstName": "Dana", "age": 15, "gender": "female“ }, { "firstName": "Pat", "age": 13, "gender": "male“, "grade": 7, "pets": [ { "name": "Concepcion", "type": "guinea pig“ }, { "name": "Haleigh", "type": "hamster“ } ]}], "address": { "state": "North Dakota", "city": "West Bretthaven", "country": "Guinea" } } complex structure one-to-many relation different object schema
  • 33. www.jankowskimichal.pl 33 database creation • create new one or use an existing one • setup performance on database level – throughput • there is no limit for it, but we need to contact support when we need more than 1 000 000 RU/s • we need to confirm higher costs we can
  • 34. www.jankowskimichal.pl 34 request units normalized measure of request processing cost Item size Reads / second Writes / second Request units 1 KB 500 100 1,000 RU/s 1 KB 500 500 3,000 RU/s 4 KB 500 100 1,350 RU/s 4 KB 500 500 4,150 RU/s 64 KB 500 100 9,800 RU/s 64 KB 500 500 29,000 RU/s Table that shows how many request units to provision for items with three different sizes (1 KB, 4 KB, and 64 KB) and at two different performance levels (500 reads/second + 100 writes/second and 500 reads/second + 500 writes/second). In this example, the data consistency is set to Session, and the indexing policy is set to None. • combines memory, CPU and IOPS into currency rate • each same request will always consume the same amount of RUs • each time we will get information about operation cost • we are paying for some capacity: • when it is exhausted our operations will be replanned • we can increase or decrease the amount of throughput instantaneously • without capacity our service will stop • cost of write operation is higher than read one • pricing cost may be different per region
  • 36. www.jankowskimichal.pl 36 collection creation option for start direction when we think about something serious
  • 37. www.jankowskimichal.pl 37 partition key Remember about some limits: • A physical partition can store a maximum of 10GB of data • A physical partition can facilitate at most 10,000 RU/s partition key selection is the most important decision Cosmos DB account Database Collections Physical partition Logical partition Logical partition Physical partition Documents
  • 39. Evans logical partition is growing Smith Jones Williams Taylor Davies Brown Wilson Thomas Johnson Roberts Evans Container
  • 40. new physical partition will be created Smith Jones Williams Taylor Davies Brown Wilson Thomas Johnson Container Roberts Evans
  • 42. Smith Jones Williams Taylor Davies Brown Wilson Thomas Johnson Container Roberts London Manchester Container Last name as partition key. Evans family with city as partition key. Liverpool Leeds Evans family as separate container
  • 43. how to do it right? • Choosing partition key purely depends on structure of data. • It is important to choose a partition key property that has a number of distinct values. • An ideal partition key is one that appears frequently as a filter in your queries and has sufficient cardinality to ensure your solution is scalable. • If chosen partition key doesn't have many distinct values then all queries will get fired to a single partition which may slow down performance. • General: • Do not be afraid of having too many partition keys. In most cases, more partition keys mean more scalability
  • 45. www.jankowskimichal.pl 45 this is time for you 1. Familiarise with presented queries. 2. Try to develop queries to a bigger database Let's do something more serious jankowskimichal.pl/cosmosdb-list2
  • 47. what is your opinion?
  • 48. www.jankowskimichal.pl 48 from my perspective quite simple product with some limitations and great potential we need to change how we are thinking about data and database can be very expensive when it is wrong designed or used
  • 50. www.jankowskimichal.pl 50 serverless main benefits cost can be more cost-effective than renting or purchasing a fixed quantity of servers operations / scalability a serverless architecture means that developers and operators do not need to spend time setting up and tuning autoscaling policies or system productivity simplifying the task of back-end software development
  • 51. www.jankowskimichal.pl 51 the performance latency How fast is the response on provided request? throughput How many requests can be handled in a provided period?
  • 52. www.jankowskimichal.pl 52 know the limits The speed of light in vacuum is a universal physical constant important in many areas of physics. Its exact value is 299,792,458 metres per second. The speed at which light propagates through transparent materials, such as glass or air, is less than c.
  • 53. www.jankowskimichal.pl 53 what does it mean for us? ~ 200ms ~ 5ms
  • 54. geo replication. • it has never been so easy • you can replicate your data to as many data centers as you need • you can do it with just a few clicks
  • 56. www.jankowskimichal.pl 56 bounded staleness Bounded staleness consistency guarantees that the reads may lag behind writes by at most K versions or prefixes of an item or t time-interval. The cost of a read operation (in terms of RUs consumed) with bounded staleness is higher than session and eventual consistency, but the same as strong consistency.
  • 57. www.jankowskimichal.pl 57 session Session consistency is ideal for all scenarios where a device or user session is involved since it guarantees monotonic reads, monotonic writes, and read your own writes (RYW) guarantees. Session consistency provides predictable consistency for a session, and maximum read throughput while offering the lowest latency writes and reads.
  • 58. www.jankowskimichal.pl 58 consistent prefix Consistent prefix guarantees that in absence of any further writes, the replicas within the group eventually converge. Consistent prefix guarantees that reads never see out of order writes. If writes were performed in the order A, B, C, then a client sees either A or A,B, or A,B,C, but never out of order like A,C or B,A,C.
  • 59. www.jankowskimichal.pl 59 eventual Eventual consistency guarantees that in absence of any further writes, the replicas within the group eventually converge. It is the weakest form of consistency a client may get the values that are older than the ones it had seen before. Provides the weakest read consistency but offers the lowest latency for both reads and writes with the lowest cost of a read operation.
  • 60. prefer bounded staleness20% Azure Cosmos DB tenants use session consistency73% experiment with various consistency levels initially before settling on a specific consistency 3%
  • 61. www.jankowskimichal.pl 61 read – nothing to do In the rare event of an Azure regional outage or data center outage, Cosmos DB automatically triggers failovers of all Cosmos DB accounts with a presence in the affected region. write – automatic failover must be on If the affected region is the current write region and automatic failover is enabled for the Azure Cosmos DB account, then the region is automatically marked as offline. Then, an alternative region is promoted as the write region for the affected Azure Cosmos DB account. * manual failover Can be used as follow the clock model. regional failover
  • 62. www.jankowskimichal.pl 62 data index customisations scope - include or exclude documents and paths to and from the index index types - hash - supports efficient equality and JOIN queries - range - supports efficient equality queries, range queries (using >, <, >=, <=, !=), and ORDER BY queries - spatial - supports efficient spatial (within and distance) queries precision - make trade-offs between index storage overhead and query performance index update mode - consistent, lazy, and none indexing everything by default
  • 63. azure functions. By definition, synergy happens when the interaction between two elements produces an effect greater than the individual elements’ contribution.
  • 65. www.jankowskimichal.pl 65 this is time for you 1. Create a function that allows adding new ToDo items to the database 2. Create a function that will list all ToDo items assigned to list Let’s build API for the application jankowskimichal.pl/cosmosdb-list3
  • 67. www.jankowskimichal.pl 67 main features many-to-many complex relations typical usage of this type of API social networks analyse interconnected data and relationships excessive JOINs recommendation engines knowledge graphs
  • 68. denote discrete objects, such as a person, a place, or an event Id: DEN Label: airport Properties: • Code: DEN • City: Denver • Description: Denver International Airport • Elevation: 5443 verticle denote relationships between vertices Id Label: route Properties: • Distance: 542 edge
  • 69. www.jankowskimichal.pl 69 sample graph label: route properties: • distance: 2249 id: United States label: country properties: • code: US • name: United States label: contains label: contains id: DEN label: airport properties: • code: DEN • city: Denver • elevation: 5443 id: ATL label: airport properties: • code: ATL • city: Atlanta • elevation: 1026
  • 71. www.jankowskimichal.pl 71 this is time for you 1. Get all the details about your favourite airport. 2. Check how you can get to your vacation location. Maybe you should plan your holidays jankowskimichal.pl/cosmosdb-list4
  • 72. summary. We made a brief introduction to serverless and its' connections to Cosmos DB. We learned how to use SQL API and connect Cosmos DB with Azure Functions. You should know how you can make optimisation of your environment. We tried graph API.
  • 73. www.jankowskimichal.pl 73 do you have any questions? www.jankowskimichal.pl @JankowskiMichal mail@jankowskimichal.pl github.com/MichalJankowskii
  • 74. www.jankowskimichal.pl 74 more information • https://azure.microsoft.com/en-us/services/ cosmos-db/ • https://docs.microsoft.com/en-us/azure/cosmos- db/ • https://docs.microsoft.com/en-us/azure/cosmos- db/sql-api-introduction • https://docs.microsoft.com/en-us/azure/azure- functions/ • https://docs.microsoft.com/en-us/azure/cosmos- db/serverless-computing-database • https://docs.microsoft.com/en-us/azure/cosmos- db/graph-introduction