API Gateway & Dynamo DB Flashcards
Can you use mapping templates when you have the proxy setting enabled?
No
What is the difference between provisioned and on-demand mode for DynamoDB?
Provisioned (default) - you specify the number of reads/writes per second, plan capacity beforehand, pay for provisioned units.
On-demand - read/writes automatically scale with your workloads. No planning needed but more expensive.
What is one write capacity unit (WCU) in DynamoDB?
Represents one write per second for an item up to 1KB in size (rounded up to the nearest whole KB)
Work out the number of write capacity units needed to write 6 items per second into DynamoDB each with a size of 1.5KB
6 x 2 = 12 1.5KB would be rounded up to 2KB (because amazon are money greedy bastards)
Work out the number of write capacity units needed to write 120 items per minute into DynamoDB each with a size of 2KB
120/60 x 2 = 4
What are the two “modes” for reading items from DynamoDB (in the context of consistency)
Eventually consistent read (default) - if we read straight after a write we might get stale data as replication may not complete in time.
Strongly consistent read - reading always up-to-date data, this is done via a parameter in the api call, consumes twice the RCU (read capacity units).
What does one read capacity unit represent in DynamoDB?
Represents one strongly consistent read per second or two eventually consistent reads per second, for an item up to 4KB in size.
Work out the number of read capacity units for 10 strongly consistent reads per second, with an item size of 4KB
10 RCUs
Work out the number of read capacity units for 16 eventually consistent reads per second with an item size of 12KB
We need (16/2) x (12kb / 4kb) = 24 RCUs
What is the difference between the PutItem and UpdateItem api calls to DynamoDB?
PutItem creates or replaces an item (based on primary key) whereas UpdateItem edits a subset of an existing items attributes.
What is the most efficient way to delete all the items in a DynamoDB table?
Use the DeleteTable api call, do not use the DeleteItem with a scan
In DynamoDB when using batch operations what happens if one operation in a batch fails?
The whole batch does not roll back, just the parts that failed are returned as failed, the client can then retry just those failed operations.
What is PartiQL?
SQL compatible query language for DynamoDB (without joins)
What is DynamoDB Accelerator (DAX)?
In memory cache for DynamoDB
What can be cached in a DAX?
Individual objects, queries / scans
When might you use ElastiCache instead of DAX?
Storing the result of computed data
What are DynamoDB Streams?
Ordered stream of item-level modifications (create/update/delete) in a table
Where can DynamoDB Streams be sent?
Kinesis Data Streams, Lambda, Kinesis Client Library apps
When DynamoDB automatically deletes an item that had a TTL attribute set are any WCUs consumed?
No, no extra cost
How quickly do expired DynamoDB items (using TTL) get deleted?
Within 48 hours
When using transactions in DynamoDB how many more capacity units are used?
Twice as many
Work out how many WCUs are needed for 3 transactional writes per second, with an item size of 5Kb
3 x (5Kb / 1Kb) x 2 (transactional cost) = 30WCUs
Work out how many RCUs are needed for 5 transactional reads per second, with an item size of 8Kb
5 x (8Kb / 4Kb) x 2 (transactional cost) = 20RCUs
What is the difference between using DynamoDB vs ElastiCache as session state cache (user logins)
ElastiCache is in memory. DynamoDB is serverless and auto scales. Both are key/value stores.