Question

Difficulty: HardResolving DynamoDB Throttling and Key Distribution Issues

A logistics tracking application named PackTrack records real-time delivery status updates for packages. The underlying Amazon DynamoDB table uses `PackageID` as the partition key and `StatusTimestamp` as the sort key. A fleet monitoring dashboard needs to display all deliveries that are currently delayed. To retrieve this data, the dashboard runs a weekly batch process using a `Scan` operation with a `FilterExpression` on the `DeliveryStatus` attribute where the value equals `DELAYED`. As package volume increases, the scan operation consistently throws `ProvisionedThroughputExceededException` errors, causing the dashboard to load partially or fail entirely, despite the developer scaling up the table's read capacity units (RCUs). Which of the following is the most cost-effective and appropriate solution to resolve this throttling issue?

  1. Create a Global Secondary Index (GSI) with DeliveryStatus as the partition key and StatusTimestamp as the sort key, and update the dashboard to query the GSI instead of scanning the base table.Answer
  2. B
    Configure AWS Application Auto Scaling to dynamically increase the provisioned Read Capacity Units (RCUs) of the base table to handle the capacity spike.
  3. C
    Modify the dashboard batch process to run a parallel Scan with multiple segments executing concurrently to distribute the read load across partitions.
  4. D
    Integrate an Amazon SQS queue to buffer the dashboard requests, and set the queue's visibility timeout to be shorter than the processing time to guarantee rapid message delivery.

Answer

Create a Global Secondary Index (GSI) with DeliveryStatus as the partition key and StatusTimestamp as the sort key, and update the dashboard to query the GSI instead of scanning the base table.
The correct option is to create a Global Secondary Index (GSI) with DeliveryStatus as the partition key and query it. A Scan operation in DynamoDB reads every item in the table and then applies the filter, which consumes massive amounts of Read Capacity Units (RCUs) and leads to throttling as the table grows. By creating a GSI with DeliveryStatus as the partition key, the application can perform a Query operation instead. A Query only reads the items that match the partition key, consuming significantly fewer RCUs and resolving the throttling issue in a cost-effective manner.

Step-by-Step Solution

1
Analyze the cause of the ProvisionedThroughputExceededException.
Identify that the dashboard is using a Scan operation with a FilterExpression to locate specific records (delayed packages) rather than querying them directly.
Scan operations read the entire table before filtering out results, which consumes RCUs proportional to the size of the table rather than the number of matching items.
2
Select a strategy to convert the Scan into a Query.
Since the partition key of the base table is PackageID (high cardinality but not matching the query criteria), a secondary index is required to query by DeliveryStatus.
A Global Secondary Index (GSI) allows redefining the partition key to DeliveryStatus, enabling efficient Query operations.
3
Create the GSI and update the application logic.
Create a GSI with DeliveryStatus as the partition key and StatusTimestamp as the sort key. Modify the dashboard code to execute a Query against this GSI.
Querying the GSI retrieves only the relevant items matching 'DELAYED', which dramatically reduces RCU consumption and resolves throttling.

Key Concept

Resolving DynamoDB throttling issues by replacing inefficient Scan operations with targeted Query operations on a Global Secondary Index (GSI).
Rate this question