A developer is building a vehicle fleet tracking application that stores telemetry data in an Amazon DynamoDB table. The table is configured with a partition key of `` and a sort key of ``. The application needs to support two access patterns: retrieving the history of a specific vehicle within a given time range, and retrieving telemetry records matching a specific `` across the entire fleet of vehicles. Some partitions are experiencing throttling due to high-frequency read requests.
Which two actions should the developer take to implement these queries efficiently and resolve the throttling issue?
- Create a Global Secondary Index (GSI) with a partition key of `` to query speeding violations across all vehicles.Cevap
- Use the `Query` API operation on the base table with a key condition expression specifying the `` and a range condition on the ``.Cevap
- CUse a `Scan` API operation on the base table with a `FilterExpression` on the `` attribute to identify speeding violations across all vehicles.
- DIncrease the overall provisioned Read Capacity Units (RCUs) of the base table to mitigate the partition throttling issues.
- EInitialize the AWS SDK DynamoDB client inside the application by hardcoding an IAM user's access keys to ensure authorized access to the table.
Cevap
Create a Global Secondary Index (GSI) with a partition key of speed, and use the Query API operation on the base table with a key condition expression specifying the vehicle identifier and a range condition on the timestamp.
The correct approach involves using the Query API operation on the base table to retrieve a vehicle's history because it targets a single partition key and filters by the sort key range efficiently. Additionally, to retrieve records by speed across all vehicles, a Global Secondary Index (GSI) must be created with speed as the partition key, which allows executing Query operations rather than scanning the entire table.
Adım Adım Çözüm
Anahtar Kavram
DynamoDB querying and indexing strategies using Query operations and Global Secondary Indexes (GSIs) to optimize performance and prevent hot partitions.