Question

Difficulty: MediumData Store Operations with Amazon DynamoDB

A developer is building a backend service for a food delivery application. The service needs to store and query customer order history in an Amazon DynamoDB table. The table is structured with `CustomerId` as the partition key and `OrderTimestamp` as the sort key. The developer also needs to perform bulk updates of restaurant menus daily, uploading up to 2,0002,000 menu items. The developer wants to optimize application performance, minimize DynamoDB capacity consumption, and ensure secure credential management.

Which two strategies should the developer implement? (Select two.)

  1. Use the `Query` API operation with the `CustomerId` and a key condition expression on `OrderTimestamp` to retrieve a customer's order history.Answer
  2. Use the `BatchWriteItem` API operation to perform the bulk menu updates, grouping the write requests in batches of up to 2525 items.Answer
  3. C
    Use the `Scan` API operation with a `FilterExpression` on `CustomerId` and `OrderTimestamp` to locate and retrieve the customer's orders.
  4. D
    Embed the AWS access key and secret access key directly in the application configuration to initialize the DynamoDB client.
  5. E
    Increase the table's provisioned write capacity units (WCUs) immediately if `ProvisionedThroughputExceededException` errors occur during bulk updates, without analyzing partition key distribution.

Answer

The developer should use the Query API operation to retrieve a customer's order history and the BatchWriteItem API operation to perform the bulk menu updates.
The correct strategies are to use the Query API for order retrieval and the BatchWriteItem API for bulk menu updates. Using Query targets the specific partition key directly, optimizing read performance. Using BatchWriteItem bundles multiple write requests into a single network round trip, reducing API overhead.

Step-by-Step Solution

1
Determine the most efficient retrieval method for order history using the known schema.
Since CustomerId is the partition key and OrderTimestamp is the sort key, a Query operation can target a specific CustomerId partition directly.
Querying is more efficient than scanning because it only reads the partition of interest, saving Read Capacity Units (RCUs) and lowering latency.
2
Select the appropriate API for bulk writing menu items.
The BatchWriteItem API is selected to group up to 2525 PutItem or DeleteItem requests.
This minimizes the number of HTTPS requests, reduces overhead, and optimizes Write Capacity Unit (WCU) consumption during batch uploads.
3
Address credential security and potential throttling errors during writes.
Use IAM roles and the default credential provider chain instead of hardcoded keys, and analyze partition key distribution if write exceptions occur.
Hardcoding keys is insecure, and partition throttling must be solved by distributing keys evenly rather than globally increasing provisioned throughput.

Key Concept

Efficient DynamoDB retrieval using Query rather than Scan, batching writes using BatchWriteItem, and adhering to AWS credential and partition scaling best practices.
Rate this question