Database | Amazon DynamoDB Flashcards
What is Amazon DynamoDB?
What is Amazon DynamoDB?
Amazon DynamoDB | Database
Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. DynamoDB enables customers to offload the administrative burdens of operating and scaling distributed databases to AWS so that they don’t have to worry about hardware provisioning, setup and configuration, throughput capacity planning, replication, software patching, or cluster scaling.
What does Amazon DynamoDB manage on my behalf?
What is Amazon DynamoDB?
Amazon DynamoDB | Database
Amazon DynamoDB takes away one of the main stumbling blocks of scaling databases: the management of database software and the provisioning of the hardware needed to run it. You can deploy a nonrelational database in a matter of minutes. DynamoDB automatically scales throughput capacity to meet workload demands and partitions and repartitions your data as your table size grows. In addition, DynamoDB synchronously replicates data across three facilities in an AWS Region, giving you high availability and data durability.
What does read consistency mean? Why should I care?
What is Amazon DynamoDB?
Amazon DynamoDB | Database
Amazon DynamoDB stores three geographically distributed replicas of each table to enable high availability and data durability. Read consistency represents the manner and timing in which the successful write or update of a data item is reflected in a subsequent read operation of that same item. DynamoDB exposes logic that enables you to specify the consistency characteristics you desire for each read request within your application.
What is the consistency model of Amazon DynamoDB?
What is Amazon DynamoDB?
Amazon DynamoDB | Database
When reading data from Amazon DynamoDB, users can specify whether they want the read to be eventually consistent or strongly consistent:
Eventually consistent reads (Default) – The eventual consistency option maximizes your read throughput. However, an eventually consistent read might not reflect the results of a recently completed write. Consistency across all copies of data is usually reached within a second. Repeating a read after a short time should return the updated data.
Strongly consistent reads — In addition to eventual consistency, Amazon DynamoDB also gives you the flexibility and control to request a strongly consistent read if your application, or an element of your application, requires it. A strongly consistent read returns a result that reflects all writes that received a successful response prior to the read.
Does DynamoDB support in-place atomic updates?
What is Amazon DynamoDB?
Amazon DynamoDB | Database
Amazon DynamoDB supports fast, in-place updates. You can increment or decrement a numeric attribute in a row using a single API call. Similarly, you can atomically add or remove sets, lists, or maps. For more information about atomic updates, see Atomic Counters.
Why is Amazon DynamoDB built on solid-state drives?
What is Amazon DynamoDB?
Amazon DynamoDB | Database
Amazon DynamoDB runs exclusively on solid-state drives (SSDs). SSDs help AWS achieve the design goals of predictable low-latency response times for storing and accessing data at any scale. The high I/O (high reads/second and writes/second) performance of SSDs also enables us to serve high-scale request workloads cost-efficiently, and to pass this efficiency along in low request pricing.
The storage cost of DynamoDB seems high. Is this a cost-effective service?
What is Amazon DynamoDB?
Amazon DynamoDB | Database
As with any product, we encourage potential customers of Amazon DynamoDB to consider the total cost of a solution, not just a single pricing dimension. The total cost of servicing a database workload is a function of the request traffic requirements and the amount of data stored. Most database workloads are characterized by a requirement for high I/O (high reads/second and writes/second) per GB stored. DynamoDB is built on SSD drives, which raises the cost per GB stored, relative to spinning media, but it also allows us to offer very low request costs. Based on what we see in typical database workloads, we believe that the total bill for using SSD-based DynamoDB will usually be lower than the cost of using a typical spinning media-based relational or nonrelational database. If you need to store a large amount of data that you rarely access, DynamoDB may not be right for you. We recommend that you use Amazon S3 for such use cases.
You also should note that the storage cost reflects the cost of storing multiple copies of each data item across multiple facilities in an AWS Region.
Is DynamoDB only for high-scale applications?
Getting started
Amazon DynamoDB | Database
No. Amazon DynamoDB offers seamless scaling so that you can scale automatically as your application requirements increase. If you need fast, predictable performance at any scale, DynamoDB may be the right choice for you.
How do I get started with Amazon DynamoDB?
Getting started
Amazon DynamoDB | Database
Click “Sign Up” to get started with Amazon DynamoDB today. From there, you can begin interacting with Amazon DynamoDB using either the AWS Management Console or Amazon DynamoDB APIs. If you are using the AWS Management Console, you can create a table with Amazon DynamoDB and begin exploring with just a few clicks.
What kind of query functionality does DynamoDB support?
Getting started
Amazon DynamoDB | Database
Amazon DynamoDB supports GET/PUT operations using a user-defined primary key. The primary key is the only required attribute for items in a table and it uniquely identifies each item. You specify the primary key when you create a table. In addition to that DynamoDB provides flexible querying by letting you query on non-primary key attributes using Global Secondary Indexes and Local Secondary Indexes.
A primary key can either be a single-attribute partition key or a composite partition-sort key. A single attribute partition primary key could be, for example, “UserID”. This would allow you to quickly read and write data for an item associated with a given user ID.
A composite partition-sort key is indexed as a partition key element and a sort key element. This multi-part key maintains a hierarchy between the first and second element values. For example, a composite partition-sort key could be a combination of “UserID” (partition) and “Timestamp” (sort). Holding the partition key element constant, you can search across the sort key element to retrieve items. This would allow you to use the Query API to, for example, retrieve all items for a single UserID across a range of timestamps.
For more information on Global Secondary Indexing and its query capabilities, see the Secondary Indexes section in FAQ.
How do I update and query data items with Amazon DynamoDB?
Getting started
Amazon DynamoDB | Database
After you have created a table using the AWS Management Console or CreateTable API, you can use the PutItem or BatchWriteItem APIs to insert items. Then you can use the GetItem, BatchGetItem, or, if composite primary keys are enabled and in use in your table, the Query API to retrieve the item(s) you added to the table.
Does Amazon DynamoDB support conditional operations?
Getting started
Amazon DynamoDB | Database
Yes, you can specify a condition that must be satisfied for a put, update, or delete operation to be completed on an item. To perform a conditional operation, you can define a ConditionExpression that is constructed from the following:
Boolean functions: ATTRIBUTE_EXIST, CONTAINS, and BEGINS_WITH
Comparison operators: =, <>, , <=, >=, BETWEEN, and IN
Logical operators: NOT, AND, and OR.
You can construct a free-form conditional expression that combines multiple conditional clauses, including nested clauses. Conditional operations allow users to implement optimistic concurrency control systems on DynamoDB. For more information on conditional operations, please see our documentation.
Are expressions supported for key conditions?
Getting started
Amazon DynamoDB | Database
Yes, you can specify an expression as part of the Query API call to filter results based on values of primary keys on a table using the KeyConditionExpression parameter.
Are expressions supported for partition and partition-sort keys?
Getting started
Amazon DynamoDB | Database
Yes, you can use expressions for both partition and partition-sort keys. Refer to the documentation page for more information on which expressions work on partition and partition-sort keys.
Does Amazon DynamoDB support increment or decrement operations?
Getting started
Amazon DynamoDB | Database
Yes, Amazon DynamoDB allows atomic increment and decrement operations on scalar values.
When should I use Amazon DynamoDB vs a relational database engine on Amazon RDS or Amazon EC2?
Getting started
Amazon DynamoDB | Database
Today’s web-based applications generate and consume massive amounts of data. For example, an online game might start out with only a few thousand users and a light database workload consisting of 10 writes per second and 50 reads per second. However, if the game becomes successful, it may rapidly grow to millions of users and generate tens (or even hundreds) of thousands of writes and reads per second. It may also create terabytes or more of data per day. Developing your applications against Amazon DynamoDB enables you to start small and simply dial-up your request capacity for a table as your requirements scale, without incurring downtime. You pay highly cost-efficient rates for the request capacity you provision, and let Amazon DynamoDB do the work over partitioning your data and traffic over sufficient server capacity to meet your needs. Amazon DynamoDB does the database management and administration, and you simply store and request your data. Automatic replication and failover provides built-in fault tolerance, high availability, and data durability. Amazon DynamoDB gives you the peace of mind that your database is fully managed and can grow with your application requirements.
While Amazon DynamoDB tackles the core problems of database scalability, management, performance, and reliability, the datamodel, just like any NoSQL, must be designed specifically for the access patterns required by the application. In other words, running adhoc queries on DynamoDB can be inefficient. Refer to the design guidance that shows how to effectively migrate from any Relational database to DynamoDB. If your workload requires this functionality, or you are looking for compatibility with an existing relational engine, you may wish to run a relational engine on Amazon RDS or Amazon EC2. While relational database engines provide robust features and functionality, scaling a workload beyond a single relational database instance is highly complex and requires significant time and expertise. As such, if you anticipate scaling requirements for your new application and do not need relational features, Amazon DynamoDB may be the best choice for you.
How does Amazon DynamoDB differ from Amazon SimpleDB?
Getting started
Amazon DynamoDB | Database
Which should I use? Both services are non-relational databases that remove the work of database administration. Amazon DynamoDB focuses on providing seamless scalability and fast, predictable performance. It runs on solid state disks (SSDs) for low-latency response times, and there are no limits on the request capacity or storage size for a given table. This is because Amazon DynamoDB automatically partitions your data and workload over a sufficient number of servers to meet the scale requirements you provide. In contrast, a table in Amazon SimpleDB has a strict storage limitation of 10 GB and is limited in the request capacity it can achieve (typically under 25 writes/second); it is up to you to manage the partitioning and re-partitioning of your data over additional SimpleDB tables if you need additional scale. While SimpleDB has scaling limitations, it may be a good fit for smaller workloads that require query flexibility. Amazon SimpleDB automatically indexes all item attributes and thus supports query flexibility at the cost of performance and scale.
Amazon CTO Werner Vogels’ DynamoDB blog post provides additional context on the evolution of non-relational database technology at Amazon.
When should I use Amazon DynamoDB vs Amazon S3?
Getting started
Amazon DynamoDB | Database
Amazon DynamoDB stores structured data, indexed by primary key, and allows low latency read and write access to items ranging from 1 byte up to 400KB. Amazon S3 stores unstructured blobs and suited for storing large objects up to 5 TB. In order to optimize your costs across AWS services, large objects or infrequently accessed data sets should be stored in Amazon S3, while smaller data elements or file pointers (possibly to Amazon S3 objects) are best saved in Amazon DynamoDB.
Can DynamoDB be used by applications running on any operating system?
Data models and APIs
Amazon DynamoDB | Database
Yes. DynamoDB is a fully managed cloud service that you access via API. DynamoDB can be used by applications running on any operating system (e.g. Linux, Windows, iOS, Android, Solaris, AIX, HP-UX, etc.). We recommend using the AWS SDKs to get started with DynamoDB. You can find a list of the AWS SDKs on our Developer Resources page. If you have trouble installing or using one of our SDKs, please let us know by posting to the relevant AWS Forum.
What is the Data Model?
Data models and APIs
Amazon DynamoDB | Database
The data model for Amazon DynamoDB is as follows:
Table: A table is a collection of data items – just like a table in a relational database is a collection of rows. Each table can have an infinite number of data items. Amazon DynamoDB is schema-less, in that the data items in a table need not have the same attributes or even the same number of attributes. Each table must have a primary key. The primary key can be a single attribute key or a “composite” attribute key that combines two attributes. The attribute(s) you designate as a primary key must exist for every item as primary keys uniquely identify each item within the table.
Item: An Item is composed of a primary or composite key and a flexible number of attributes. There is no explicit limitation on the number of attributes associated with an individual item, but the aggregate size of an item, including all the attribute names and attribute values, cannot exceed 400KB.
Attribute: Each attribute associated with a data item is composed of an attribute name (e.g. “Color”) and a value or set of values (e.g. “Red” or “Red, Yellow, Green”). Individual attributes have no explicit size limit, but the total value of an item (including all attribute names and values) cannot exceed 400KB.
Is there a limit on the size of an item?
Data models and APIs
Amazon DynamoDB | Database
The total size of an item, including attribute names and attribute values, cannot exceed 400KB. Refer to the design guidance for using ‘Composite Sort Keys’ to design for items that exceed the 400K limit.
Is there a limit on the number of attributes an item can have?
Data models and APIs
Amazon DynamoDB | Database
There is no limit to the number of attributes that an item can have. However, the total size of an item, including attribute names and attribute values, cannot exceed 400KB.
What are the APIs?
Data models and APIs
Amazon DynamoDB | Database
CreateTable – Creates a table and specifies the primary index used for data access.
UpdateTable – Updates the provisioned throughput values for the given table.
DeleteTable – Deletes a table.
DescribeTable – Returns table size, status, and index information.
ListTables – Returns a list of all tables associated with the current account and endpoint.
PutItem – Creates a new item, or replaces an old item with a new item (including all the attributes). If an item already exists in the specified table with the same primary key, the new item completely replaces the existing item. You can also use conditional operators to replace an item only if its attribute values match certain conditions, or to insert a new item only if that item doesn’t already exist.
BatchWriteItem – Inserts, replaces, and deletes multiple items across multiple tables in a single request, but not as a single transaction. Supports batches of up to 25 items to Put or Delete, with a maximum total request size of 16 MB.
UpdateItem – Edits an existing item’s attributes. You can also use conditional operators to perform an update only if the item’s attribute values match certain conditions.
DeleteItem – Deletes a single item in a table by primary key. You can also use conditional operators to perform a delete an item only if the item’s attribute values match certain conditions.
GetItem – The GetItem operation returns a set of Attributes for an item that matches the primary key. The GetItem operation provides an eventually consistent read by default. If eventually consistent reads are not acceptable for your application, use ConsistentRead.
BatchGetItem – The BatchGetItem operation returns the attributes for multiple items from multiple tables using their primary keys. A single response has a size limit of 16 MB and returns a maximum of 100 items. Supports both strong and eventual consistency.
Query – Gets one or more items using the table primary key, or from a secondary index using the index key. You can narrow the scope of the query on a table by using comparison operators or expressions. You can also filter the query results using filters on non-key attributes. Supports both strong and eventual consistency. A single response has a size limit of 1 MB.
Scan – Gets all items and attributes by performing a full scan across the table or a secondary index. You can limit the return set by specifying filters against one or more attributes.
What is the consistency model of the Scan operation?
Data models and APIs
Amazon DynamoDB | Database
The Scan operation supports eventually consistent and consistent reads. By default, the Scan operation is eventually consistent. However, you can modify the consistency model using the optional ConsistentRead parameter in the Scan API call. Setting the ConsistentRead parameter to true will enable you make consistent reads from the Scan operation. For more information, read the documentation for the Scan operation.
How does the Scan operation work?
Data models and APIs
Amazon DynamoDB | Database
You can think of the Scan operation as an iterator. Once the aggregate size of items scanned for a given Scan API request exceeds a 1 MB limit, the given request will terminate and fetched results will be returned along with a LastEvaluatedKey (to continue the scan in a subsequent operation).
Are there any limitations for a Scan operation?
Data models and APIs
Amazon DynamoDB | Database
A Scan operation on a table or secondary index has a limit of 1MB of data per operation. After the 1MB limit, it stops the operation and returns the matching values up to that point, and a LastEvaluatedKey to apply in a subsequent operation, so that you can pick up where you left off.
How many read capacity units does a Scan operation consume?
Data models and APIs
Amazon DynamoDB | Database
The read units required is the number of bytes fetched by the scan operation, rounded to the nearest 4KB, divided by 4KB. Scanning a table with consistent reads consumes twice the read capacity as a scan with eventually consistent reads.
What data types does DynamoDB support?
Data models and APIs
Amazon DynamoDB | Database
DynamoDB supports four scalar data types: Number, String, Binary, and Boolean. Additionally, DynamoDB supports collection data types: Number Set, String Set, Binary Set, heterogeneous List and heterogeneous Map. DynamoDB also supports NULL values.
What types of data structures does DynamoDB support?
Data models and APIs
Amazon DynamoDB | Database
DynamoDB supports key-value and document data structures.
What is a key-value store?
Data models and APIs
Amazon DynamoDB | Database
A key-value store is a database service that provides support for storing, querying and updating collections of objects that are identified using a key and values that contain the actual content being stored.
What is a document store?
Data models and APIs
Amazon DynamoDB | Database
A document store provides support for storing, querying and updating items in a document format such as JSON, XML, and HTML.
Does DynamoDB have a JSON data type?
Data models and APIs
Amazon DynamoDB | Database
No, but you can use the document SDK to pass JSON data directly to DynamoDB. DynamoDB’s data types are a superset of the data types supported by JSON. The document SDK will automatically map JSON documents onto native DynamoDB data types.
Can I use the AWS Management Console to view and edit JSON documents?
Data models and APIs
Amazon DynamoDB | Database
Yes. The AWS Management Console provides a simple UI for exploring and editing the data stored in your DynamoDB tables, including JSON documents. To view or edit data in your table, please log in to the AWS Management Console, choose DynamoDB, select the table you want to view, then click on the “Explore Table” button.
Is querying JSON data in DynamoDB any different?
Data models and APIs
Amazon DynamoDB | Database
No. You can create a Global Secondary Index or Local Secondary Index on any top-level JSON element. For example, suppose you stored a JSON document that contained the following information about a person: First Name, Last Name, Zip Code, and a list of all of their friends. First Name, Last Name and Zip code would be top-level JSON elements. You could create an index to let you query based on First Name, Last Name, or Zip Code. The list of friends is not a top-level element, therefore you cannot index the list of friends. For more information on Global Secondary Indexing and its query capabilities, see the Secondary Indexes section in this FAQ.
If I have nested JSON data in DynamoDB, can I retrieve only a specific element of that data?
Data models and APIs
Amazon DynamoDB | Database
Yes. When using the GetItem, BatchGetItem, Query, or Scan APIs, you can define a ProjectionExpression to determine which attributes should be retrieved from the table. Those attributes can include scalars, sets, or elements of a JSON document.
If I have nested JSON data in DynamoDB, can I update only a specific element of that data?
Scalability, availability, and durability
Amazon DynamoDB | Database
Yes. When updating a DynamoDB item, you can specify the sub-element of the JSON document that you want to update.
Q:What is the Document SDK?
The Document SDK is a datatypes wrapper for JavaScript that allows easy interoperability between JS and DynamoDB datatypes. With this SDK, wrapping for requests will be handled for you; similarly for responses, datatypes will be unwrapped. For more information and downloading the SDK see our GitHub respository here.
Is there a limit to how much data I can store in Amazon DynamoDB?
Scalability, availability, and durability
Amazon DynamoDB | Database
No. There is no limit to the amount of data you can store in an Amazon DynamoDB table. As the size of your data set grows, Amazon DynamoDB will automatically spread your data over sufficient machine resources to meet your storage requirements.
Is there a limit to how much throughput I can get out of a single table?
Scalability, availability, and durability
Amazon DynamoDB | Database
No, you can increase the maximum capacity limit setting for Auto Scaling or increase the throughput you have manually provisioned for your table using the API or the AWS Management Console. DynamoDB is able to operate at massive scale and there is no theoretical limit on the maximum throughput you can achieve. DynamoDB automatically divides your table across multiple partitions, where each partition is an independent parallel computation unit. DynamoDB can achieve increasingly high throughput rates by adding more partitions.
If you wish to exceed throughput rates of 10,000 writes/second or 10,000 reads/second, you must first contact Amazon through this online form.
Does Amazon DynamoDB remain available when Auto Scaling triggers scaling or when I ask it to scale up or down by changing the provisioned throughput?
Scalability, availability, and durability
Amazon DynamoDB | Database
Yes. Amazon DynamoDB is designed to scale its provisioned throughput up or down while still remaining available, whether managed by Auto Scaling or manually.
Do I need to manage client-side partitioning on top of Amazon DynamoDB?
Scalability, availability, and durability
Amazon DynamoDB | Database
No. Amazon DynamoDB removes the need to partition across database tables for throughput scalability.
How highly available is Amazon DynamoDB?
Scalability, availability, and durability
Amazon DynamoDB | Database
The service runs across Amazon’s proven, high-availability data centers. The service replicates data across three facilities in an AWS Region to provide fault tolerance in the event of a server failure or Availability Zone outage.
How does Amazon DynamoDB achieve high uptime and durability?
Auto Scaling
Amazon DynamoDB | Database
To achieve high uptime and durability, Amazon DynamoDB synchronously replicates data across three facilities within an AWS Region.
What is DynamoDB Auto Scaling?
Auto Scaling
Amazon DynamoDB | Database
DynamoDB Auto Scaling is a fully managed feature that automatically scales up or down provisioned read and write capacity of a DynamoDB table or a global secondary index, as application requests increase or decrease.
Why do I need to use Auto Scaling?
Auto Scaling
Amazon DynamoDB | Database
Auto Scaling eliminates the guesswork involved in provisioning adequate capacity when creating new tables and reduces the operational burden of continuously monitoring consumed throughput and adjusting provisioned capacity manually. Auto Scaling helps ensure application availability and reduces costs from unused provisioned capacity.
What application request patterns and workload are suited for Auto Scaling?
Auto Scaling
Amazon DynamoDB | Database
Auto Scaling is ideally suited for request patterns that are uniform, predictable, with sustained high and low throughput usage that lasts for several minutes to hours.
How can I enable Auto Scaling for a DynamoDB table or global secondary index?
Auto Scaling
Amazon DynamoDB | Database
From the DynamoDB console, when you create a new table, leave the ‘Use default settings’ option checked, to enable Auto Scaling and apply the same settings for global secondary indexes for the table. If you uncheck ‘Use default settings’, you can either set provisioned capacity manually or enable Auto Scaling with custom values for target utilization and minimum and maximum capacity. For existing tables, you can enable Auto Scaling or change existing Auto Scaling settings by navigating to the ‘Capacity’ tab and for indexes, you can enable Auto Scaling from under the ‘Indexes’ tab. Auto Scaling can also be programmatically managed using CLI or AWS SDK. Please refer to the DynamoDB developer guide to learn more.
What are settings I can configure for Auto Scaling?
Auto Scaling
Amazon DynamoDB | Database
There are three configurable settings for Auto Scaling: Target Utilization, the percentage of actual consumed throughput to total provisioned throughput, at a point in time, the Minimum capacity to which Auto Scaling can scale down to, and Maximum capacity, to which the Auto Scaling can scale up to. The default value for Target Utilization is 70% (allowed range is 20% - 80% in one percent increments), minimum capacity is 1 unit and maximum capacity is the table limit for your account in the region. Please refer to the Limits in DynamoDB page for region-level default table limits.
Can I change the settings of an existing Auto Scaling policy?
Auto Scaling
Amazon DynamoDB | Database
Yes, you can change the settings of an existing Auto Scaling policy at any time, by navigating to the ‘Capacity’ tab in the management console or programmatically from the CLI or SDK using the AutoScaling APIs.
How does Auto Scaling work?
Auto Scaling
Amazon DynamoDB | Database
When you create a new Auto Scaling policy for your DynamoDB table, Amazon CloudWatch alarms are created with thresholds for target utilization you specify, calculated based on consumed and provisioned capacity metrics published to CloudWatch. If the table’s actual utilization deviates from target for a specific length of time, the CloudWatch alarms activates Auto Scaling, which evaluates your policy and in turn makes an UpdateTable API request to DynamoDB to dynamically increase (or decrease) the table’s provisioned throughput capacity to bring the actual utilization closer to the target.
Can I enable a single Auto Scaling policy across multiple tables in multiple regions?
Auto Scaling
Amazon DynamoDB | Database
No, an Auto Scaling policy can only be set to a single table or a global secondary indexes within a single region.
Can I force an Auto Scaling policy to scale up to maximum capacity or scale down to minimum capacity instantly?
Auto Scaling
Amazon DynamoDB | Database
No, scaling up instantly to maximum capacity or scaling down to minimum capacity is not supported. Instead, you can temporarily disable Auto Scaling, set desired capacity you need manually for required duration, and re-enable Auto Scaling later.
Where can I monitor the scaling actions triggered by Auto Scaling?
Auto Scaling
Amazon DynamoDB | Database
You can monitor status of scaling actions triggered by Auto Scaling under the ‘Capacity’ tab in the management console and from CloudWatch graphs under the ‘Metrics’ tab.
How can I tell if a table has an active Auto Scaling policy or not?
Auto Scaling
Amazon DynamoDB | Database
From the DynamoDB console, click on Tables in the left menu, to bring up the list view of all DynamoDB tables in your account. For tables with an active Auto Scaling policy, the ‘Auto Scaling’ column shows either READ_CAPACITY, WRITE_CAPACITY or READ_AND_WRITE depending on whether Auto Scaling is enabled for read or write or both. Additionally, under the ‘Table details’ section of the ‘Overview’ tab of a table, the provisioned capacity label shows whether Auto Scaling is enabled for read, write or both.
What happens to the Auto Scaling policy when I delete a table or global secondary index with an active policy?
Auto Scaling
Amazon DynamoDB | Database
When you delete a table or global secondary index from the console, its Auto Scaling policy and supporting Cloud Watch alarms are also deleted.
Are there any additional costs to use Auto Scaling?
Auto Scaling
Amazon DynamoDB | Database
No, there are no additional cost to using Auto Scaling, beyond what you already pay for DynamoDB and CloudWatch alarms. To learn about DynamoDB pricing, please visit the DynamoDB pricing page.
How does throughput capacity managed by Auto Scaling work with my Reserved Capacity?
Global secondary indexes
Amazon DynamoDB | Database
Auto Scaling works with reserved capacity in the same manner as manually provisioned throughput capacity does today. Reserved Capacity is applied to the total provisioned capacity for the region you purchased it in. Capacity provisioned by Auto Scaling will consume the reserved capacity first, billed at discounted prices, and any excess capacity will be charged at standard rates. To limit total consumption to the reserved capacity you purchased, distribute maximum capacity limit across all tables with Auto Scaling enabled, to be cumulatively less than total reserved capacity amount you have purchased.
What are global secondary indexes?
Global secondary indexes
Amazon DynamoDB | Database
Global secondary indexes are indexes that contain a partition or partition-and-sort keys that can be different from the table’s primary key.
For efficient access to data in a table, Amazon DynamoDB creates and maintains indexes for the primary key attributes. This allows applications to quickly retrieve data by specifying primary key values. However, many applications might benefit from having one or more secondary (or alternate) keys available to allow efficient access to data with attributes other than the primary key. To address this, you can create one or more secondary indexes on a table, and issue Query requests against these indexes.
Amazon DynamoDB supports two types of secondary indexes:
Local secondary index — an index that has the same partition key as the table, but a different sort key. A local secondary index is “local” in the sense that every partition of a local secondary index is scoped to a table partition that has the same partition key.
Global secondary index — an index with a partition or a partition-and-sort key that can be different from those on the table. A global secondary index is considered “global” because queries on the index can span all items in a table, across all partitions.
Secondary indexes are automatically maintained by Amazon DynamoDB as sparse objects. Items will only appear in an index if they exist in the table on which the index is defined. This makes queries against an index very efficient, because the number of items in the index will often be significantly less than the number of items in the table.
Global secondary indexes support non-unique attributes, which increases query flexibility by enabling queries against any non-key attribute in the table.
Consider a gaming application that stores the information of its players in a DynamoDB table whose primary key consists of UserId (partition) and GameTitle (sort). Items have attributes named TopScore, Timestamp, ZipCode, and others. Upon table creation, DynamoDB provides an implicit index (primary index) on the primary key that can support efficient queries that return a specific user’s top scores for all games.
However, if the application requires top scores of users for a particular game, using this primary index would be inefficient, and would require scanning through the entire table. Instead, a global secondary index with GameTitle as the partition key element and TopScore as the sort key element would enable the application to rapidly retrieve top scores for a game.
A GSI does not need to have a sort key element. For instance, you could have a GSI with a key that only has a partition element GameTitle. In the example below, the GSI has no projected attributes, so it will just return all items (identified by primary key) that have an attribute matching the GameTitle you are querying on.
When should I use global secondary indexes?
Global secondary indexes
Amazon DynamoDB | Database
Global secondary indexes are particularly useful for tracking relationships between attributes that have a lot of different values. For example, you could create a DynamoDB table with CustomerID as the primary partition key for the table and ZipCode as the partition key for a global secondary index, since there are a lot of zip codes and since you will probably have a lot of customers. Using the primary key, you could quickly get the record for any customer. Using the global secondary index, you could efficiently query for all customers that live in a given zip code.
To ensure that you get the most out of your global secondary index’s capacity, please review our best practices documentation on uniform workloads.
How do I create a global secondary index for a DynamoDB table?
Global secondary indexes
Amazon DynamoDB | Database
GSIs associated with a table can be specified at any time. For detailed steps on creating a Table and its indexes, see here. You can create a maximum of 5 global secondary indexes per table.
Does the local version of DynamoDB support global secondary indexes?
Global secondary indexes
Amazon DynamoDB | Database
Yes. The local version of DynamoDB is useful for developing and testing DynamoDB-backed applications. You can download the local version of DynamoDB here.
What are projected attributes?
Global secondary indexes
Amazon DynamoDB | Database
The data in a secondary index consists of attributes that are projected, or copied, from the table into the index. When you create a secondary index, you define the alternate key for the index, along with any other attributes that you want to be projected in the index. Amazon DynamoDB copies these attributes into the index, along with the primary key attributes from the table. You can then query the index just as you would query a table.
Can a global secondary index key be defined on non-unique attributes?
Global secondary indexes
Amazon DynamoDB | Database
Yes. Unlike the primary key on a table, a GSI index does not require the indexed attributes to be unique. For instance, a GSI on GameTitle could index all items that track scores of users for every game. In this example, this GSI can be queried to return all users that have played the game “TicTacToe.”
How do global secondary indexes differ from local secondary indexes?
Global secondary indexes
Amazon DynamoDB | Database
Both global and local secondary indexes enhance query flexibility. An LSI is attached to a specific partition key value, whereas a GSI spans all partition key values. Since items having the same partition key value share the same partition in DynamoDB, the “Local” Secondary Index only covers items that are stored together (on the same partition). Thus, the purpose of the LSI is to query items that have the same partition key value but different sort key values. For example, consider a DynamoDB table that tracks Orders for customers, where CustomerId is the partition key.
An LSI on OrderTime allows for efficient queries to retrieve the most recently ordered items for a particular customer.
In contrast, a GSI is not restricted to items with a common partition key value. Instead, a GSI spans all items of the table just like the primary key. For the table above, a GSI on ProductId can be used to efficiently find all orders of a particular product. Note that in this case, no GSI sort key is specified, and even though there might be many orders with the same ProductId, they will be stored as separate items in the GSI.
In order to ensure that data in the table and the index are co-located on the same partition, LSIs limit the total size of all elements (tables and indexes) to 10 GB per partition key value. GSIs do not enforce data co-location, and have no such restriction.
When you write to a table, DynamoDB atomically updates all the LSIs affected. In contrast, updates to any GSIs defined on the table are eventually consistent.
LSIs allow the Query API to retrieve attributes that are not part of the projection list. This is not supported behavior for GSIs.
How do global secondary indexes work?
Global secondary indexes
Amazon DynamoDB | Database
In many ways, GSI behavior is similar to that of a DynamoDB table. You can query a GSI using its partition key element, with conditional filters on the GSI sort key element. However, unlike a primary key of a DynamoDB table, which must be unique, a GSI key can be the same for multiple items. If multiple items with the same GSI key exist, they are tracked as separate GSI items, and a GSI query will retrieve all of them as individual items. Internally, DynamoDB will ensure that the contents of the GSI are updated appropriately as items are added, removed or updated.
DynamoDB stores a GSI’s projected attributes in the GSI data structure, along with the GSI key and the matching items’ primary keys. GSI’s consume storage for projected items that exist in the source table. This enables queries to be issued against the GSI rather than the table, increasing query flexibility and improving workload distribution. Attributes that are part of an item in a table, but not part of the GSI key, primary key of the table, or projected attributes are thus not returned on querying the GSI index. Applications that need additional data from the table after querying the GSI, can retrieve the primary key from the GSI and then use either the GetItem or BatchGetItem APIs to retrieve the desired attributes from the table. As GSI’s are eventually consistent, applications that use this pattern have to accommodate item deletion (from the table) in between the calls to the GSI and GetItem/BatchItem.
DynamoDB automatically handles item additions, updates and deletes in a GSI when corresponding changes are made to the table. When an item (with GSI key attributes) is added to the table, DynamoDB updates the GSI asynchronously to add the new item. Similarly, when an item is deleted from the table, DynamoDB removes the item from the impacted GSI.
Can I create global secondary indexes for partition-based tables and partition-sort schema tables?
Global secondary indexes
Amazon DynamoDB | Database
Yes, you can create a global secondary index regardless of the type of primary key the DynamoDB table has. The table’s primary key can include just a partition key, or it may include both a partition key and a sort key.
What is the consistency model for global secondary indexes?
Global secondary indexes
Amazon DynamoDB | Database
GSIs support eventual consistency. When items are inserted or updated in a table, the GSIs are not updated synchronously. Under normal operating conditions, a write to a global secondary index will propagate in a fraction of a second. In unlikely failure scenarios, longer delays may occur. Because of this, your application logic should be capable of handling GSI query results that are potentially out-of-date. Note that this is the same behavior exhibited by other DynamoDB APIs that support eventually consistent reads.
Consider a table tracking top scores where each item has attributes UserId, GameTitle and TopScore. The partition key is UserId, and the primary sort key is GameTitle. If the application adds an item denoting a new top score for GameTitle “TicTacToe” and UserId “GAMER123,” and then subsequently queries the GSI, it is possible that the new score will not be in the result of the query. However, once the GSI propagation has completed, the new item will start appearing in such queries on the GSI.
Can I provision throughput separately for the table and for each global secondary index?
Global secondary indexes
Amazon DynamoDB | Database
Yes. GSIs manage throughput independently of the table they are based on. When you enable Auto Scaling for a new or existing table from the console, you can optionally choose to apply the same settings to GSIs. You can also provision different throughput for tables and global secondary indexes manually.
Depending upon on your application, the request workload on a GSI can vary significantly from that of the table or other GSIs. Some scenarios that show this are given below:
A GSI that contains a small fraction of the table items needs a much lower write throughput compared to the table.
A GSI that is used for infrequent item lookups needs a much lower read throughput, compared to the table.
A GSI used by a read-heavy background task may need high read throughput for a few hours per day.
As your needs evolve, you can change the provisioned throughput of the GSI, independently of the provisioned throughput of the table.
Consider a DynamoDB table with a GSI that projects all attributes, and has the GSI key present in 50% of the items. In this case, the GSI’s provisioned write capacity units should be set at 50% of the table’s provisioned write capacity units. Using a similar approach, the read throughput of the GSI can be estimated. Please see DynamoDB GSI Documentation for more details.
How does adding a global secondary index impact provisioned throughput and storage for a table?
Global secondary indexes
Amazon DynamoDB | Database
Similar to a DynamoDB table, a GSI consumes provisioned throughput when reads or writes are performed to it. A write that adds or updates a GSI item will consume write capacity units based on the size of the update. The capacity consumed by the GSI write is in addition to that needed for updating the item in the table.
Note that if you add, delete, or update an item in a DynamoDB table, and if this does not result in a change to a GSI, then the GSI will not consume any write capacity units. This happens when an item without any GSI key attributes is added to the DynamoDB table, or an item is updated without changing any GSI key or projected attributes.
A query to a GSI consumes read capacity units, based on the size of the items examined by the query.
Storage costs for a GSI are based on the total number of bytes stored in that GSI. This includes the GSI key and projected attributes and values, and an overhead of 100 bytes for indexing purposes.
Can DynamoDB throttle my application writes to a table because of a GSI’s provisioned throughput?
Global secondary indexes
Amazon DynamoDB | Database
Because some or all writes to a DynamoDB table result in writes to related GSIs, it is possible that a GSI’s provisioned throughput can be exhausted. In such a scenario, subsequent writes to the table will be throttled. This can occur even if the table has available write capacity units.
How often can I change provisioned throughput at the index level?
Global secondary indexes
Amazon DynamoDB | Database
Tables with GSIs have the same daily limits on the number of throughput change operations as normal tables.
How am I charged for DynamoDB global secondary index?
Global secondary indexes
Amazon DynamoDB | Database
You are charged for the aggregate provisioned throughput for a table and its GSIs by the hour. When you provision manually, while not required, You are charged for the aggregate provisioned throughput for a table and its GSIs by the hour. In addition, you are charged for the data storage taken up by the GSI as well as standard data transfer (external) fees. If you would like to change your GSI’s provisioned throughput capacity, you can do so using the DynamoDB Console or the UpdateTable API or the PutScalingPolicy API for updating Auto Scaling policy settings.
Can I specify which global secondary index should be used for a query?
Global secondary indexes
Amazon DynamoDB | Database
Yes. In addition to the common query parameters, a GSI Query command explicitly includes the name of the GSI to operate against. Note that a query can use only one GSI.
What API calls are supported by a global secondary index?
Global secondary indexes
Amazon DynamoDB | Database
The API calls supported by a GSI are Query and Scan. A Query operation only searches index key attribute values and supports a subset of comparison operators. Because GSIs are updated asynchronously, you cannot use the ConsistentRead parameter with the query. Please see here for details on using GSIs with queries and scans.
What is the order of the results in scan on a global secondary index?
Global secondary indexes
Amazon DynamoDB | Database
For a global secondary index, with a partition-only key schema there is no ordering. For global secondary index with partition-sort key schema the ordering of the results for the same partition key is based on the sort key attribute.
Can I change Global Secondary Indexes after a table has been created?
Global secondary indexes
Amazon DynamoDB | Database
Yes, Global Secondary Indexes can be changed at any time, even after the table has been created.
How can I add a Global Secondary Index to an existing table?
Global secondary indexes
Amazon DynamoDB | Database
You can add a Global Secondary Indexes through the console or through an API call. On the DynamoDB console, first select the table for which you want to add a Global Secondary Index and click the “Create Index” button to add a new index. Follow the steps in the index creation wizard and select “Create” when done. You can also add or delete a Global Secondary Index using the UpdateTable API call with the GlobalSecondaryIndexes parameter.You can learn more by reading our documentation page.
How can I delete a Global Secondary Index?
Global secondary indexes
Amazon DynamoDB | Database
You can delete a Global Secondary Index from the console or through an API call. On the DynamoDB console, select the table for which you want to delete a Global Secondary Index. Then, select the “Indexes” tab under “Table Items” and click on the “Delete” button next to delete the index. You can also delete a Global Secondary Index using the UpdateTable API call.You can learn more by reading our documentation page.
Can I add or delete more than one index in a single API call on the same table?
Global secondary indexes
Amazon DynamoDB | Database
You can only add or delete one index per API call.
What happens if I submit multiple requests to add the same index?
Global secondary indexes
Amazon DynamoDB | Database
Only the first add request is accepted and all subsequent add requests will fail till the first add request is finished.
Can I concurrently add or delete several indexes on the same table?
Global secondary indexes
Amazon DynamoDB | Database
No, at any time there can be only one active add or delete index operation on a table.
Should I provision additional throughput to add a Global Secondary Index?
Global secondary indexes
Amazon DynamoDB | Database
With Auto Scaling, it is recommended that you apply the same settings to Global Secondary Index as the table. When you provision manually, while not required, it is highly recommended that you provision additional write throughput that is separate from the throughput for the index. If you do not provision additional write throughput, the write throughput from the index will be consumed for adding the new index. This will affect the write performance of the index while the index is being created as well as increase the time to create the new index.
Do I have to reduce the additional throughput on a Global Secondary Index once the index has been created?
Global secondary indexes
Amazon DynamoDB | Database
Yes, you would have to dial back the additional write throughput you provisioned for adding an index, once the process is complete.
Can I modify the write throughput that is provisioned for adding a Global Secondary Index?
Global secondary indexes
Amazon DynamoDB | Database
Yes, you can dial up or dial down the provisioned write throughput for index creation at any time during the creation process.
When a Global Secondary Index is being added or deleted, is the table still available?
Global secondary indexes
Amazon DynamoDB | Database
Yes, the table is available when the Global Secondary Index is being updated.
When a Global Secondary Index is being added or deleted, are the existing indexes still available?
Global secondary indexes
Amazon DynamoDB | Database
Yes, the existing indexes are available when the Global Secondary Index is being updated.
When a Global Secondary Index is being created added, is the new index available?
Global secondary indexes
Amazon DynamoDB | Database
No, the new index becomes available only after the index creation process is finished.
How long does adding a Global Secondary Index take?
Global secondary indexes
Amazon DynamoDB | Database
The length of time depends on the size of the table and the amount of additional provisioned write throughput for Global Secondary Index creation. The process of adding or deleting an index could vary from a few minutes to a few hours. For example, let’s assume that you have a 1GB table that has 500 write capacity units provisioned and you have provisioned 1000 additional write capacity units for the index and new index creation. If the new index includes all the attributes in the table and the table is using all the write capacity units, we expect the index creation will take roughly 30 minutes.
How long does deleting a Global Secondary Index take?
Global secondary indexes
Amazon DynamoDB | Database
Deleting an index will typically finish in a few minutes. For example, deleting an index with 1GB of data will typically take less than 1 minute.
How do I track the progress of add or delete operation for a Global Secondary Index?
Global secondary indexes
Amazon DynamoDB | Database
You can use the DynamoDB console or DescribeTable API to check the status of all indexes associated with the table. For an add index operation, while the index is being created, the status of the index will be “CREATING”. Once the creation of the index is finished, the index state will change from “CREATING” to “ACTIVE”. For a delete index operation, when the request is complete, the deleted index will cease to exist.
Can I get a notification when the index creation process for adding a Global Secondary Index is complete?
Global secondary indexes
Amazon DynamoDB | Database
You can request a notification to be sent to your email address confirming that the index addition has been completed. When you add an index through the console, you can request a notification on the last step before creating the index. When the index creation is complete, DynamoDB will send an SNS notification to your email.
What happens when I try to add more Global Secondary Indexes, when I already have 5?
Global secondary indexes
Amazon DynamoDB | Database
You are currently limited to 5 GSIs. The “Add” operation will fail and you will get an error.
Can I reuse a name for a Global Secondary Index after an index with the same name has been deleted?
Global secondary indexes
Amazon DynamoDB | Database
Yes, once a Global Secondary Index has been deleted, that index name can be used again when a new index is added.
Can I cancel an index add while it is being created?
Global secondary indexes
Amazon DynamoDB | Database
No, once index creation starts, the index creation process cannot be canceled.
Are GSI key attributes required in all items of a DynamoDB table?
Global secondary indexes
Amazon DynamoDB | Database
No. GSIs are sparse indexes. Unlike the requirement of having a primary key, an item in a DynamoDB table does not have to contain any of the GSI keys. If a GSI key has both partition and sort elements, and a table item omits either of them, then that item will not be indexed by the corresponding GSI. In such cases, a GSI can be very useful in efficiently locating items that have an uncommon attribute.
Can I retrieve all attributes of a DynamoDB table from a global secondary index?
Global secondary indexes
Amazon DynamoDB | Database
A query on a GSI can only return attributes that were specified to be included in the GSI at creation time. The attributes included in the GSI are those that are projected by default such as the GSI’s key attribute(s) and table’s primary key attribute(s), and those that the user specified to be projected. For this reason, a GSI query will not return attributes of items that are part of the table, but not included in the GSI. A GSI that specifies all attributes as projected attributes can be used to retrieve any table attributes. See here for documentation on using GSIs for queries.
How can I list GSIs associated with a table?
Global secondary indexes
Amazon DynamoDB | Database
The DescribeTable API will return detailed information about global secondary indexes on a table.
What data types can be indexed?
Global secondary indexes
Amazon DynamoDB | Database
All scalar data types (Number, String, Binary, and Boolean) can be used for the sort key element of the local secondary index key. Set, list, and map types cannot be indexed.
Are composite attribute indexes possible?
Global secondary indexes
Amazon DynamoDB | Database
No. But you can concatenate attributes into a string and use this as a key.
What data types can be part of the projected attributes for a GSI?
Global secondary indexes
Amazon DynamoDB | Database
You can specify attributes with any data types (including set types) to be projected into a GSI.
What are some scalability considerations of GSIs?
Global secondary indexes
Amazon DynamoDB | Database
Performance considerations of the primary key of a DynamoDB table also apply to GSI keys. A GSI assumes a relatively random access pattern across all its keys. To get the most out of secondary index provisioned throughput, you should select a GSI partition key attribute that has a large number of distinct values, and a GSI sort key attribute that is requested fairly uniformly, as randomly as possible.
What new metrics will be available through CloudWatch for global secondary indexes?
Global secondary indexes
Amazon DynamoDB | Database
Tables with GSI will provide aggregate metrics for the table and GSIs, as well as breakouts of metrics for the table and each GSI.
Reports for individual GSIs will support a subset of the CloudWatch metrics that are supported by a table. These include:
Read Capacity (Provisioned Read Capacity, Consumed Read Capacity)
Write Capacity (Provisioned Write Capacity, Consumed Write Capacity)
Throttled read events
Throttled write events
For more details on metrics supported by DynamoDB tables and indexes see here.
How can I scan a Global Secondary Index?
Global secondary indexes
Amazon DynamoDB | Database
Global secondary indexes can be scanned via the Console or the Scan API.
To scan a global secondary index, explicitly reference the index in addition to the name of the table you’d like to scan. You must specify the index partition attribute name and value. You can optionally specify a condition against the index key sort attribute.
Will a Scan on Global secondary index allow me to specify non-projected attributes to be returned in the result set?
Global secondary indexes
Amazon DynamoDB | Database
Scan on global secondary indexes will not support fetching of non-projected attributes.
Will there be parallel scan support for indexes?
Local secondary indexes
Amazon DynamoDB | Database
Yes, parallel scan will be supported for indexes and the semantics are the same as that for the main table.
What are local secondary indexes?
Local secondary indexes
Amazon DynamoDB | Database
Local secondary indexes enable some common queries to run more quickly and cost-efficiently, that would otherwise require retrieving a large number of items and then filtering the results. It means your applications can rely on more flexible queries based on a wider range of attributes.
Before the launch of local secondary indexes, if you wanted to find specific items within a partition (items that share the same partition key), DynamoDB would have fetched all objects that share a single partition key, and filter the results accordingly. For instance, consider an e-commerce application that stores customer order data in a DynamoDB table with partition-sort schema of customer id-order timestamp. Without LSI, to find an answer to the question “Display all orders made by Customer X with shipping date in the past 30 days, sorted by shipping date”, you had to use the Query API to retrieve all the objects under the partition key “X”, sort the results by shipment date and then filter out older records.
With local secondary indexes, we are simplifying this experience. Now, you can create an index on “shipping date” attribute and execute this query efficiently and just retieve only the necessary items. This significantly reduces the latency and cost of your queries as you will retrieve only items that meet your specific criteria. Moreover, it also simplifies the programming model for your application as you no longer have to write customer logic to filter the results. We call this new secondary index a ‘local’ secondary index because it is used along with the partition key and hence allows you to search locally within a partition key bucket. So while previously you could only search using the partition key and the sort key, now you can also search using a secondary index in place of the sort key, thus expanding the number of attributes that can be used for queries which can be conducted efficiently.
Redundant copies of data attributes are copied into the local secondary indexes you define. These attributes include the table partition and sort key, plus the alternate sort key you define. You can also redundantly store other data attributes in the local secondary index, in order to access those other attributes without having to access the table itself.
Local secondary indexes are not appropriate for every application. They introduce some constraints on the volume of data you can store within a single partition key value. For more information, see the FAQ items below about item collections.
What are Projections?
Local secondary indexes
Amazon DynamoDB | Database
The set of attributes that is copied into a local secondary index is called a projection. The projection determines the attributes that you will be able to retrieve with the most efficiency. When you query a local secondary index, Amazon DynamoDB can access any of the projected attributes, with the same performance characteristics as if those attributes were in a table of their own. If you need to retrieve any attributes that are not projected, Amazon DynamoDB will automatically fetch those attributes from the table.
When you define a local secondary index, you need to specify the attributes that will be projected into the index. At a minimum, each index entry consists of: (1) the table partition key value, (2) an attribute to serve as the index sort key, and (3) the table sort key value.
Beyond the minimum, you can also choose a user-specified list of other non-key attributes to project into the index. You can even choose to project all attributes into the index, in which case the index replicates the same data as the table itself, but the data is organized by the alternate sort key you specify.
How can I create a LSI?
Local secondary indexes
Amazon DynamoDB | Database
You need to create a LSI at the time of table creation. It can’t currently be added later on. To create an LSI, specify the following two parameters:
Indexed Sort key – the attribute that will be indexed and queried on.
Projected Attributes – the list of attributes from the table that will be copied directly into the local secondary index, so they can be returned more quickly without fetching data from the primary index, which contains all the items of the table. Without projected attributes, local secondary index contains only primary and secondary index keys.
What is the consistency model for LSI?
Local secondary indexes
Amazon DynamoDB | Database
Local secondary indexes are updated automatically when the primary index is updated. Similar to reads from a primary index, LSI supports both strong and eventually consistent read options.
Do local secondary indexes contain references to all items in the table?
Local secondary indexes
Amazon DynamoDB | Database
No, not necessarily. Local secondary indexes only reference those items that contain the indexed sort key specified for that LSI. DynamoDB’s flexible schema means that not all items will necessarily contain all attributes.
This means local secondary index can be sparsely populated, compared with the primary index. Because local secondary indexes are sparse, they are efficient to support queries on attributes that are uncommon.
For example, in the Orders example described above, a customer may have some additional attributes in an item that are included only if the order is canceled (such as CanceledDateTime, CanceledReason). For queries related to canceled items, an local secondary index on either of these attributes would be efficient since the only items referenced in the index would be those that had these attributes present.
How do I query local secondary indexes?
Local secondary indexes
Amazon DynamoDB | Database
Local secondary indexes can only be queried via the Query API.
To query a local secondary index, explicitly reference the index in addition to the name of the table you’d like to query. You must specify the index partition attribute name and value. You can optionally specify a condition against the index key sort attribute.
Your query can retrieve non-projected attributes stored in the primary index by performing a table fetch operation, with a cost of additional read capacity units.
Both strongly consistent and eventually consistent reads are supported for query using local secondary index.
How do I create local secondary indexes?
Local secondary indexes
Amazon DynamoDB | Database
Local secondary indexes must be defined at time of table creation. The primary index of the table must use a partition-sort composite key.
Can I add local secondary indexes to an existing table?
Local secondary indexes
Amazon DynamoDB | Database
No, it’s not possible to add local secondary indexes to existing tables at this time. We are working on adding this capability and will be releasing it in the future. When you create a table with local secondary index, you may decide to create local secondary index for future use by defining a sort key element that is currently not used. Since local secondary index are sparse, this index costs nothing until you decide to use it.
How many local secondary indexes can I create on one table?
Local secondary indexes
Amazon DynamoDB | Database
Each table can have up to five local secondary indexes.
How many projected non-key attributes can I create on one table?
Local secondary indexes
Amazon DynamoDB | Database
Each table can have up to 20 projected non-key attributes, in total across all local secondary indexes within the table. Each index may also specifify that all non-key attributes from the primary index are projected.
Can I modify the index once it is created?
Local secondary indexes
Amazon DynamoDB | Database
No, an index cannot be modified once it is created. We are working to add this capability in the future.
Can I delete local secondary indexes?
Local secondary indexes
Amazon DynamoDB | Database
No, local secondary indexes cannot be removed from a table once they are created at this time. Of course, they are deleted if you also decide to delete the entire table. We are working on adding this capability and will be releasing it in the future.
How do local secondary indexes consume provisioned capacity?
Local secondary indexes
Amazon DynamoDB | Database
You don’t need to explicitly provision capacity for a local secondary index. It consumes provisioned capacity as part of the table with which it is associated.
Reads from LSIs and writes to tables with LSIs consume capacity by the standard formula of 1 unit per 1KB of data, with the following differences:
When writes contain data that are relevant to one or more local secondary indexes, those writes are mirrored to the appropriate local secondary indexes. In these cases, write capacity will be consumed for the table itself, and additional write capacity will be consumed for each relevant LSI.
Updates that overwrite an existing item can result in two operations– delete and insert – and thereby consume extra units of write capacity per 1KB of data.
When a read query requests attributes that are not projected into the LSI, DynamoDB will fetch those attributes from the primary index. This implicit GetItem request consumes one read capacity unit per 4KB of item data fetched.
How much storage will local secondary indexes consume?
Local secondary indexes
Amazon DynamoDB | Database
Local secondary indexes consume storage for the attribute name and value of each LSI’s primary and index keys, for all projected non-key attributes, plus 100 bytes per item reflected in the LSI.
What data types can be indexed?
Local secondary indexes
Amazon DynamoDB | Database
All scalar data types (Number, String, Binary) can be used for the sort key element of the local secondary index key. Set types cannot be used.
What data types can be projected into a local secondary index?
Local secondary indexes
Amazon DynamoDB | Database
All data types (including set types) can be projected into a local secondary index.
What are item collections and how are they related to LSI?
Local secondary indexes
Amazon DynamoDB | Database
In Amazon DynamoDB, an item collection is any group of items that have the same partition key, across a table and all of its local secondary indexes. Traditional partitioned (or sharded) relational database systems call these shards or partitions, referring to all database items or rows stored under a partition key.
Item collections are automatically created and maintained for every table that includes local secondary indexes. DynamoDB stores each item collection within a single disk partition.
Are there limits on the size of an item collection?
Local secondary indexes
Amazon DynamoDB | Database
Every item collection in Amazon DynamoDB is subject to a maximum size limit of 10 gigabytes. For any distinct partition key value, the sum of the item sizes in the table plus the sum of the item sizes across all of that table’s local secondary indexes must not exceed 10 GB.
The 10 GB limit for item collections does not apply to tables without local secondary indexes; only tables that have one or more local secondary indexes are affected.
Although individual item collections are limited in size, the storage size of an overall table with local secondary indexes is not limited. The total size of an indexed table in Amazon DynamoDB is effectively unlimited, provided the total storage size (table and indexes) for any one partition key value does not exceed the 10 GB threshold.
How can I track the size of an item collection?
Local secondary indexes
Amazon DynamoDB | Database
DynamoDB’s write APIs (PutItem, UpdateItem, DeleteItem, and BatchWriteItem) include an option, which allows the API response to include an estimate of the relevant item collection’s size. This estimate includes lower and upper size estimate for the data in a particular item collection, measured in gigabytes.
We recommend that you instrument your application to monitor the sizes of your item collections. Your applications should examine the API responses regarding item collection size, and log an error message whenever an item collection exceeds a user-defined limit (8 GB, for example). This would provide an early warning system, letting you know that an item collection is growing larger, but giving you enough time to do something about it.
What if I exceed the 10GB limit for an item collection?
Local secondary indexes
Amazon DynamoDB | Database
If a particular item collection exceeds the 10GB limit, then you will not be able to write new items, or increase the size of existing items, for that particular partition key. Read and write operations that shrink the size of the item collection are still allowed. Other item collections in the table are not affected.
To address this problem , you can remove items or reduce item sizes in the collection that has exceeded 10GB. Alternatively, you can introduce new items under a new partition key value to work around this problem. If your table includes historical data that is infrequently accessed, consider archiving the historical data to Amazon S3, Amazon Glacier or another data store.
How can I scan a local secondary index?
Local secondary indexes
Amazon DynamoDB | Database
To scan a local secondary index, explicitly reference the index in addition to the name of the table you’d like to scan. You must specify the index partition attribute name and value. You can optionally specify a condition against the index key sort attribute.
Your scan can retrieve non-projected attributes stored in the primary index by performing a table fetch operation, with a cost of additional read capacity units.
Will a Scan on a local secondary index allow me to specify non-projected attributes to be returned in the result set?
Local secondary indexes
Amazon DynamoDB | Database
Scan on local secondary indexes will support fetching of non-projected attributes.
What is the order of the results in scan on a local secondary index?
Security and control
Amazon DynamoDB | Database
For local secondary index, the ordering within a collection will be the based on the order of the indexed attribute.
What is DynamoDB Fine-Grained Access Control?
Security and control
Amazon DynamoDB | Database
Fine Grained Access Control (FGAC) gives a DynamoDB table owner a high degree of control over data in the table. Specifically, the table owner can indicate who (caller) can access which items or attributes of the table and perform what actions (read / write capability). FGAC is used in concert with AWS Identity and Access Management (IAM), which manages the security credentials and the associated permissions.
What are the common use cases for DynamoDB FGAC?
Security and control
Amazon DynamoDB | Database
FGAC can benefit any application that tracks information in a DynamoDB table, where the end user (or application client acting on behalf of an end user) wants to read or modify the table directly, without a middle-tier service. For instance, a developer of a mobile app named Acme can use FGAC to track the top score of every Acme user in a DynamoDB table. FGAC allows the application client to modify only the top score for the user that is currently running the application.
Can I use Fine Grain Access Control with JSON documents?
Security and control
Amazon DynamoDB | Database
Yes. You can use Fine Grain Access Control (FGAC) to restrict access to your data based on top-level attributes in your document. You cannot use FGAC to restrict access based on nested attributes. For example, suppose you stored a JSON document that contained the following information about a person: ID, first name, last name, and a list of all of their friends. You could use FGAC to restrict access based on their ID, first name, or last name, but not based on the list of friends.
Without FGAC, how can a developer achieve item level access control?
Security and control
Amazon DynamoDB | Database
To achieve this level of control without FGAC, a developer would have to choose from a few potentially onerous approaches. Some of these are:
Proxy: The application client sends a request to a brokering proxy that performs the authentication and authorization. Such a solution increases the complexity of the system architecture and can result in a higher total cost of ownership (TCO).
Per Client Table: Every application client is assigned its own table. Since application clients access different tables, they would be protected from one another. This could potentially require a developer to create millions of tables, thereby making database management extremely painful.
Per-Client Embedded Token: A secret token is embedded in the application client. The shortcoming of this is the difficulty in changing the token and handling its impact on the stored data. Here, the key of the items accessible by this client would contain the secret token.
How does DynamoDB FGAC work?
Security and control
Amazon DynamoDB | Database
With FGAC, an application requests a security token that authorizes the application to access only specific items in a specific DynamoDB table. With this token, the end user application agent can make requests to DynamoDB directly. Upon receiving the request, the incoming request’s credentials are first evaluated by DynamoDB, which will use IAM to authenticate the request and determine the capabilities allowed for the user. If the user’s request is not permitted, FGAC will prevent the data from being accessed.
How much does DynamoDB FGAC cost?
Security and control
Amazon DynamoDB | Database
There is no additional charge for using FGAC. As always, you only pay for the provisioned throughput and storage associated with the DynamoDB table.
How do I get started?
Security and control
Amazon DynamoDB | Database
Refer to the Fine-Grained Access Control section of the DynamoDB Developer Guide to learn how to create an access policy, create an IAM role for your app (e.g. a role named AcmeFacebookUsers for a Facebook app_id of 34567), and assign your access policy to the role. The trust policy of the role determines which identity providers are accepted (e.g. Login with Amazon, Facebook, or Google), and the access policy describes which AWS resources can be accessed (e.g. a DynamoDB table). Using the role, your app can now to obtain temporary credentials for DynamoDB by calling the AssumeRoleWithIdentityRequest API of the AWS Security Token Service (STS).
How do I allow users to Query a Local Secondary Index, but prevent them from causing a table fetch to retrieve non-projected attributes?
Security and control
Amazon DynamoDB | Database
Some Query operations on a Local Secondary Index can be more expensive than others if they request attributes that are not projected into an index. You an restrict such potentially expensive “fetch” operations by limiting the permissions to only projected attributes, using the “dynamodb:Attributes” context key.
How do I prevent users from accessing specific attributes?
Security and control
Amazon DynamoDB | Database
The recommended approach to preventing access to specific attributes is to follow the principle of least privilege, and Allow access to only specific attributes.
Alternatively, you can use a Deny policy to specify attributes that are disallowed. However, this is not recommended for the following reasons:
With a Deny policy, it is possible for the user to discover the hidden attribute names by issuing repeated requests for every possible attribute name, until the user is ultimately denied access.
Deny policies are more fragile, since DynamoDB could introduce new API functionality in the future that might allow an access pattern that you had previously intended to block.
How do I prevent users from adding invalid data to a table?
Security and control
Amazon DynamoDB | Database
The available FGAC controls can determine which items changed or read, and which attributes can be changed or read. Users can add new items without those blocked attributes, and change any value of any attribute that is modifiable.
Can I grant access to multiple attributes without listing all of them?
Security and control
Amazon DynamoDB | Database
Yes, the IAM policy language supports a rich set of comparison operations, including StringLike, StringNotLike, and many others. For additional details, please see the IAM Policy Reference.
How do I create an appropriate policy?
Security and control
Amazon DynamoDB | Database
We recommend that you use the DynamoDB Policy Generator from the DynamoDB console. You may also compare your policy to those listed in the Amazon DynamoDB Developer Guide to make sure you are following a recommended pattern. You can post policies to the AWS Forums to get thoughts from the DynamoDB community.
Can I grant access based on a canonical user id instead of separate ids for the user based on the identity provider they logged in with?
Security and control
Amazon DynamoDB | Database
Not without running a “token vending machine”. If a user retrieves federated access to your IAM role directly using Facebook credentials with STS, those temporary credentials only have information about that user’s Facebook login, and not their Amazon login, or Google login. If you want to internally store a mapping of each of these logins to your own stable identifier, you can run a service that the user contacts to log in, and then call STS and provide them with credentials scoped to whatever partition key value you come up with as their canonical user id.
What information cannot be hidden from callers using FGAC?
Security and control
Amazon DynamoDB | Database
Certain information cannot currently be blocked from the caller about the items in the table:
Item collection metrics. The caller can ask for the estimated number of items and size in bytes of the item collection.
Consumed throughput The caller can ask for the detailed breakdown or summary of the provisioned throughput consumed by operations.
Validation cases. In certain cases, the caller can learn about the existence and primary key schema of a table when you did not intend to give them access. To prevent this, follow the principle of least privilege and only allow access to the tables and actions that you intended to allow access to.
If you deny access to specific attributes instead of whitelisting access to specific attributes, the caller can theoretically determine the names of the hidden attributes if “allow all except for” logic. It is safer to whitelist specific attribute names instead.
Does Amazon DynamoDB support IAM permissions?
Security and control
Amazon DynamoDB | Database
Yes, DynamoDB supports API-level permissions through AWS Identity and Access Management (IAM) service integration.
For more information about IAM, go to:
AWS Identity and Access Management
AWS Identity and Access Management Getting Started Guide
Using AWS Identity and Access Management
I wish to perform security analysis or operational troubleshooting on my DynamoDB tables. Can I get a history of all DynamoDB API calls made on my account?
Pricing
Amazon DynamoDB | Database
Yes. AWS CloudTrail is a web service that records AWS API calls for your account and delivers log files to you. The AWS API call history produced by AWS CloudTrail enables security analysis, resource change tracking, and compliance auditing. Details about DynamoDB support for CloudTrail can be found here. Learn more about CloudTrail at the AWS CloudTrail detail page, and turn it on via CloudTrail’s AWS Management Console home page.
How will I be charged for my use of Amazon DynamoDB?
Pricing
Amazon DynamoDB | Database
Each DynamoDB table has provisioned read-throughput and write-throughput associated with it. You are billed by the hour for that throughput capacity if you exceed the free tier.
Please note that you are charged by the hour for the throughput capacity, whether or not you are sending requests to your table. If you would like to change your table’s provisioned throughput capacity, you can do so using the AWS Management Console, the UpdateTable API or the PutScalingPolicy API for Auto Scaling..
In addition, DynamoDB also charges for indexed data storage as well as the standard internet data transfer fees
To learn more about DynamoDB pricing, please visit the DynamoDB pricing page.
What are some pricing examples?
Pricing
Amazon DynamoDB | Database
Here is an example of how to calculate your throughput costs using US East (Northern Virginia) Region pricing. To view prices for other regions, visit our pricing page.
If you create a table and request 10 units of write capacity and 200 units of read capacity of provisioned throughput, you would be charged:
$0.01 + (4 x $0.01) = $0.05 per hour
If your throughput needs changed and you increased your reserved throughput requirement to 10,000 units of write capacity and 50,000 units of read capacity, your bill would then change to:
(1,000 x $0.01) + (1,000 x $0.01) = $20/hour
To learn more about DynamoDB pricing, please visit the DynamoDB pricing page.
Do your prices include taxes?
Pricing
Amazon DynamoDB | Database
For details on taxes, see Amazon Web Services Tax Help.
What is provisioned throughput?
Pricing
Amazon DynamoDB | Database
Amazon DynamoDB Auto Scaling adjusts throughput capacity automatically as request volumes change, based on your desired target utilization and minimum and maximum capacity limits, or lets you specify the request throughput you want your table to be able to achieve manually. Behind the scenes, the service handles the provisioning of resources to achieve the requested throughput rate. Rather than asking you to think about instances, hardware, memory, and other factors that could affect your throughput rate, we simply ask you to provision the throughput level you want to achieve. This is the provisioned throughput model of service.
During creation of a new table or global secondary index, Auto Scaling is enabled by default with default settings for target utilization, minimum and maximum capacity; or you can specify your required read and write capacity needs manually; and Amazon DynamoDB automatically partitions and reserves the appropriate amount of resources to meet your throughput requirements.
How does selection of primary key influence the scalability I can achieve?
Pricing
Amazon DynamoDB | Database
When storing data, Amazon DynamoDB divides a table into multiple partitions and distributes the data based on the partition key element of the primary key. While allocating capacity resources, Amazon DynamoDB assumes a relatively random access pattern across all primary keys. You should set up your data model so that your requests result in a fairly even distribution of traffic across primary keys. If a table has a very small number of heavily-accessed partition key elements, possibly even a single very heavily-used partition key element, traffic is concentrated on a small number of partitions – potentially only one partition. If the workload is heavily unbalanced, meaning disproportionately focused on one or a few partitions, the operations will not achieve the overall provisioned throughput level. To get the most out of Amazon DynamoDB throughput, build tables where the partition key element has a large number of distinct values, and values are requested fairly uniformly, as randomly as possible. An example of a good primary key is CustomerID if the application has many customers and requests made to various customer records tend to be more or less uniform. An example of a heavily skewed primary key is “Product Category Name” where certain product categories are more popular than the rest.
What is a read/write capacity unit?
Pricing
Amazon DynamoDB | Database
How do I estimate how many read and write capacity units I need for my application? A unit of Write Capacity enables you to perform one write per second for items of up to 1KB in size. Similarly, a unit of Read Capacity enables you to perform one strongly consistent read per second (or two eventually consistent reads per second) of items of up to 4KB in size. Larger items will require more capacity. You can calculate the number of units of read and write capacity you need by estimating the number of reads or writes you need to do per second and multiplying by the size of your items (rounded up to the nearest KB).
Units of Capacity required for writes = Number of item writes per second x item size in 1KB blocks
Units of Capacity required for reads* = Number of item reads per second x item size in 4KB blocks
* If you use eventually consistent reads you’ll get twice the throughput in terms of reads per second.
If your items are less than 1KB in size, then each unit of Read Capacity will give you 1 strongly consistent read/second and each unit of Write Capacity will give you 1 write/second of capacity. For example, if your items are 512 bytes and you need to read 100 items per second from your table, then you need to provision 100 units of Read Capacity.
If your items are larger than 4KB in size, then you should calculate the number of units of Read Capacity and Write Capacity that you need. For example, if your items are 4.5KB and you want to do 100 strongly consistent reads/second, then you would need to provision 100 (read per second) x 2 (number of 4KB blocks required to store 4.5KB) = 200 units of Read Capacity.
Note that the required number of units of Read Capacity is determined by the number of items being read per second, not the number of API calls. For example, if you need to read 500 items per second from your table, and if your items are 4KB or less, then you need 500 units of Read Capacity. It doesn’t matter if you do 500 individual GetItem calls or 50 BatchGetItem calls that each return 10 items.
Will I always be able to achieve my level of provisioned throughput?
Pricing
Amazon DynamoDB | Database
Amazon DynamoDB assumes a relatively random access pattern across all primary keys. You should set up your data model so that your requests result in a fairly even distribution of traffic across primary keys. If you have a highly uneven or skewed access pattern, you may not be able to achieve your level of provisioned throughput.
When storing data, Amazon DynamoDB divides a table into multiple partitions and distributes the data based on the partition key element of the primary key. The provisioned throughput associated with a table is also divided among the partitions; each partition’s throughput is managed independently based on the quota allotted to it. There is no sharing of provisioned throughput across partitions. Consequently, a table in Amazon DynamoDB is best able to meet the provisioned throughput levels if the workload is spread fairly uniformly across the partition key values. Distributing requests across partition key values distributes the requests across partitions, which helps achieve your full provisioned throughput level.
If you have an uneven workload pattern across primary keys and are unable to achieve your provisioned throughput level, you may be able to meet your throughput needs by increasing your provisioned throughput level further, which will give more throughput to each partition. However, it is recommended that you considering modifying your request pattern or your data model in order to achieve a relatively random access pattern across primary keys.
If I retrieve only a single element of a JSON document, will I be charged for reading the whole item?
Pricing
Amazon DynamoDB | Database
Yes. When reading data out of DynamoDB, you consume the throughput required to read the entire item.
What is the maximum throughput I can provision for a single DynamoDB table?
Pricing
Amazon DynamoDB | Database
DynamoDB is designed to scale without limits However, if you wish to exceed throughput rates of 10,000 write capacity units or 10,000 read capacity units for an individual table, you must first contact Amazon through this online form. If you wish to provision more than 20,000 write capacity units or 20,000 read capacity units from a single subscriber account you must first contact us using the form described above.
What is the minimum throughput I can provision for a single DynamoDB table?
Pricing
Amazon DynamoDB | Database
The smallest provisioned throughput you can request is 1 write capacity unit and 1 read capacity unit for both Auto Scaling and manual throughput provisioning..
This falls within the free tier which allows for 25 units of write capacity and 25 units of read capacity. The free tier applies at the account level, not the table level. In other words, if you add up the provisioned capacity of all your tables, and if the total capacity is no more than 25 units of write capacity and 25 units of read capacity, your provisioned capacity would fall into the free tier.
Is there any limit on how much I can change my provisioned throughput with a single request?
Pricing
Amazon DynamoDB | Database
You can increase the provisioned throughput capacity of your table by any amount using the UpdateTable API. For example, you could increase your table’s provisioned write capacity from 1 write capacity unit to 10,000 write capacity units with a single API call. Your account is still subject to table-level and account-level limits on capacity, as described in our documentation page. If you need to raise your provisioned capacity limits, you can visit our Support Center, click “Open a new case”, and file a service limit increase request.
How am I charged for provisioned throughput?
Pricing
Amazon DynamoDB | Database
Every Amazon DynamoDB table has pre-provisioned the resources it needs to achieve the throughput rate you asked for. You are billed at an hourly rate for as long as your table holds on to those resources. For a complete list of prices with examples, see the DynamoDB pricing page.
How do I change the provisioned throughput for an existing DynamoDB table?
Pricing
Amazon DynamoDB | Database
There are two ways to update the provisioned throughput of an Amazon DynamoDB table. You can either make the change in the management console, or you can use the UpdateTable API call. In either case, Amazon DynamoDB will remain available while your provisioned throughput level increases or decreases.
How often can I change my provisioned throughput?
Pricing
Amazon DynamoDB | Database
You can increase your provisioned throughput as often as you want. You can decrease up to four times any time per day. A day is defined according to the GMT time zone. Additionally, if there was no decrease in the past four hours, an additional dial down is allowed, effectively bringing maximum number of decreases in a day to 9 (4 decreases in the first 4 hours, and 1 decrease for each of the subsequent 4 hour windows in a day).
Keep in mind that you can’t change your provisioned throughput if your Amazon DynamoDB table is still in the process of responding to your last request to change provisioned throughput. Use the management console or the DescribeTables API to check the status of your table. If the status is “CREATING”, “DELETING”, or “UPDATING”, you won’t be able to adjust the throughput of your table. Please wait until you have a table in “ACTIVE” status and try again.
Does the consistency level affect the throughput rate?
Pricing
Amazon DynamoDB | Database
Yes. For a given allocation of resources, the read-rate that a DynamoDB table can achieve is different for strongly consistent and eventually consistent reads. If you request “1,000 read capacity units”, DynamoDB will allocate sufficient resources to achieve 1,000 strongly consistent reads per second of items up to 4KB. If you want to achieve 1,000 eventually consistent reads of items up to 4KB, you will need half of that capacity, i.e., 500 read capacity units. For additional guidance on choosing the appropriate throughput rate for your table, see our provisioned throughput guide.
Does the item size affect the throughput rate?
Pricing
Amazon DynamoDB | Database
Yes. For a given allocation of resources, the read-rate that a DynamoDB table can achieve does depend on the size of an item. When you specify the provisioned read throughput you would like to achieve, DynamoDB provisions its resources on the assumption that items will be less than 4KB in size. Every increase of up to 4KB will linearly increase the resources you need to achieve the same throughput rate. For example, if you have provisioned a DynamoDB table with 100 units of read capacity, that means that it can handle 100 4KB reads per second, or 50 8KB reads per second, or 25 16KB reads per second, and so on.
Similarly the write-rate that a DynamoDB table can achieve does depend on the size of an item. When you specify the provisioned write throughput you would like to achieve, DynamoDB provisions its resources on the assumption that items will be less than 1KB in size. Every increase of up to 1KB will linearly increase the resources you need to achieve the same throughput rate. For example, if you have provisioned a DynamoDB table with 100 units of write capacity, that means that it can handle 100 1KB writes per second, or 50 2KB writes per second, or 25 4KB writes per second, and so on.
For additional guidance on choosing the appropriate throughput rate for your table, see our provisioned throughput guide.
What happens if my application performs more reads or writes than my provisioned capacity?
Pricing
Amazon DynamoDB | Database
If your application performs more reads/second or writes/second than your table’s provisioned throughput capacity allows, requests above your provisioned capacity will be throttled and you will receive 400 error codes. For instance, if you had asked for 1,000 write capacity units and try to do 1,500 writes/second of 1 KB items, DynamoDB will only allow 1,000 writes/second to go through and you will receive error code 400 on your extra requests. You should use CloudWatch to monitor your request rate to ensure that you always have enough provisioned throughput to achieve the request rate that you need.