Soru

Zorluk: OrtaApplication Caching and Session State Management

A developer is designing a high-traffic web application that will be deployed on Amazon ECS. The application requires a highly available session state store that can handle complex data structures, such as lists and sets, with sub-millisecond latency. The session data must be replicated across multiple Availability Zones, and any session that is inactive for more than 2 hours must be automatically removed.

Which TWO solutions or configurations should the developer implement to meet these requirements?

  1. Use Amazon ElastiCache for Redis with a multi-node cluster configuration across multiple Availability Zones.Cevap
  2. Use the Redis EXPIRE command to set a Time to Live (TTL) of 7200 seconds on each session key when it is created or updated.Cevap
  3. C
    Use Amazon Cognito Identity Pools to store and synchronize the user session state data directly across the ECS tasks.
  4. D
    Store the session states in an Amazon DynamoDB table and implement a scheduled AWS Lambda function that performs a Scan operation every hour to locate and delete expired sessions.
  5. E
    Store the session states in Amazon Systems Manager Parameter Store and configure Parameter Store policies to delete the parameters after 2 hours.

Cevap

Use Amazon ElastiCache for Redis with a multi-node cluster configuration across multiple Availability Zones, and use the Redis EXPIRE command to set a Time to Live (TTL) of 7200 seconds on each session key.
The developer should use Amazon ElastiCache for Redis and the Redis EXPIRE command. Amazon ElastiCache for Redis is an in-memory database that natively supports complex data structures (like lists and sets), features multi-AZ replication for high availability, and provides sub-millisecond latencies. Setting a TTL of 7200 seconds (2 hours) using the Redis EXPIRE command handles the automatic expiration of inactive sessions cleanly and natively within the cache.

Adım Adım Çözüm

1
Evaluate key data store requirements: sub-millisecond latency, replication across multiple Availability Zones, and support for complex data structures like lists and sets.
Identify that Amazon ElastiCache for Redis meets all these criteria, whereas Memcached lacks native multi-AZ replication for session states, and DynamoDB is not suited for sub-millisecond caching without DAX.
Redis is a high-performance in-memory data store that natively supports replication, clustering, and rich data structures.
2
Address the session expiration requirement of 2 hours (7200 seconds) of inactivity.
Determine that setting a Time to Live (TTL) using the Redis EXPIRE command is the optimal, low-overhead way to automatically clean up expired keys.
The Redis EXPIRE command ensures that keys are automatically evicted from memory after the specified duration, freeing up resources without application-side polling.

Anahtar Kavram

Selecting ElastiCache for Redis for high-availability session caching with complex data structures and managing expiration via TTL.
Bu soruyu puanla