Question

Difficulty: Very hardData Store Operations with Amazon DynamoDB

A developer is designing an integration for an IoT system that logs temperature metrics to an Amazon DynamoDB table. The table uses `SensorId` as the partition key and `Timestamp` as the sort key. A Lambda function executes a `Query` operation to retrieve metrics for a specific `SensorId` over a 24-hour period.

The query matches exactly 100 items, and each item has an average size of 5 KB5\text{ KB}. The operation uses a `FilterExpression` to only return the 20 items where the `AlertStatus` attribute is set to `RED`. Additionally, a `ProjectionExpression` is used to limit the returned attributes to `Timestamp` and `Reading`, reducing the payload size of each returned item to 1.5 KB1.5\text{ KB}.

If the query is configured to use strongly consistent reads and the Lambda function must handle 10 queries per second, what is the minimum read capacity units (RCUs) that must be provisioned for the table to prevent throttling?

  1. A
    625 RCU625\text{ RCU}
  2. 1250 RCU1250\text{ RCU}Answer
  3. C
    250 RCU250\text{ RCU}
  4. D
    80 RCU80\text{ RCU}

Answer

The minimum read capacity units (RCUs) that must be provisioned is 1250 RCU1250\text{ RCU}.
The correct answer is 1250 RCU1250\text{ RCU}. In Amazon DynamoDB, read capacity calculations are based on the amount of data read from the table before any FilterExpression or ProjectionExpression is applied. The query matches 100 items with an average size of 5 KB5\text{ KB}, resulting in a total evaluated data size of 500 KB500\text{ KB}. Since the query uses strongly consistent reads, each RCU provides one read per second for an item up to 4 KB4\text{ KB}. Thus, a single query requires 500 KB/4 KB=125500\text{ KB} / 4\text{ KB} = 125 read operations. To support 10 queries per second, the minimum provisioned capacity required is 125×10=1250 RCU125 \times 10 = 1250\text{ RCU}.

Step-by-Step Solution

1
Determine the total data size evaluated by the Query operation.
The total evaluated size is 100×5 KB=500 KB100 \times 5\text{ KB} = 500\text{ KB}.
DynamoDB calculates read capacity based on the size of all items that match the key condition expression, before any FilterExpression or ProjectionExpression is applied.
2
Calculate the read operations required for a single query.
500 KB/4 KB=125500\text{ KB} / 4\text{ KB} = 125 read operations.
For strongly consistent reads, one read operation is consumed for every 4 KB4\text{ KB} of data read, rounded up.
3
Calculate the total provisioned RCU needed per second.
125 read operations×10 queries/sec=1250 RCU125 \text{ read operations} \times 10 \text{ queries/sec} = 1250\text{ RCU}.
Read Capacity Units are provisioned per second, so the single-query requirement must be multiplied by the query rate.

Key Concept

DynamoDB read capacity unit calculation behaves independently of projection and filter expressions.
Rate this question