<s>
Azure	B-Application
Cosmos	I-Application
DB	I-Application
is	O
a	O
globally	O
distributed	O
,	O
multi-model	B-Operating_System
database	I-Operating_System
service	O
offered	O
by	O
Microsoft	B-Application
Azure	I-Application
.	O
</s>
<s>
Unlike	O
traditional	O
relational	O
databases	O
,	O
Cosmos	B-Application
DB	I-Application
is	O
a	O
NoSQL	O
database	O
,	O
which	O
means	O
it	O
can	O
handle	O
unstructured	O
and	O
semi-structured	O
data	O
types	O
.	O
</s>
<s>
Internally	O
,	O
Cosmos	B-Application
DB	I-Application
stores	O
"	O
items	O
"	O
in	O
"	O
containers	O
"	O
,	O
with	O
these	O
two	O
concepts	O
being	O
surfaced	O
differently	O
depending	O
on	O
the	O
API	B-General_Concept
used	O
(	O
these	O
would	O
be	O
"	O
documents	O
"	O
in	O
"	O
collections	O
"	O
when	O
using	O
the	O
MongoDB-compatible	O
API	B-General_Concept
,	O
for	O
example	O
)	O
.	O
</s>
<s>
Cosmos	B-Application
DB	I-Application
offers	O
two	O
types	O
of	O
indexes	O
:	O
</s>
<s>
range	B-General_Concept
,	O
supporting	O
range	B-General_Concept
and	O
ORDER	O
BY	O
queries	O
,	O
</s>
<s>
spatial	O
,	O
supporting	O
spatial	B-Language
queries	I-Language
from	O
points	O
,	O
polygons	O
and	O
line	O
strings	O
encoded	O
in	O
standard	O
GeoJSON	B-General_Concept
fragments	O
.	O
</s>
<s>
Each	O
Cosmos	B-Application
DB	I-Application
container	O
exposes	O
a	O
change	O
feed	O
,	O
which	O
clients	O
can	O
subscribe	O
to	O
in	O
order	O
to	O
get	O
notified	O
of	O
new	O
items	O
being	O
added	O
or	O
updated	O
in	O
the	O
container	O
.	O
</s>
<s>
Changes	O
are	O
persisted	O
by	O
Cosmos	B-Application
DB	I-Application
,	O
which	O
makes	O
it	O
possible	O
to	O
request	O
changes	O
from	O
any	O
point	O
in	O
time	O
since	O
the	O
creation	O
of	O
the	O
container	O
.	O
</s>
<s>
A	O
"	O
Time	B-Protocol
to	I-Protocol
Live	I-Protocol
"	O
(	O
or	O
TTL	O
)	O
can	O
be	O
specified	O
at	O
the	O
container	O
level	O
to	O
let	O
Cosmos	B-Application
DB	I-Application
automatically	O
delete	O
items	O
after	O
a	O
certain	O
amount	O
of	O
time	O
expressed	O
in	O
seconds	O
.	O
</s>
<s>
five	O
different	O
compatibility	O
APIs	B-General_Concept
,	O
exposing	O
endpoints	O
that	O
are	O
partially	O
compatible	O
with	O
the	O
wire	O
protocols	O
of	O
MongoDB	B-Application
,	O
Gremlin	B-Language
,	O
Cassandra	B-Application
,	O
Azure	O
Table	O
Storage	O
,	O
and	O
etcd	O
;	O
these	O
compatibility	O
APIs	B-General_Concept
make	O
it	O
possible	O
for	O
any	O
compatible	O
application	O
to	O
connect	O
to	O
and	O
use	O
Cosmos	B-Application
DB	I-Application
through	O
standard	O
drivers	O
or	O
SDKs	O
,	O
while	O
also	O
benefiting	O
from	O
Cosmos	B-Application
DB	I-Application
's	O
core	O
features	O
like	O
partitioning	O
and	O
global	O
distribution	O
.	O
</s>
<s>
APIInternal	O
mappingCompatibility	O
status	O
and	O
remarksContainersItemsMongoDBCollectionsDocumentsCompatible	O
with	O
wire	O
protocol	O
version	O
6	O
and	O
server	O
version	O
3.6	O
of	O
the	O
MongoDB.GremlinGraphsNodes	O
and	O
edgesCompatible	O
with	O
version	O
3.2	O
of	O
the	O
Gremlin	B-Language
specification.CassandraTableRowCompatible	O
with	O
version	O
4	O
of	O
the	O
Cassandra	B-Application
Query	O
Language	O
(	O
CQL	O
)	O
wire	O
protocol.Azure	O
Table	O
StorageTableItemetcdKeyValueCompatible	O
with	O
version	O
3	O
of	O
etcd	O
.	O
</s>
<s>
The	O
SQL	O
API	B-General_Concept
lets	O
clients	O
create	O
,	O
update	O
and	O
delete	O
containers	O
and	O
items	O
.	O
</s>
<s>
Items	O
can	O
be	O
queried	O
with	O
a	O
read-only	O
,	O
JSON-friendly	O
SQL	O
dialect	O
.	O
</s>
<s>
As	O
Cosmos	B-Application
DB	I-Application
embeds	O
a	O
JavaScript	B-Language
engine	I-Language
,	O
the	O
SQL	O
API	B-General_Concept
also	O
enables	O
:	O
</s>
<s>
Stored	B-General_Concept
procedures	I-General_Concept
.	O
</s>
<s>
Functions	O
that	O
bundle	O
an	O
arbitrarily	O
complex	O
set	O
of	O
operations	O
and	O
logic	O
into	O
an	O
ACID-compliant	B-Operating_System
transaction	O
.	O
</s>
<s>
They	O
are	O
isolated	O
from	O
changes	O
made	O
while	O
the	O
stored	B-General_Concept
procedure	I-General_Concept
is	O
executing	O
and	O
either	O
all	O
write	O
operations	O
succeed	O
or	O
they	O
all	O
fail	O
,	O
leaving	O
the	O
database	O
in	O
a	O
consistent	O
state	O
.	O
</s>
<s>
Stored	B-General_Concept
procedures	I-General_Concept
are	O
executed	O
in	O
a	O
single	O
partition	O
.	O
</s>
<s>
Stored	B-General_Concept
procedures	I-General_Concept
can	O
be	O
used	O
to	O
make	O
up	O
for	O
the	O
lack	O
of	O
certain	O
functionality	O
.	O
</s>
<s>
For	O
instance	O
,	O
the	O
lack	O
of	O
aggregation	O
capability	O
is	O
made	O
up	O
for	O
by	O
the	O
implementation	O
of	O
an	O
OLAP	B-Application
cube	O
as	O
a	O
stored	B-General_Concept
procedure	I-General_Concept
in	O
the	O
open	O
sourced	O
documentdb-lumenize	O
project	O
.	O
</s>
<s>
User-defined	B-Language
functions	I-Language
(	O
UDF	O
)	O
.	O
</s>
<s>
The	O
SQL	O
API	B-General_Concept
is	O
exposed	O
as	O
a	O
REST	B-Protocol
API	I-Protocol
,	O
which	O
itself	O
is	O
implemented	O
in	O
various	O
SDKs	O
that	O
are	O
officially	O
supported	O
by	O
Microsoft	O
and	O
available	O
for	O
.NET	B-Application
Framework	I-Application
,	O
.NET	B-Application
,	O
Node.js	B-Language
(	O
JavaScript	B-Language
)	O
,	O
Java	B-Language
and	O
Python	B-Language
.	O
</s>
<s>
Cosmos	B-Application
DB	I-Application
added	O
automatic	O
partitioning	O
capability	O
in	O
2016	O
with	O
the	O
introduction	O
of	O
partitioned	O
containers	O
.	O
</s>
<s>
Cosmos	B-Application
DB	I-Application
automatically	O
decides	O
how	O
many	O
partitions	O
to	O
spread	O
data	O
across	O
depending	O
on	O
the	O
size	O
and	O
throughput	O
needs	O
.	O
</s>
<s>
Before	O
partitioned	O
containers	O
were	O
available	O
,	O
it	O
was	O
common	O
to	O
write	O
custom	O
code	O
to	O
partition	O
data	O
and	O
some	O
of	O
the	O
Cosmos	B-Application
DB	I-Application
SDKs	O
explicitly	O
supported	O
several	O
different	O
partitioning	O
schemes	O
.	O
</s>
<s>
Cosmos	B-Application
DB	I-Application
reserves	O
resources	O
(	O
memory	O
,	O
CPU	O
and	O
IOPS	O
)	O
to	O
guarantee	O
the	O
requested	O
throughput	O
while	O
maintaining	O
request	O
latency	O
below	O
10ms	O
for	O
both	O
reads	O
and	O
writes	O
at	O
the	O
99th	O
percentile	O
.	O
</s>
<s>
aggregations	O
like	O
count	O
)	O
and	O
stored	B-General_Concept
procedure	I-General_Concept
executions	O
can	O
consume	O
hundreds	O
to	O
thousands	O
of	O
RUs	O
depending	O
on	O
the	O
complexity	O
of	O
the	O
operations	O
needed	O
.	O
</s>
<s>
Cosmos	B-Application
DB	I-Application
databases	O
can	O
be	O
configured	O
to	O
be	O
available	O
in	O
any	O
of	O
the	O
Microsoft	B-Application
Azure	I-Application
regions	O
(	O
54	O
regions	O
as	O
of	O
December	O
2018	O
)	O
,	O
letting	O
application	O
developers	O
place	O
their	O
data	O
closer	O
to	O
where	O
their	O
users	O
are	O
.	O
</s>
<s>
By	O
leveraging	O
Cosmos	B-Application
DB	I-Application
's	O
multi-homing	O
API	B-General_Concept
,	O
applications	O
do	O
n't	O
have	O
to	O
be	O
updated	O
or	O
redeployed	O
when	O
regions	O
are	O
added	O
or	O
removed	O
,	O
as	O
Cosmos	B-Application
DB	I-Application
will	O
automatically	O
route	O
their	O
requests	O
to	O
the	O
regions	O
that	O
are	O
available	O
and	O
closest	O
to	O
their	O
location	O
.	O
</s>
<s>
Data	B-General_Concept
consistency	I-General_Concept
is	O
configurable	O
on	O
Cosmos	B-Application
DB	I-Application
,	O
letting	O
application	O
developers	O
choose	O
among	O
five	O
different	O
levels	O
:	O
</s>
<s>
The	O
desired	O
consistency	B-General_Concept
level	O
is	O
defined	O
at	O
the	O
account	O
level	O
but	O
can	O
be	O
overridden	O
on	O
a	O
per	O
request	O
basis	O
by	O
using	O
a	O
specific	O
HTTP	O
header	O
or	O
the	O
corresponding	O
feature	O
exposed	O
by	O
the	O
SDKs	O
.	O
</s>
<s>
All	O
five	O
consistency	B-General_Concept
levels	O
have	O
been	O
specified	O
and	O
verified	O
using	O
the	O
TLA+	B-Application
specification	I-Application
language	I-Application
,	O
with	O
the	O
TLA+	B-Application
model	O
being	O
open-sourced	O
on	O
GitHub	O
.	O
</s>
<s>
Cosmos	B-Application
DB	I-Application
's	O
original	O
distribution	O
model	O
involves	O
one	O
single	O
write	O
region	O
,	O
with	O
all	O
other	O
regions	O
being	O
read-only	O
replicas	O
.	O
</s>
<s>
Potential	O
merge	O
conflicts	O
that	O
may	O
arise	O
when	O
different	O
write	O
regions	O
issue	O
concurrent	O
,	O
conflicting	O
writes	O
can	O
be	O
resolved	O
by	O
either	O
the	O
default	O
Last	O
Write	O
Wins	O
policy	O
,	O
or	O
a	O
custom	O
JavaScript	B-Language
function	O
.	O
</s>
<s>
This	O
feature	O
,	O
announced	O
in	O
May	O
2020	O
,	O
is	O
a	O
fully	O
isolated	O
column	O
store	O
for	O
enabling	O
large	O
scale	O
analytics	O
against	O
operational	O
data	O
in	O
the	O
Azure	B-Application
Cosmos	I-Application
DB	I-Application
,	O
without	O
any	O
impact	O
to	O
its	O
transactional	O
workloads	O
.	O
</s>
<s>
This	O
feature	O
addresses	O
the	O
complexity	O
and	O
latency	O
challenges	O
that	O
occur	O
with	O
the	O
traditional	O
ETL	O
pipelines	O
required	O
to	O
have	O
a	O
data	O
repository	O
optimized	O
to	O
execute	O
Online	B-Application
analytical	I-Application
processing	I-Application
by	O
automatically	O
syncing	O
the	O
operational	O
data	O
into	O
a	O
separate	O
column	O
store	O
suitable	O
for	O
large	O
scale	O
analytical	O
queries	O
to	O
be	O
performed	O
in	O
an	O
optimized	O
manner	O
,	O
resulting	O
in	O
improving	O
the	O
latency	O
of	O
such	O
queries	O
.	O
</s>
<s>
Using	O
Microsoft	B-Application
Azure	I-Application
Synapse	O
Link	O
for	O
Cosmos	B-Application
DB	I-Application
,	O
it	O
is	O
possible	O
to	O
build	O
no-ETL	O
Hybrid	O
transactional/analytical	O
processing	O
solutions	O
by	O
directly	O
linking	O
to	O
Azure	B-Application
Cosmos	I-Application
DB	I-Application
analytical	O
store	O
from	O
Synapse	O
Analytics	O
.	O
</s>
<s>
Gartner	O
Research	O
positions	O
Microsoft	O
as	O
the	O
leader	O
in	O
the	O
Magic	O
Quadrant	O
Operational	O
Database	O
Management	O
Systems	O
in	O
2016	O
and	O
calls	O
out	O
the	O
unique	O
capabilities	O
of	O
Cosmos	B-Application
DB	I-Application
in	O
their	O
write-up	O
.	O
</s>
<s>
Microsoft	O
utilizes	O
Cosmos	B-Application
DB	I-Application
in	O
many	O
of	O
its	O
own	O
apps	O
,	O
including	O
Microsoft	B-Application
Office	I-Application
,	O
Skype	B-Application
,	O
Active	B-Protocol
Directory	I-Protocol
,	O
Xbox	B-Protocol
,	O
and	O
MSN	B-Protocol
.	O
</s>
<s>
In	O
building	O
a	O
more	O
globally-resilient	O
application	O
/	O
system	O
,	O
Cosmos	B-Application
DB	I-Application
combines	O
with	O
other	O
Azure	O
services	O
,	O
such	O
as	O
Azure	O
App	O
Services	O
and	O
Azure	O
Traffic	O
Manager	O
.	O
</s>
<s>
The	O
Cosmos	B-Application
DB	I-Application
Profiler	O
cloud	O
cost	O
optimization	O
tool	O
detects	O
inefficient	O
data	O
queries	O
in	O
the	O
interactions	O
between	O
an	O
application	O
and	O
its	O
Cosmos	B-Application
DB	I-Application
database	O
.	O
</s>
<s>
However	O
,	O
stored	B-General_Concept
procedures	I-General_Concept
can	O
be	O
used	O
to	O
implement	O
in-the-database	O
aggregation	O
capability	O
.	O
</s>
<s>
Support	O
only	O
for	O
pure	O
JSON	B-General_Concept
data	O
types	O
.	O
</s>
<s>
Most	O
notably	O
,	O
Cosmos	B-Application
DB	I-Application
lacks	O
support	O
for	O
date-time	O
data	O
requiring	O
that	O
you	O
store	O
this	O
data	O
using	O
the	O
available	O
data	O
types	O
.	O
</s>
<s>
MongoDB	B-Application
,	O
the	O
database	O
to	O
which	O
Cosmos	B-Application
DB	I-Application
is	O
most	O
often	O
compared	O
,	O
extended	O
JSON	B-General_Concept
in	O
their	O
BSON	O
binary	O
serialization	O
specification	O
to	O
cover	O
date-time	O
data	O
as	O
well	O
as	O
traditional	O
number	O
types	O
,	O
regular	O
expressions	O
,	O
and	O
Undefined	O
.	O
</s>
<s>
However	O
,	O
many	O
argue	O
that	O
Cosmos	B-Application
DB	I-Application
's	O
choice	O
of	O
pure	O
JSON	B-General_Concept
is	O
actually	O
an	O
advantage	O
as	O
it	O
's	O
a	O
better	O
fit	O
for	O
JSON-based	O
REST	B-Protocol
APIs	I-Protocol
and	O
the	O
JavaScript	B-Language
engine	I-Language
built	O
into	O
the	O
database	O
.	O
</s>
