0
0
DynamodbConceptBeginner · 3 min read

What is Read Capacity Unit in DynamoDB: Explained Simply

A Read Capacity Unit (RCU) in DynamoDB represents one strongly consistent read per second for an item up to 4 KB in size. For eventually consistent reads, one RCU can handle two reads per second of items up to 4 KB. It helps control and measure the read throughput capacity of your DynamoDB table.
⚙️

How It Works

Think of a Read Capacity Unit (RCU) as a ticket that lets you read data from DynamoDB. Each ticket allows you to read one item up to 4 KB in size per second if you want a strongly consistent read, which means you get the most up-to-date data. If you are okay with eventually consistent reads, which might be slightly out of date but faster, one ticket lets you read two items of up to 4 KB each per second.

This system helps DynamoDB manage how much data you can read at once without slowing down. If your items are larger than 4 KB, DynamoDB uses more tickets (RCUs) to read them. For example, reading an 8 KB item strongly consistently uses 2 RCUs because it is twice the size of 4 KB.

By setting the number of RCUs, you tell DynamoDB how much read traffic your application expects. If you try to read more than your RCUs allow, DynamoDB will slow down or throttle your requests to keep the system stable.

💻

Example

This example shows how to calculate the required RCUs for reading items from a DynamoDB table using Python and the AWS SDK (boto3). It assumes you want to read 10 items per second, each 6 KB in size, with strongly consistent reads.

python
import math

# Item size in KB
item_size_kb = 6

# Number of items to read per second
read_per_second = 10

# Calculate RCUs needed per item (round up)
rcu_per_item = math.ceil(item_size_kb / 4)

# Total RCUs needed
total_rcus = rcu_per_item * read_per_second

print(f"RCUs needed: {total_rcus}")
Output
RCUs needed: 20
🎯

When to Use

Use Read Capacity Units when you choose the provisioned capacity mode in DynamoDB. This mode is best when you know your application's read traffic in advance and want to control costs by setting a fixed number of RCUs.

For example, if you run an online store and expect about 100 product page views per second, you can calculate the RCUs needed based on the size of each product item and set your table's read capacity accordingly. This helps avoid unexpected throttling or overspending.

If your read traffic varies a lot or is unpredictable, consider using on-demand capacity mode instead, which automatically adjusts RCUs for you.

Key Points

  • One RCU = one strongly consistent read per second for an item up to 4 KB.
  • One RCU = two eventually consistent reads per second for items up to 4 KB.
  • Larger items consume more RCUs, rounded up per 4 KB chunk.
  • RCUs help manage and control read throughput in provisioned mode.
  • Choosing the right RCUs prevents throttling and controls costs.

Key Takeaways

A Read Capacity Unit controls how many reads your DynamoDB table can handle per second.
One RCU supports one strongly consistent read or two eventually consistent reads of up to 4 KB each per second.
Larger items require more RCUs, calculated by dividing item size by 4 KB and rounding up.
Set RCUs in provisioned mode to manage costs and avoid throttling.
Use on-demand mode if your read traffic is unpredictable or highly variable.