Question

Difficulty: MediumApplication Caching and Session State Management

A developer is troubleshooting performance issues on a web application where user session state is stored in an Amazon DynamoDB table. During high-traffic events, users frequently experience session timeouts and slow page loads. The application logs show numerous `ProvisionedThroughputExceededException` errors during session read and write operations. The developer confirms that the table has a partition key of `SessionId` and a sort key of `LastActiveTime`.

Which TWO strategies should the developer implement to optimize session state management and resolve the throughput issues? (Select TWO.)

  1. Enable Amazon DynamoDB Time to Live (TTL) on the table using a dedicated attribute that stores the session expiration timestamp in Unix epoch format.Answer
  2. Modify the application logic to retrieve session items using DynamoDB GetItem or Query operations targeting the SessionId partition key.Answer
  3. C
    Migrate the session state storage to AWS Systems Manager Parameter Store and configure the application to retrieve sessions via the Parameter Store API.
  4. D
    Continuously increase the provisioned read and write capacity units of the DynamoDB table without altering how the application queries or deletes session data.
  5. E
    Implement a scheduled daily Lambda function that runs a Scan operation on the table to identify expired sessions and deletes them using BatchWriteItem calls.

Answer

Enable Amazon DynamoDB Time to Live (TTL) on the table using a dedicated epoch timestamp attribute and modify the application logic to retrieve session items using targeted DynamoDB GetItem or Query operations.
Enabling DynamoDB Time to Live (TTL) is an architectural best practice for session data since it automatically deletes expired items without consuming read or write capacity units. Additionally, querying the table directly by the SessionId partition key ensures that the database only retrieves the specific item requested, minimizing Read Capacity Unit (RCU) consumption and reducing latency.

Step-by-Step Solution

1
Analyze error logs to determine the cause of performance issues.
Identify that the ProvisionedThroughputExceededException errors are caused by inefficient data access patterns and expired data accumulation.
Before applying optimizations, it is necessary to identify the root cause of the DynamoDB throttling.
2
Enable DynamoDB Time to Live (TTL) on the table.
DynamoDB automatically deletes expired sessions behind the scenes without consuming provisioned write capacity.
This removes the need for expensive scan-and-delete processes to clean up stale session data.
3
Refactor application queries to perform direct lookups using the key schema.
The application retrieves session state using GetItem or Query operations on the SessionId partition key, which execute in O(1) time.
This prevents table scans and dramatically reduces Read Capacity Unit (RCU) consumption.

Key Concept

Optimizing DynamoDB throughput for session state management using TTL and key-based lookups instead of scans.
Estimated Time:2m 0s
Rate this question