Question

Difficulty: HardData Store Operations with Amazon DynamoDB

A developer is optimizing a backend order-management microservice for a high-volume retail application. The application stores order details in an Amazon DynamoDB table. The base table has `CustomerID` as the partition key and `OrderID` as the sort key. The average size of an item in the base table is 10 KB10\text{ KB}.

The developer needs to support a new dashboard feature that frequently retrieves the `OrderID`, `OrderDate`, and `TotalAmount` for all orders that have an `OrderStatus` of `BACKORDERED`. These results must be returned chronologically by `OrderDate`. The dashboard is expected to perform 8080 individual query requests per second, each retrieving a single order's projected fields. The dashboard can tolerate eventually consistent data. The average size of the projected attributes (`OrderID`, `OrderDate`, `TotalAmount`) along with the primary keys is 1.5 KB1.5\text{ KB}.

Which configuration will meet these requirements with the lowest latency and lowest provisioned Read Capacity Units (RCUs)?

  1. A
    Create a Global Secondary Index (GSI) with `OrderStatus` as the partition key and `OrderDate` as the sort key. Configure the GSI projection type to `ALL`. Provision 120 RCUs120\text{ RCUs} for the GSI.
  2. Create a Global Secondary Index (GSI) with `OrderStatus` as the partition key and `OrderDate` as the sort key. Configure the GSI projection type to `INCLUDE` and project `TotalAmount`. Provision 40 RCUs40\text{ RCUs} for the GSI.Answer
  3. C
    Perform a Scan operation on the base table using a FilterExpression on `OrderStatus` to filter for `BACKORDERED` items, and provision 200 RCUs200\text{ RCUs} on the base table.
  4. D
    Configure the application to query the base table using a FilterExpression on `OrderStatus`, initializing the DynamoDB client by passing hardcoded IAM Access Keys directly into the AWS SDK client constructor.

Answer

Create a Global Secondary Index (GSI) with OrderStatus as the partition key and OrderDate as the sort key. Configure the GSI projection type to INCLUDE and project TotalAmount. Provision 40 RCUs for the GSI.
The correct answer recommends creating a Global Secondary Index (GSI) with `OrderStatus` as the partition key and `OrderDate` as the sort key, projecting only the required attributes (`TotalAmount`) via `INCLUDE`. Because the dashboard needs to query across all customers for a specific status, a GSI is required. By projecting only the necessary fields, the index item size remains small (1.5 KB1.5\text{ KB}), which rounds up to 4 KB4\text{ KB} for capacity calculations. For eventually consistent reads, each 4 KB4\text{ KB} read request consumes 0.5 RCU0.5\text{ RCU} (1 RCU1\text{ RCU} per 2 reads/sec). Therefore, performing 8080 reads per second requires exactly 40 RCUs40\text{ RCUs}.

Step-by-Step Solution

1
Determine the correct indexing strategy to query across different partition keys.
A Global Secondary Index (GSI) with `OrderStatus` as the partition key and `OrderDate` as the sort key is selected.
The base table's partition key is `CustomerID`, but the queries do not specify a customer. An LSI cannot cross partitions, so a GSI is required to query by `OrderStatus` and sort by `OrderDate` across the entire table.
2
Determine the optimal projection type for the GSI to minimize item size.
The GSI is configured with projection type `INCLUDE` containing the `TotalAmount` attribute.
Projecting only `TotalAmount` keeps the GSI item size small (1.5 KB1.5\text{ KB}), because the base table keys (`CustomerID`, `OrderID`) and the GSI keys (`OrderStatus`, `OrderDate`) are automatically projected.
3
Calculate the required Read Capacity Units (RCUs) for the projected index.
The RCU calculation results in 40 RCUs40\text{ RCUs} for the GSI.
The projected item size is 1.5 KB1.5\text{ KB}, which rounds up to the next 4 KB4\text{ KB} increment (4 KB4\text{ KB}). For eventually consistent reads, 1 RCU performs 2 reads per second. To support 8080 reads per second: RCUs=80/2=40\text{RCUs} = 80 / 2 = 40.

Key Concept

DynamoDB index selection and Read Capacity Unit (RCU) optimization based on attribute projection and consistency models.
Estimated Time:2m 30s
Rate this question