<s>
Amazon	B-Application
DynamoDB	I-Application
is	O
a	O
fully	O
managed	O
proprietary	B-Application
NoSQL	B-General_Concept
database	O
service	O
that	O
supports	O
key	B-Application
–	I-Application
value	I-Application
and	O
document	O
data	B-General_Concept
structures	I-General_Concept
and	O
is	O
offered	O
by	O
Amazon.com	B-Application
as	O
part	O
of	O
the	O
Amazon	B-Application
Web	I-Application
Services	I-Application
portfolio	O
.	O
</s>
<s>
DynamoDB	B-Application
uses	O
synchronous	O
replication	O
across	O
multiple	O
data	B-Operating_System
centers	I-Operating_System
for	O
high	O
durability	O
and	O
availability	O
.	O
</s>
<s>
DynamoDB	B-Application
was	O
announced	O
by	O
Amazon	B-Application
CTO	O
Werner	O
Vogels	O
on	O
January	O
18	O
,	O
2012	O
,	O
and	O
is	O
presented	O
as	O
an	O
evolution	O
of	O
Amazon	B-Application
SimpleDB	O
.	O
</s>
<s>
Werner	O
Vogels	O
,	O
CTO	O
at	O
Amazon.com,	O
provided	O
a	O
motivation	O
for	O
the	O
project	O
in	O
his	O
2012	O
announcement	O
.	O
</s>
<s>
Amazon	B-Application
began	O
as	O
a	O
decentralized	O
network	O
of	O
services	O
.	O
</s>
<s>
When	O
this	O
became	O
a	O
bottleneck	O
on	O
engineering	O
operations	O
,	O
services	O
moved	O
away	O
from	O
this	O
direct	O
access	O
pattern	O
in	O
favor	O
of	O
public-facing	O
APIs	B-Application
.	O
</s>
<s>
Still	O
,	O
third-party	O
relational	B-Application
database	I-Application
management	I-Application
systems	I-Application
struggled	O
to	O
handle	O
Amazon	B-Application
's	O
client	O
base	O
.	O
</s>
<s>
Engineers	O
were	O
normalizing	O
these	O
relational	O
systems	O
to	O
reduce	O
data	B-Application
redundancy	I-Application
,	O
a	O
design	O
that	O
optimizes	O
for	O
storage	B-General_Concept
.	O
</s>
<s>
Many	O
of	O
Amazon	B-Application
's	O
services	O
demanded	O
mostly	O
primary-key	O
reads	O
on	O
their	O
data	O
,	O
and	O
with	O
speed	O
a	O
top	O
priority	O
,	O
putting	O
these	O
pieces	O
together	O
was	O
extremely	O
taxing	O
.	O
</s>
<s>
Content	O
with	O
compromising	O
storage	B-General_Concept
efficiency	O
,	O
Amazon	B-Application
's	O
response	O
was	O
Dynamo	B-Application
:	O
a	O
highly	O
available	O
key	B-Data_Structure
–	I-Data_Structure
value	I-Data_Structure
store	I-Data_Structure
built	O
for	O
internal	O
use	O
.	O
</s>
<s>
Dynamo	B-Application
,	O
it	O
seemed	O
,	O
was	O
everything	O
their	O
engineers	O
needed	O
,	O
but	O
adoption	O
lagged	O
.	O
</s>
<s>
Amazon	B-Application
's	O
developers	O
opted	O
for	O
"	O
just	O
works	O
"	O
design	O
patterns	O
with	O
S3	B-General_Concept
and	O
SimpleDB	O
.	O
</s>
<s>
While	O
these	O
systems	O
had	O
noticeable	O
design	O
flaws	O
,	O
they	O
did	O
not	O
demand	O
the	O
overhead	O
of	O
provisioning	O
hardware	O
and	O
scaling	B-Architecture
and	O
re-partitioning	O
data	O
.	O
</s>
<s>
Amazon	B-Application
's	O
next	O
iteration	O
of	O
NoSQL	B-General_Concept
technology	O
,	O
DynamoDB	B-Application
,	O
automated	O
these	O
database	O
management	O
operations	O
.	O
</s>
<s>
DynamoDB	B-Application
differs	O
from	O
other	O
Amazon	B-Application
services	O
by	O
allowing	O
developers	O
to	O
purchase	O
a	O
service	O
based	O
on	O
throughput	O
,	O
rather	O
than	O
storage	B-General_Concept
.	O
</s>
<s>
If	O
Auto	O
Scaling	B-Architecture
is	O
enabled	O
,	O
then	O
the	O
database	O
will	O
scale	B-Architecture
automatically	O
.	O
</s>
<s>
Additionally	O
,	O
administrators	O
can	O
request	O
throughput	O
changes	O
and	O
DynamoDB	B-Application
will	O
spread	O
the	O
data	O
and	O
traffic	O
over	O
a	O
number	O
of	O
servers	O
using	O
solid-state	B-Device
drives	I-Device
,	O
allowing	O
predictable	O
performance	O
.	O
</s>
<s>
It	O
offers	O
integration	O
with	O
Hadoop	B-Application
via	O
Elastic	B-Application
MapReduce	I-Application
.	O
</s>
<s>
In	O
September	O
2013	O
,	O
Amazon	B-Application
made	O
a	O
local	O
development	O
version	O
of	O
DynamoDB	B-Application
available	O
so	O
developers	O
could	O
test	O
DynamoDB-backed	O
applications	O
locally	O
.	O
</s>
<s>
A	O
DynamoDB	B-Application
table	B-Application
features	O
items	O
that	O
have	O
attributes	O
,	O
some	O
of	O
which	O
form	O
a	O
primary	B-Application
key	I-Application
.	O
</s>
<s>
In	O
relational	O
systems	O
,	O
however	O
,	O
an	O
item	O
features	O
each	O
table	B-Application
attribute	O
(	O
or	O
juggles	O
"	O
null	O
"	O
and	O
"	O
unknown	O
"	O
values	O
in	O
their	O
absence	O
)	O
,	O
DynamoDB	B-Application
items	O
are	O
schema-less	O
.	O
</s>
<s>
The	O
only	O
exception	O
:	O
when	O
creating	O
a	O
table	B-Application
,	O
a	O
developer	O
specifies	O
a	O
primary	B-Application
key	I-Application
,	O
and	O
the	O
table	B-Application
requires	O
a	O
key	O
for	O
every	O
item	O
.	O
</s>
<s>
Primary	B-Application
keys	I-Application
must	O
be	O
scalar	O
(	O
strings	O
,	O
numbers	O
,	O
or	O
binary	O
)	O
and	O
can	O
take	O
one	O
of	O
two	O
forms	O
.	O
</s>
<s>
A	O
single-attribute	O
primary	B-Application
key	I-Application
is	O
known	O
as	O
the	O
table	B-Application
's	O
"	O
partition	O
key	O
"	O
,	O
which	O
determines	O
the	O
partition	O
that	O
an	O
item	O
hashes	B-Error_Name
to	O
–	O
–	O
more	O
on	O
partitioning	O
below	O
–	O
–	O
so	O
an	O
ideal	O
partition	O
key	O
has	O
a	O
uniform	O
distribution	O
over	O
its	O
range	O
.	O
</s>
<s>
A	O
primary	B-Application
key	I-Application
can	O
also	O
feature	O
a	O
second	O
attribute	O
,	O
which	O
DynamoDB	B-Application
calls	O
the	O
table	B-Application
's	O
"	O
sort	O
key	O
"	O
.	O
</s>
<s>
In	O
the	O
relational	O
model	O
,	O
indices	O
typically	O
serve	O
as	O
"	O
helper	O
"	O
data	B-General_Concept
structures	I-General_Concept
to	O
supplement	O
a	O
table	B-Application
.	O
</s>
<s>
In	O
DynamoDB	B-Application
,	O
there	O
is	O
no	O
query	B-Language
optimizer	I-Language
,	O
and	O
an	O
index	O
is	O
simply	O
another	O
table	B-Application
with	O
a	O
different	O
key	O
(	O
or	O
two	O
)	O
that	O
sits	O
beside	O
the	O
original	O
.	O
</s>
<s>
When	O
a	O
developer	O
creates	O
an	O
index	O
,	O
they	O
create	O
a	O
new	O
copy	O
of	O
their	O
data	O
,	O
but	O
only	O
the	O
fields	O
that	O
they	O
specified	O
get	O
copied	O
over	O
(	O
at	O
a	O
minimum	O
,	O
the	O
fields	O
that	O
they	O
index	O
on	O
and	O
the	O
original	O
table	B-Application
's	O
primary	B-Application
key	I-Application
)	O
.	O
</s>
<s>
DynamoDB	B-Application
users	O
issue	O
queries	O
directly	O
to	O
their	O
indices	O
.	O
</s>
<s>
A	O
global	O
secondary	O
index	O
features	O
a	O
partition	O
key	O
(	O
and	O
optional	O
sort	O
key	O
)	O
that	O
's	O
different	O
from	O
the	O
original	O
table	B-Application
's	O
partition	O
key	O
.	O
</s>
<s>
A	O
local	O
secondary	O
index	O
features	O
the	O
same	O
partition	O
key	O
as	O
the	O
original	O
table	B-Application
,	O
but	O
a	O
different	O
sort	O
key	O
.	O
</s>
<s>
Both	O
indices	O
introduce	O
entirely	O
new	O
query	O
functionality	O
to	O
a	O
DynamoDB	B-Application
database	O
by	O
allowing	O
queries	O
on	O
new	O
keys	O
.	O
</s>
<s>
Similar	O
to	O
relational	B-Application
database	I-Application
management	I-Application
systems	I-Application
,	O
DynamoDB	B-Application
updates	O
indices	O
automatically	O
on	O
addition/update/deletion	O
,	O
so	O
you	O
must	O
be	O
judicious	O
when	O
creating	O
them	O
or	O
risk	O
slowing	O
down	O
a	O
write-heavy	O
database	O
with	O
a	O
slew	O
of	O
index	O
updates	O
.	O
</s>
<s>
DynamoDB	B-Application
uses	O
JSON	B-General_Concept
for	O
its	O
syntax	O
because	O
of	O
its	O
ubiquity	O
.	O
</s>
<s>
The	O
create	O
table	B-Application
action	O
demands	O
just	O
three	O
arguments	O
:	O
TableName	O
,	O
KeySchema	O
–	O
–	O
a	O
list	O
containing	O
a	O
partition	O
key	O
and	O
an	O
optional	O
sort	O
key	O
–	O
–	O
and	O
AttributeDefinitions	O
–	O
–	O
a	O
list	O
of	O
attributes	O
to	O
be	O
defined	O
which	O
must	O
at	O
least	O
contain	O
definitions	O
for	O
the	O
attributes	O
used	O
as	O
partition	O
and	O
sort	O
keys	O
.	O
</s>
<s>
Whereas	O
relational	B-Application
databases	I-Application
offer	O
robust	O
query	O
languages	O
,	O
DynamoDB	B-Application
offers	O
just	O
Put	O
,	O
Get	O
,	O
Update	O
,	O
and	O
Delete	O
operations	O
.	O
</s>
<s>
DynamoDB	B-Application
uses	O
hashing	B-Error_Name
and	O
B-trees	B-Architecture
to	O
manage	O
data	O
.	O
</s>
<s>
Upon	O
entry	O
,	O
data	O
is	O
first	O
distributed	O
into	O
different	O
partitions	O
by	O
hashing	B-Error_Name
on	O
the	O
partition	O
key	O
.	O
</s>
<s>
One	O
RCU	O
represents	O
one	O
strongly	B-General_Concept
consistent	I-General_Concept
read	O
per	O
second	O
or	O
two	O
eventually	B-General_Concept
consistent	I-General_Concept
reads	O
per	O
second	O
for	O
items	O
up	O
to	O
4KB	O
in	O
size	O
.	O
</s>
<s>
To	O
prevent	O
data	O
loss	O
,	O
DynamoDB	B-Application
features	O
a	O
two-tier	O
backup	O
system	O
of	O
replication	O
and	O
long-term	O
storage	B-General_Concept
.	O
</s>
<s>
Each	O
node	O
also	O
contains	O
two	O
data	B-General_Concept
structures	I-General_Concept
:	O
a	O
B	B-Architecture
tree	I-Architecture
used	O
to	O
locate	O
items	O
,	O
and	O
a	O
replication	O
log	O
that	O
notes	O
all	O
changes	O
made	O
to	O
the	O
node	O
.	O
</s>
<s>
DynamoDB	B-Application
periodically	O
takes	O
snapshots	O
of	O
these	O
two	O
data	B-General_Concept
structures	I-General_Concept
and	O
stores	O
them	O
for	O
a	O
month	O
in	O
S3	B-General_Concept
so	O
that	O
engineers	O
can	O
perform	O
point-in-time	O
restores	O
of	O
their	O
databases	O
.	O
</s>
<s>
All	O
write	O
operations	O
travel	O
first	O
through	O
the	O
leader	O
node	O
before	O
propagating	O
,	O
which	O
makes	O
writes	O
consistent	O
in	O
DynamoDB	B-Application
.	O
</s>
<s>
DynamoDB	B-Application
uses	O
the	O
Paxos	B-Operating_System
algorithm	I-Operating_System
to	O
elect	O
leaders	O
.	O
</s>
<s>
Amazon	B-Application
engineers	O
originally	O
avoided	O
Dynamo	B-Application
due	O
to	O
engineering	O
overheads	O
like	O
provisioning	O
and	O
managing	O
partitions	O
and	O
nodes	O
.	O
</s>
<s>
In	O
response	O
,	O
the	O
DynamoDB	B-Application
team	O
built	O
a	O
service	O
it	O
calls	O
AutoAdmin	O
to	O
manage	O
a	O
database	O
.	O
</s>
<s>
Just	O
like	O
indexing	O
systems	O
in	O
the	O
relational	O
model	O
,	O
DynamoDB	B-Application
demands	O
that	O
any	O
updates	O
to	O
a	O
table	B-Application
be	O
reflected	O
in	O
each	O
of	O
the	O
table	B-Application
's	O
indices	O
.	O
</s>
<s>
DynamoDB	B-Application
handles	O
this	O
using	O
a	O
service	O
it	O
calls	O
the	O
"	O
log	O
propagator	O
"	O
,	O
which	O
subscribes	O
to	O
the	O
replication	O
logs	O
in	O
each	O
node	O
and	O
sends	O
additional	O
Put	O
,	O
Update	O
,	O
and	O
Delete	O
requests	O
to	O
indices	O
as	O
necessary	O
.	O
</s>
<s>
Because	O
indices	O
result	O
in	O
substantial	O
performance	O
hits	O
for	O
write	O
requests	O
,	O
DynamoDB	B-Application
allows	O
a	O
user	O
at	O
most	O
five	O
of	O
them	O
on	O
any	O
given	O
table	B-Application
.	O
</s>
<s>
Suppose	O
that	O
a	O
DynamoDB	B-Application
user	O
issues	O
a	O
write	O
operation	O
(	O
a	O
Put	O
,	O
Update	O
,	O
or	O
Delete	O
)	O
.	O
</s>
<s>
While	O
a	O
typical	O
relational	O
system	O
would	O
convert	O
the	O
SQL	O
query	O
to	O
relational	B-Algorithm
algebra	I-Algorithm
and	O
run	O
optimization	O
algorithms	O
,	O
DynamoDB	B-Application
skips	O
both	O
processes	O
and	O
gets	O
right	O
to	O
work	O
.	O
</s>
<s>
The	O
request	O
arrives	O
at	O
the	O
DynamoDB	B-Application
request	O
router	O
,	O
which	O
authenticates	O
–	O
–	O
"	O
Is	O
the	O
request	O
coming	O
from	O
where/whom	O
it	O
claims	O
to	O
be	O
?	O
</s>
<s>
Assuming	O
these	O
checks	O
pass	O
,	O
the	O
system	O
hashes	B-Error_Name
the	O
request	O
's	O
partition	O
key	O
to	O
arrive	O
in	O
the	O
appropriate	O
partition	O
.	O
</s>
<s>
For	O
each	O
index	O
,	O
it	O
grabs	O
that	O
index	O
's	O
primary	B-Application
key	I-Application
value	O
from	O
the	O
item	O
,	O
then	O
performs	O
the	O
same	O
write	O
on	O
that	O
index	O
without	O
log	O
propagation	O
.	O
</s>
<s>
If	O
the	O
operation	O
is	O
an	O
Update	O
to	O
a	O
preexisting	O
item	O
,	O
the	O
updated	O
attribute	O
may	O
serve	O
as	O
a	O
primary	B-Application
key	I-Application
for	O
an	O
index	O
,	O
and	O
thus	O
the	O
B	B-Architecture
tree	I-Architecture
for	O
that	O
index	O
must	O
update	O
as	O
well	O
.	O
</s>
<s>
B	B-Architecture
trees	I-Architecture
only	O
handle	O
insert	O
,	O
delete	O
,	O
and	O
read	O
operations	O
,	O
so	O
in	O
practice	O
,	O
when	O
the	O
log	O
propagator	O
receives	O
an	O
Update	O
operation	O
,	O
it	O
issues	O
both	O
a	O
Delete	O
operation	O
and	O
a	O
Put	O
operation	O
to	O
all	O
indices	O
.	O
</s>
<s>
Now	O
suppose	O
that	O
a	O
DynamoDB	B-Application
user	O
issues	O
a	O
Get	O
operation	O
.	O
</s>
<s>
Next	O
,	O
as	O
above	O
,	O
we	O
hash	B-Error_Name
our	O
partition	O
key	O
to	O
arrive	O
in	O
the	O
appropriate	O
hash	B-Error_Name
.	O
</s>
<s>
Now	O
,	O
we	O
encounter	O
a	O
problem	O
:	O
with	O
three	O
nodes	O
in	O
eventual	B-General_Concept
consistency	I-General_Concept
with	O
one	O
another	O
,	O
how	O
can	O
we	O
decide	O
which	O
to	O
investigate	O
?	O
</s>
<s>
DynamoDB	B-Application
offers	O
the	O
user	O
two	O
options	O
when	O
issuing	O
a	O
read	O
:	O
consistent	O
and	O
eventually	B-General_Concept
consistent	I-General_Concept
.	O
</s>
<s>
The	O
second	O
option	O
,	O
an	O
eventually	B-General_Concept
consistent	I-General_Concept
read	O
,	O
selects	O
a	O
random	O
node	O
.	O
</s>
<s>
In	O
practice	O
,	O
this	O
is	O
where	O
DynamoDB	B-Application
trades	O
consistency	O
for	O
availability	O
.	O
</s>
<s>
DynamoDB	B-Application
exposes	O
performance	O
metrics	O
that	O
help	O
users	O
provision	O
it	O
correctly	O
and	O
keep	O
applications	O
using	O
DynamoDB	B-Application
running	O
smoothly	O
:	O
</s>
<s>
These	O
metrics	O
can	O
be	O
tracked	O
using	O
the	O
AWS	B-Application
Management	O
Console	O
,	O
using	O
the	O
AWS	B-Application
Command	B-Application
Line	I-Application
Interface	I-Application
,	O
or	O
a	O
monitoring	O
tool	O
integrating	O
with	O
Amazon	B-Application
CloudWatch	O
.	O
</s>
<s>
Languages	O
and	O
frameworks	O
with	O
a	O
DynamoDB	B-Application
binding	B-Application
include	O
Java	B-Language
,	O
JavaScript	B-Language
,	O
Node.js	B-Language
,	O
Go	B-Application
,	O
C#	B-Application
.NET	B-Application
,	O
Perl	B-Language
,	O
PHP	B-Application
,	O
Python	B-Language
,	O
Ruby	B-Language
,	O
Rust	B-Application
,	O
Haskell	B-Language
,	O
Erlang	B-Operating_System
,	O
Django	B-Language
,	O
and	O
Grails	B-Language
.	O
</s>
<s>
GetItem	O
in	O
Go:DeleteItem	O
in	O
Go	B-Application
:	O
in	O
Go	B-Application
using	O
:	O
</s>
