Question

Difficulty: MediumImplement Azure Cache for Redis Configuration and Data Patterns

An application uses Azure Cache for Redis to store both temporary catalog search results and active shopping cart details. The transient catalog search results are configured with a defined Time-to-Live (TTL), while the shopping cart details are stored without a TTL. During periods of peak traffic, the cache memory becomes fully utilized. You must ensure that the Redis instance evicts the catalog search results based on a least-recently-used (LRU) algorithm when the memory limit is reached, while preserving all shopping cart details. In addition, you must reserve memory for replication and fragmentation overhead to prevent out-of-memory (OOM) conditions.

Which two configuration settings should you configure to meet these requirements?

  1. Set the maxmemory-policy configuration setting to volatile-lruAnswer
  2. Configure a non-zero value for the maxmemory-reserved settingAnswer
  3. C
    Set the maxmemory-policy configuration setting to allkeys-lru
  4. D
    Set the maxmemory-policy configuration setting to noeviction
  5. E
    Set the maxmemory-policy configuration setting to volatile-ttl

Answer

Setting the maxmemory-policy configuration setting to volatile-lru and configuring a non-zero value for the maxmemory-reserved setting.
The correct configurations are setting the eviction policy to volatile-lru and configuring a non-zero value for the maxmemory-reserved setting. The volatile-lru policy ensures that under memory pressure, only keys with an active expiration (TTL) set are evaluated and evicted using a least-recently-used (LRU) algorithm, preserving keys without an expiration. Configuring the maxmemory-reserved setting allocates dedicated memory for replication and fragmentation overhead, preventing out-of-memory conditions on the instance.

Step-by-Step Solution

1
Analyze the eviction requirements for keys with and without a TTL.
Determine that keys without a TTL (shopping cart details) must be protected, while keys with a TTL (search results) are eligible for LRU eviction.
This narrows the eviction policy choice to 'volatile' policies, specifically excluding 'allkeys' policies which evict any key regardless of expiration status.
2
Select the correct eviction algorithm based on the scenario description.
Identify 'volatile-lru' as the configuration that applies the least-recently-used algorithm only to keys with an expiration.
The scenario requires a least-recently-used (LRU) algorithm for eviction, making volatile-lru correct and volatile-ttl incorrect.
3
Address the requirement to prevent out-of-memory (OOM) conditions caused by overhead.
Identify that reserving memory using the 'maxmemory-reserved' setting secures space for replication and fragmentation.
Azure Cache for Redis provides the 'maxmemory-reserved' setting specifically to allocate memory for non-cache overhead and operations.

Key Concept

Azure Cache for Redis eviction policies and memory reservation configuration.
Rate this question