Capacity Modes - DynamoDB Throughput and On-Demand Capacity
Syntax
DynamoDB Throughput Mode
To switch to DynamoDB Throughput Mode, you need to provision capacity for read and write operations in advance.
aws dynamodb update-table \
--table-name my-table \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
On-Demand Capacity Mode
To switch to On-Demand Capacity Mode, you need to enable it for your table.
aws dynamodb update-table \
--table-name my-table \
--billing-mode PAY_PER_REQUEST
Example
Consider a scenario where you are designing an application that reads a large volume of data from a DynamoDB table. In this scenario, you have two options for managing capacity:
- Provision enough capacity in advance to handle the expected load.
- Use On-Demand Capacity Mode to allow DynamoDB to automatically adjust capacity as necessary based on the rate of read and write requests.
To choose between these options, you need to consider your application's requirements and usage patterns.
Output
The output of the above commands will be a confirmation message indicating that the update was successful.
Explanation
DynamoDB provides two options for managing capacity: DynamoDB Throughput Mode and On-Demand Capacity Mode.
In DynamoDB Throughput Mode, you must provision capacity for read and write operations in advance. This mode works best for applications with predictable usage patterns.
In On-Demand Capacity Mode, DynamoDB automatically adjusts capacity as necessary based on the rate of read and write requests. This mode works best for applications with unpredictable or highly variable usage patterns.
Use
You can use DynamoDB Throughput Mode or On-Demand Capacity Mode depending on your application's requirements and usage patterns.
DynamoDB Throughput Mode is useful when you have predictable usage patterns, and you want to ensure that there is always enough capacity to handle your expected load.
On-Demand Capacity Mode is useful when you have unpredictable or highly variable usage patterns, and you want to avoid over-provisioning capacity.
Important Points
- DynamoDB provides two options for managing capacity: DynamoDB Throughput Mode and On-Demand Capacity Mode.
- DynamoDB Throughput Mode requires you to provision capacity for read and write operations in advance.
- On-Demand Capacity Mode automatically adjusts capacity as necessary based on the rate of read and write requests.
- Choose the capacity mode that best suits your application's requirements and usage patterns.
Summary
In summary, DynamoDB offers two capacity modes: DynamoDB Throughput Mode and On-Demand Capacity Mode. DynamoDB Throughput Mode requires you to provision capacity for read and write operations in advance, while On-Demand Capacity Mode automatically adjusts capacity as necessary based on the rate of read and write requests. Choose the capacity mode that best suits your application's requirements and usage patterns.