Soru

Zorluk: OrtaData Store Operations with Amazon DynamoDB

A developer is optimization-tuning an e-commerce order processing system. The order data is stored in an Amazon DynamoDB table where the primary key consists of OrderIdOrderId (partition key) and OrderDateOrderDate (sort key). The application frequently retrieves all orders placed by a specific user within a given date range. Currently, the application retrieves this data by performing a Scan operation with a FilterExpression on the UserIdUserId and OrderDateOrderDate attributes, which has caused high latency and read capacity exhaustion. Which two actions should the developer take to resolve these issues? (Select TWO.)

  1. Create a Global Secondary Index (GSI) with UserId as the partition key and OrderDate as the sort key.Cevap
  2. Configure the application to perform Query operations against the newly created Global Secondary Index using UserId as the key condition.Cevap
  3. C
    Modify the application to perform a parallel Scan on the base table using a Segment parameter to divide the workload.
  4. D
    Increase the provisioned read capacity units (RCUs) of the base table to prevent read throttling during peak Scan requests.
  5. E
    Hardcode an IAM user's Access Key and Secret Key with DynamoDBFullAccess permissions in the application configuration to ensure scan requests never fail due to authorization issues.

Cevap

Create a Global Secondary Index (GSI) with UserId as the partition key and OrderDate as the sort key, and configure the application to perform Query operations against the GSI using UserId as the key condition.
The correct approach involves creating a Global Secondary Index (GSI) that designates the search attribute as the partition key and the range attribute as the sort key, and then updating the application to run targeted Query operations on this index. This eliminates the need to scan the entire base table, reducing both latency and Read Capacity Unit (RCU) consumption.

Adım Adım Çözüm

1
Analyze the access pattern to determine the partition and sort keys needed for target data retrieval.
Identified that the application needs to retrieve items by UserId (which is currently a non-key attribute) and filter/sort by OrderDate.
Designing secondary indexes requires mapping the access pattern requirements to secondary partition and sort keys.
2
Define and create a Global Secondary Index (GSI) on the DynamoDB table.
A GSI is created with UserId as the partition key and OrderDate as the sort key.
A GSI allows queries on non-key attributes from the base table, establishing a new partition structure for efficient lookups.
3
Update the application code to replace the Scan operation with a Query operation against the GSI.
The application issues a Query request with KeyConditionExpression specifying the UserId and KeyConditions for the OrderDate range.
Using Query instead of Scan limits the operation to the target partition, minimizing both read latency and RCU consumption.

Anahtar Kavram

Optimizing DynamoDB data retrieval by replacing table scans with targeted queries on a Global Secondary Index (GSI).
Bu soruyu puanla