A developer is designing the backend for a multiplayer game where the game session state is stored in an Amazon DynamoDB table. The table structure is defined as follows:
- Partition key: `` (String)
- Sort key: `` (String)
- Attributes: `` (Number), `` (String), `` (Map, size )
The application must support the following requirements:
1. Retrieve the top highest scores for a specific `` in real-time with strong consistency.
2. Every , retrieve a list of all active sessions (where `` is ) to display on a public lobby dashboard. The number of active sessions is typically small (fewer than at any time), but the table contains millions of completed sessions.
3. Minimize provisioned write capacity consumption. Players update their `` and `` frequently (up to per session).
Which two configurations should the developer implement to meet these requirements with the lowest latency and cost?
- Create a Local Secondary Index (LSI) with `` as the partition key and `` as the sort key. Configure the LSI projection to `KEYS_ONLY` to prevent the `` attribute from being copied, thereby minimizing write capacity consumption during score updates.Cevap
- Create a Global Secondary Index (GSI) with `` as the partition key and `` as the sort key, configured with `KEYS_ONLY` projection. In the application, set `` to when starting a session, and delete the `` attribute when the session completes.Cevap
- CCreate a GSI with `` as the partition key and project all (`ALL`) attributes. When players update their score, resolve any write throttling on the base table by scaling up the base table's provisioned write capacity units, assuming the limit is due to the overall table capacity.
- DPerform a `Scan` operation on the base table with a `FilterExpression` of ` = 'ACTIVE'` to populate the dashboard, and use a local cache inside the application to reduce the query frequency to once every .
- EIn the AWS Lambda function that updates scores, initialize the DynamoDB client by hardcoding the AWS Access Key ID and Secret Access Key of a dedicated IAM user with full DynamoDB permissions to bypass IAM role assumption latency and optimize write performance.