AWS DynamoDB Capacity Management

Read/Write Capacity Mode:

When you provision Read Capacity Unit (RCU) and Write Capacity Unit (WCU) for Dynamo DB table, Always choose an option carefully after analysing the consumption as it may have a huge impact on the billing.

The read/write capacity mode controls how you are charged for read and write throughput and how you manage capacity. You can set the read/write capacity mode when creating a table or you can change it later.

Amazon 
Dynamo 
DB 
Services 
Availability 
Zone A 
Your Region 
Amazon 
Dynamo 
DB 
Services 
Availability 
Zone B 
Amazon 
Dynamo 
DB 
Services 
Availability Zone C 
DynamoDB stores and manages any 
amount of data and traffic 
Provides high performance and less 
latency 
Automatically replicates data across 
three data centers

Capacity modes for processing reads and writes in a DynamoDB table are:

  • On-demand
  • Provisioned (default, free-tier eligible)

On-Demand:

When you select On-Demand Capacity Mode while creating or re-configuring a table in DynamoDB, you only pay what we use as on-demand mode is bills you on pay-per-request model.

On-demand mode is preferable option when,

  • You create new tables with unknown workloads. 
  • You have unpredictable application traffic. 
  • You prefer the ease of paying for only what you use. 

Note: You can switch between read/write capacity modes once every 24 hours.

Read Request Units and Write Request Units:

For on-demand mode tables, you don’t need to specify how much read and write throughput you expect your application to perform.  

DynamoDB charges you for the reads and writes that your application performs on your tables in terms of read request units and write request units. 

One read request unit represents one strongly consistent read request, or two eventually consistent read requests, for an item up to 4 KB in size.  Transactional read requests require 2 read request units to perform one read for items up to 4 KB. If you need to read an item that is larger than 4 KB, DynamoDB needs additional read request units. The total number of read request units required depends on the item size, and whether you want an eventually consistent or strongly consistent read. 

For example, if your item size is 8 KB, you require 2 read request units to sustain one strongly consistent read, 1 read request unit if you choose eventually consistent reads, or 4 read request units for a transactional read request. Read Capacity Units 
4/4 = 1 
4 KB 
2/4 = 0.5 
0.5 Round to 1 
6/4= 1.5 
1.5 Round to 2 
1 Read Unit 
1 Read Unit 
2 Read Units 
2 Read Units

Example: 
You want to perform 100 strongly consistent reads per second, where the 
items are 6 KB in size. How many read capacity units do you need? 
Solution 
i 1. Number of read capacity units required per item = 6 KB/ 1.5 
2. Round up 1.5 to the nearest whole number = 2 Read units per item 
3. Total units needed for strongly consistent reads = 1 00 items * 2 = 200 Units 
i 4. Total units needed for eventual consistent reads = 100 items/2 = 100 Units

One write request unit represents one write for an item up to 1 KB in size. If you need to write an item that is larger than 1 KB, DynamoDB needs to consume additional write request units. Transactional write requests require 2 write request units to perform one write for items up to 1 KB. The total number of write request units required depends on the item size. For example, if your item size is 2 KB, you require 2 write request units to sustain one write request or 4 read request units for a transactional write request. 

Example: 
An application requires to write 10 items with each item being 20 KB in size 
per second. What should be set as the write throughput for the application? 
Solution 
Number of write capacity units required = 
20 KB * 10 = 200 
Answer

Provisioned Mode:

In this mode, you specify the number of reads and writes per second that you require for your application. You can use auto scaling to adjust your table’s provisioned capacity automatically in response to traffic changes. This helps you govern your DynamoDB use to stay at or below a defined request rate in order to obtain cost predictability.

Provisioned mode is a good option if any of the following are true: 

  • You have predictable application traffic. 
  • You run applications whose traffic is consistent or ramps gradually. 
  • You can forecast capacity requirements to control costs. 

When calling DescribeTable on an on-demand table, read capacity units and write capacity units are set to 0. 

If your application reads or writes larger items (up to the DynamoDB maximum item size of 400 KB), it will consume more capacity units. 

For example, suppose that you create a provisioned table with 6 read capacity units and 6 write capacity units. With these settings, your application could do the following: 

  • Perform strongly consistent reads of up to 24 KB per second (4 KB × 6 read capacity units). 
  • Perform eventually consistent reads of up to 48 KB per second (twice as much read throughput). 
  • Perform transactional read requests of up to 3 KB per second. 
  • Write up to 6 KB per second (1 KB × 6 write capacity units). 
  • Perform transactional write requests of up to 3 KB per second. 

Note: Provisioned throughput is the maximum amount of capacity that an application can consume from a table or index. If your application exceeds your provisioned throughput capacity on a table or index, it is subject to request throttling.  Throttling prevents your application from consuming too many capacity units. When a request is throttled, it fails with an HTTP 400 code (Bad Request) and a ProvisionedThroughputExceededException.  



Categories: Amazon AWS, DynamoDB

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: