As we already know, DynamoDB is one of the go-to database services we can use for big data or we need to store and query large unstructured data. I have already explained the workings of DynamoDB here: DynamoDB, When and how to use it.
When working with DynamoDB, we need to keep some limitations and quotas in mind to make it more efficient and cost-effective.
Some limitations are listed below:
- Read and Write Units
- Table Limits
- Indexes
- Partition keys
- Related to DataTypes
Read and Write Units
Read Capacity Unit (RCU) – One strongly consistent read per second, or two eventually consistent reads per second, for items up to 4 KB in size.
Write capacity unit (WCU) – One write per second, for items up to 1 KB in size.
Table Limits
Size – When working with DynamoDB, the table size is practically unlimited. You can store as many items and as much data as needed without hitting any predefined limits
Number of Tables – There’s an initial allowance of up to 2,500 tables per AWS Region for each account. This quota provides much room for organizing your data across various services and applications.
Query & Scan limitation – When querying or scanning data from DynamoDB, there’s a page size limit of 1 MB per request. If your query or scan operation retrieves more than this limit, DynamoDB will return the initial set of matching items along with a LastEvaluatedKey property. This key can be utilized in a subsequent request to retrieve the next page of results, allowing you to efficiently handle large datasets within DynamoDB’s constraints.
Indexes
You can only define two primary indexes, consisting of one partition key and one sort key. And then for more flexibility, you can additionally define secondary indexes. Secondary indexes can be further divided into two parts:
Local Secondary Indexs(LSI): A maximum of five local secondary indexes (LSIs) can be defined per the DynamoDB table. LSIs are particularly valuable when an index requires strong consistency alignment with the base table, ensuring reliable and accurate data retrieval across indexed attributes.
Global Secondary Indexes(GSI): The default quota to create secondary indexes is 20. Secondary indexes are created independently of the base table and can work independently.
Projected secondary index attributes per table:
There is a limit of a total of 100 attributes that can be projected into local and global secondary indexes. This applies to only user-defined projected attributes.
Partition keys
- In DynamoDB, the partition key value can range from a minimum of 1 byte to a maximum of 2048 bytes in length. This flexibility allows for various types of data within the key structure.
- Furthermore, there are no significant constraints on the number of unique partition key values that can be utilized across tables or secondary indexes. This scalability ensures efficient data distribution and retrieval based on partition keys.
- Similarly, for sort key values, the length can vary from a minimum of 1 byte to a maximum of 1024 bytes, offering substantial versatility in data organization and sorting within DynamoDB.
- In most scenarios, there are virtually no practical limitations on the number of distinct sort key values per partition key value. However, it’s important to note that certain constraints apply, particularly in tables with secondary indexes, where specific guidelines may influence the number of permissible sort key values per partition key.
User Data Types:
Strings: For strings in DynamoDB, their length is limited by the maximum item size of 400 KB. These strings are encoded using Unicode with UTF-8 binary encoding, ensuring compatibility with various character sets and languages.
Numbers: When it comes to numbers, DynamoDB supports precision of up to 38 digits, accommodating both positive and negative values, as well as zero.
Binary: Binary data in DynamoDB is also subject to the 400 KB item size limit. Applications handling binary attributes must encode the data using base64 encoding before storing it in DynamoDB, ensuring efficient and reliable data transmission and storage.
There is no limit on the number of values in a list, map, or set, as long as the item that contains the values fits within the 400-KB item size limit.
For more information: AWS Service Quotas