Soru

Zorluk: OrtaApplication Caching and Session State Management

A developer is refactoring a web application that runs on an Auto Scaling group of Amazon EC2 instances. The application currently stores user session state in the memory of individual instances, which causes users to lose their sessions when the Auto Scaling group scales in. The session data contains nested JSON objects representing user preferences and search history. The developer wants to store these sessions in a shared, highly available cache that supports automatic expiration of idle sessions after 30 minutes. Which solution meets these requirements with the best performance and lowest operational overhead?

  1. A
    Configure AWS Systems Manager Parameter Store to store each user's session state as a parameter, and retrieve the parameters using the AWS SDK on each request.
  2. Configure an Amazon ElastiCache for Redis cluster to store the session state, and set a Time to Live (TTL) of 1800 seconds on the session keys.Cevap
  3. C
    Store the session state in an Amazon DynamoDB table, and configure a scheduled AWS Lambda function that performs a Scan operation on the table every 30 minutes to identify and delete expired sessions.
  4. D
    Store the session state in a single Amazon DynamoDB table, and continuously scale up the table's provisioned read and write capacity units to handle the throughput spikes instead of enabling table TTL.

Cevap

Configure an Amazon ElastiCache for Redis cluster to store the session state, and set a Time to Live (TTL) of 1800 seconds on the session keys.
Storing session state in an Amazon ElastiCache for Redis cluster is an ideal solution. Redis is an in-memory data store that offers sub-millisecond latency, supports complex data structures (like nested JSON, lists, and sets), and provides native key expiration (TTL) which can be set to 1800 seconds (30 minutes) to automatically expire idle sessions.

Adım Adım Çözüm

1
Analyze the application requirements.
The solution must support shared, highly available session storage, support complex/nested data structures (nested JSON objects), and automatically expire sessions after 30 minutes (1800 seconds) with the lowest latency and operational overhead.
This establishes the criteria for selecting the appropriate service and configuration.
2
Evaluate the storage and caching options against these criteria.
Systems Manager Parameter Store is not designed for session state. Storing sessions in DynamoDB with a manual Scan-based cleanup is inefficient. Scaling up DynamoDB capacity manually is costly and does not manage session expiration. ElastiCache for Redis supports in-memory speed, complex data structures, and native TTL expiration.
This eliminates the incorrect architectural patterns and identifies the correct service.
3
Determine the correct configuration for the chosen service.
An ElastiCache for Redis cluster with a key TTL of 1800 seconds (30 minutes) satisfies all requirements.
This defines the final implementation details for the session caching mechanism.

Anahtar Kavram

The core concept is offloading session state management from application servers (EC2 instances) to a shared, high-performance in-memory cache like Amazon ElastiCache for Redis, which natively supports complex data types and key expiration (TTL) to handle session lifetimes.
Bu soruyu puanla