We were exploring AWS service groups for a while with some generic description of each service, and sometimes a list of tips regarding which service should be chosen for a given situation. Today, while still being in the topic of AWS, we will do something a bit more specific. Since I’ve recently passed an AWS Certified Developer Associate exam (with 96% score, yay!), I’ve produced quite a lot of notes as I was preparing to the test. The most important service by far on the Developer exam is DynamoDB, so I’ve decided to extract those notes in particular, edit them to be not-me-only-readable, and here we are.
This is not intended to be a description of DynamoDB, an introduction nor developer guide. The idea is to pinpoint the exact topics that are covered on an actual exam. During preparations, I went through probably over a thousand of questions in various practice / mock exams available here and there. A lot of questions were duplicated, and a lot of them was later on the actual exam, so this should give you a good overview of what to expect. In order to actually get to know DynamoDB, not only get the paper, it is recommended to get your hands dirty and play with it, at least from AWS console, if not from application code. It is also highly recommended to read FAQ. DynamoDB FAQ is damn long. There are questions that are not covered by FAQ, but come somewhere from the documentation, which is larger than the FAQ itself by one or two orders of magnitude. Learning everything by heart is basically impossible, so how the hell pass the damn thing you would ask? Keep calm and read the article. Those are the essential things you should know about DynamoDB when attempting AWS Certified Developer Associate exam.
- DynamoDB is not part of RDS, it’s a separate service.
- It’s managed, you can’t SSH into it.
- Stored on SSD.
- Uses optimistic concurrency control.
- Stored in 3 different locations.
- Suited for both small and large-scale applications.
- Does not support joins and complex queries, use RDS if it is required.
- Consistency is reached within 1 s with eventually consistent model.
- Unless Amazon explicitly mentions an eventually consistent read, they are referring to a strongly consistent read.
- Read capacity units required = item size / 4KB, round up, half that for eventually consistent reads, round up again.
- Write capacity units required = item size / 1KB, round up.
- UpdateTable operations do not consume throughput.
- ProvisionedThroughputExceededException error may be cause by exceeding individual partition (it’s then called a “hot partition”) throughput or global secondary index.
- Write throughput cost 0.0065$ per hour for every 10 units.
- Read throughput cost 0.0065$ per hour for every 50 units.
- Minimum throughput that can be provisioned to table: 1 read and 1 write.
- Free tier allows 25 read and 25 write units.
- Minimum reserved throughput: 100 units.
Query and Scan
- Query uses primary key to get item, scan examines every item in the table.
- Query is more efficient than scan.
- Query, Scan, GetItem, and BatchGetItem are the DynamoDB read operations.
- Query results are sorted ascending by sort key. To reverse the sort order, set the ScanIndexForward parameter to false.
- Single query can retrieve up to 1MB of data.
- Scan returns all attributes by default, but ProjectionExpression can be used to restrict that.
- After reaching 1 MB of data, aside from items, scan returns LastEvaluatedKey value to enable subsequent scan from this item on.
- The Limit parameter can be used to reduce page size and thus scan impact on provisioned table throughput.
- A local secondary index is an index that has the same partition key as the table, but a different sort key.
- Local secondary Index cannot be added after table creation.
- Global secondary index has different partition key than the table.
- Global secondary index can be added after table creation.
- Global secondary indexes have separate throughput from the table.
- It’s impossible to create multiple tables with secondary indexes concurrently, LimitExceededException is returned.
- Maximum 5 local secondary indexes and global secondary indexes per table.
- Maximum 20 projected attributes in all indexes per table.
- Range primary indexes should be created on field with well distributed values.
- Maximum 100 items and 16 MB for a single BatchGetItem.
- Maximum 25 PutItem or DeleteItem request in single BatchWriteItem request, maximum total size of written items: 16 MB.
- Maximum 3000 read capacity units / 1000 write units per partition.
- Maximum 10000 read / write capacity units per table (40000 in US East).
- Maximum 20000 read / write capacity units per account (80000 in US East).
- Maximum object size: 400 KB.
- Maximum 256 tables per region.
- Sort key length is between 1 and 1024 bytes.
- Partition key length is between 1 and 2048 bytes.
- ListTables can return a maximum of 100 table names in single request. Use pagination if there are more tables.
- Item can have an unlimited number attributes.
- Maximum partition size: 10 GB.
- Number of tables and provisioned throughput limit can be raised by contacting AWS support.
- Maximum name length for attributes being secondary index partition/sort key names or projected attributes: 255 characters.
- Maximum name length for the rest of attributes: 64KB.
- Maximum Number length: 38 digits.
- Maximum Expression length: 4kB.
- Data plane operations are for CRUD operations, Control plane are for management, indexes streams etc.
- The BatchWriteItem operation puts or deletes multiple items in one or more tables. When called in a loop, it also checks for unprocessed items and submits a new BatchWriteItem request with those unprocessed items until all items have been processed.
- Conditional writes are allowed in PutItem, UpdateIem and DeleteItem.
- Use conditional writes to assure consistency and atomic counters if it’s not critical.
- Conditional writes are idempotent, atomic counters are not.
- While table is in UPDATING state another UpdateTable cannot be performed.
- GetItem returns an item that matches the primary key.
- No two items can have the same primary key value.
- Primary key can be of single attribute: partition or composite: partition + sort.
- Hash and range keys are the same as composite and sort key respectively.
- DynamoDB streams capture modifications of objects, including “before” and “after”, changes last 24 hours.
- FGAC = Fine-Grained Access Control.
- First 25 GB of storage is free.
- Storage costs of 25 cents per additional GB per Month.
- Attributes can be nested up to 32 deep.
- XOR is not allowed as logical operator in query.
- ItemCollectionSizeLimitExceededException error is returned if size of items in one partition exceeds 10GB.
- If your table size grows beyond 10 GB, DynamoDB will spread your data across additional partitions, and will also distribute your table’s read and write throughput accordingly.
That’s it, more or less. This is the distilled essence of DynamoDB and notes to browse through last minute before the exam. Make sure that you know how to calculate required throughput, since there will probably be few questions about that. If you have anything to add or found some mistakes, don’t hesitate to comment or contact me in any way. Keep In mind that things changes and questions and guides are getting obsolete, for example maximum BatchWriteItem is often given as 1MB instead of the actual 16MB.
In the next episode, I will go into more details about the entire exam, how it looks, what to expect and I will break down exactly how I was preparing to it, including list of materials and a bunch of tips. Stay tuned.