Question

Difficulty: MediumApplication Caching and Session State Management

A developer is optimizing a high-traffic web application that stores user session data in an Amazon DynamoDB table. The application frequently retrieves session data by searching for the user's email address, which is not the table's primary key. During peak traffic hours, the application logs show numerous ProvisionedThroughputExceededException errors and users experience high latency. Which TWO actions should the developer take to resolve these issues and improve performance? (Select TWO.)

  1. Configure a Global Secondary Index (GSI) on the DynamoDB table with the email address as the partition key, and use the Query API instead of the Scan API to retrieve session data.Answer
  2. Implement Amazon ElastiCache for Redis to store and manage active user session states, offloading the frequent read and write operations from the DynamoDB table.Answer
  3. C
    Scale up the provisioned write and read capacity units (WCUs and RCUs) on the DynamoDB table to accommodate the increased traffic during peak hours.
  4. D
    Implement a scheduled AWS Lambda function that performs a daily Scan operation on the DynamoDB table and caches the session data in Amazon Systems Manager Parameter Store.
  5. E
    Hardcode the database and cache credentials in the application's source code and pass them directly during the AWS SDK client initialization.

Answer

Configure a Global Secondary Index (GSI) on the DynamoDB table with the email address as the partition key to Query the data, and implement Amazon ElastiCache for Redis to store and manage active user session states.
The correct options are to configure a Global Secondary Index (GSI) on the DynamoDB table with the email address as the partition key, using the Query API instead of the Scan API, and to implement Amazon ElastiCache for Redis to store and manage active session states. A GSI allows querying on the non-key email attribute efficiently, while ElastiCache for Redis provides an in-memory store that handles frequent session writes and reads with sub-millisecond latency.

Step-by-Step Solution

1
Analyze the cause of the performance degradation and throttling.
The application is searching by email, which is a non-key attribute. This triggers inefficient full table Scan operations that exhaust read capacity.
Understanding the access pattern is necessary to choose the correct optimization strategy.
2
Address the inefficient querying on the non-key attribute.
Create a Global Secondary Index (GSI) using the email address as the partition key, allowing the use of Query instead of Scan.
GSIs enable lookup on non-key attributes with low latency and optimal capacity unit utilization.
3
Offload transient session state storage from the relational or primary database layer.
Introduce Amazon ElastiCache for Redis as a dedicated session store.
Caching active sessions in-memory provides sub-millisecond latency, scales horizontally, and removes unnecessary read/write load from DynamoDB.

Key Concept

Optimizing session state storage and application performance using Amazon DynamoDB Global Secondary Indexes and Amazon ElastiCache for Redis.
Rate this question