Tags Archives: dynamodb

AWS DynamoDB

DynamoDB is a fully managed, highly-available database with replication across multiple AZs

 

NoSQL – not a relational database!

 

scales to massive workloads

 

100TBs of storage

 

fast and consistence, low latency retrieval

 

integrated with iam for security authorization and admin
enables event-driven programming via DynamoDB Streams

 

low cost and auto-scaling

 

standard and infrequent access 1A table class

 

 

Basics of DynamoDB

 

 

v important – also exam q:
made up of tables – there is NO SUCH THING AS A DATABASE – you only need to create tables!
the db already exists!

 

each table has a primary key – must be set at creation time
each table can have an infinite number of items ie rows
each item has attributes can be added over time or can be null

 

max size of an item is 400KB so not good for large objects

 

data types supported are:

 

scalar types: string, number, binary, boolean, null
document types: list, map
set types: string set, number set, binary set

 

tables:

 

have primary key – containing partition key (eg user_id) and sort key (eg game_id)
and
attributes: eg score, result – these are items which are NOT the primary key

 

read/write capacity modes

 

control how you manage your table capacity – ie the read and write throughput

 

we have 2 possible modes:

 

provisioned mode, where you specify number of read and writes per second, this is the default, you have to plan the capacity for this in advance, you pay for provisioned read capacity units RCUs and write capacity units (WCUs)

 

these “capacity units” are used to set your desired capacity for your database! – set these in the web dashboard of dynamodb when you are provisioning.

 

 

you can also add auto scaling mode for both rcu and wcu

 

on-demand mode:

read write automatically scales up and down acc to workload, so no capacity planning needed
you pay for your use, is more expensive 2-3x more

 

good for unpredictable workloads which can be large or small varying

 

need to know for exam!

 

remember always you just create tables, never a database with dynamodb!

 

DynamoDB Accelerator DAX

 

 

a fully manageable, highly available seamless in-memory cache for dynamodb

 

helps solve read congestion by means of memory caching

 

microseconds latency for cached data

 

does not require any application logic modification – so it is fully compatible with existing dynamodb api

 

applications can access the database via DAX for much faster reads

 

TTL is 5 mins default for dax data

dax is different from elasticache in that it is meant for dynamodb and does not change the api
food for individual object cache

 

elasticache
good for storing aggregation result where further processing required

 

 

DynamoDB Stream

 

very easy – is an ordered stream of data which represents items when created or updated or deleted

 

can then be sent on to kinesis datastreams
can be read by lambda or kinesis client library apps

 

data is retained for 24 hrs

 

 

use cases:

 

reacting to changes in real time eg welcome emails to new users
to do analytics
to insert into derivative tables or into elastic serarch
or implement cross region replication

 

 

DynamoDB Global Tables

 

 

are cross-region

 

two way or multi-way replication

 

to provide for low latency across regions

 

it is
active-active replication

 

this means apps can read and write to the table from any region

 

must enable dynamodb streams for this

 

TTL expiry: automatically deletes items after an expiry timestamp

 

eg 1 month for each row in the table

 

 

DynamoDB Indexes – only need to know at high level for exam

 

basically, these allow you to query on attributes other than the primary key

 

2 types:

 

gsi – global secondary and lsi – local secondary

 

(all you need to know for now)

 

by default you query on the primary key, but you can use gsi or lsi to query on other attributes.

 

 

Transactions

 

these allow you to write to 2 tables at the same time:

 

the transaction however MUST write to both or else none – in order to keep the tables accurate – so data consistency is maintained

 

 

 

 

 

 

 

 

Continue Reading