0
0
DynamoDBquery~5 mins

Read and write capacity units in DynamoDB

Choose your learning style9 modes available
Introduction

Read and write capacity units control how much data you can read or write in your DynamoDB table per second. They help keep your app fast and reliable.

When you want to set limits on how many reads your app can do per second to avoid slowdowns.
When you need to control how many writes your app can do per second to prevent errors.
When you want to plan your costs by adjusting how much capacity your table uses.
When you expect your app traffic to grow and want to prepare your database for more requests.
When you want to avoid sudden spikes in usage causing your app to fail.
Syntax
DynamoDB
ProvisionedThroughput={
  ReadCapacityUnits: number,
  WriteCapacityUnits: number
}

ReadCapacityUnits means how many strongly consistent reads per second you want.

WriteCapacityUnits means how many writes per second you want.

Examples
This sets the table to allow 5 reads and 10 writes per second.
DynamoDB
ProvisionedThroughput={
  ReadCapacityUnits: 5,
  WriteCapacityUnits: 10
}
This sets the table to allow 1 read and 1 write per second, good for very small apps.
DynamoDB
ProvisionedThroughput={
  ReadCapacityUnits: 1,
  WriteCapacityUnits: 1
}
Sample Program

This command creates a DynamoDB table named 'MyTable' with 5 read and 5 write capacity units.

DynamoDB
aws dynamodb create-table \
  --table-name MyTable \
  --attribute-definitions AttributeName=Id,AttributeType=S \
  --key-schema AttributeName=Id,KeyType=HASH \
  --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
OutputSuccess
Important Notes

One read capacity unit can handle one strongly consistent read per second for items up to 4 KB in size.

One write capacity unit can handle one write per second for items up to 1 KB in size.

If your items are larger, DynamoDB uses more capacity units per operation.

Summary

Read and write capacity units set how many reads and writes your DynamoDB table can handle per second.

They help keep your app fast and avoid errors from too many requests.

You can adjust them to control costs and performance.