Question

Difficulty: MediumApplication Caching and Session State Management

A developer is designing a web application that will be hosted on Amazon ECS. The application requires a shared session state store to support horizontal scaling of container instances. The session data consists of semi-structured JSON documents that are updated frequently with each user request. The session documents must automatically expire and be deleted after 24 hours of inactivity to keep storage costs low. Which solution meets these requirements with the lowest operational overhead?

  1. Store the session data in an Amazon DynamoDB table, and enable DynamoDB Time to Live (TTL) on an attribute containing the expiration timestamp.Answer
  2. B
    Store the session data in an Amazon DynamoDB table, and create a scheduled AWS Lambda function that performs a Scan operation daily to delete expired session records.
  3. C
    Store the session data in AWS Systems Manager Parameter Store, using a hierarchical path structure like /sessions/{session_id} to retrieve and update session JSON values.
  4. D
    Store the session data in an Amazon DynamoDB table using a single static partition key value to simplify retrieval, and scale up the provisioned Write Capacity Units (WCUs) during peak hours.

Answer

Store the session data in an Amazon DynamoDB table, and enable DynamoDB Time to Live (TTL) on an attribute containing the expiration timestamp.
Storing session data in Amazon DynamoDB and enabling Time to Live (TTL) provides a fully managed, highly scalable solution. DynamoDB automatically deletes expired items based on a timestamp attribute without consuming provisioned throughput or requiring custom application logic.

Step-by-Step Solution

1
Evaluate the session state storage requirements: high-frequency writes, semi-structured documents, automatic expiration, and low operational overhead.
Amazon DynamoDB is identified as a suitable NoSQL database because it natively supports JSON documents and auto-scaling, and offers a built-in Time to Live (TTL) feature.
DynamoDB TTL automatically deletes expired items based on an epoch timestamp attribute without consuming any read or write capacity units.
2
Assess alternative deletion mechanisms like a scheduled AWS Lambda function running a DynamoDB Scan.
The Scan-and-delete approach is rejected because Scan operations scan the entire database table, leading to high resource utilization and cost.
Using Scan violates the requirement for low operational overhead and cost efficiency.
3
Evaluate using Systems Manager Parameter Store and a static partition key design in DynamoDB.
Parameter Store is rejected due to API throttling limits, and the static key design is rejected because it creates a hot partition.
These solutions fail to scale horizontally and lead to performance degradation under load.

Key Concept

Session State Management using Amazon DynamoDB and Time to Live (TTL)
Rate this question