Question

Difficulty: MediumImplement Azure Cache for Redis Configuration and Data Patterns

A developer is configuring a Premium tier Azure Cache for Redis instance for a retail e-commerce application. The cache stores two types of data: product inventory levels (which are critical and must never be evicted, and do not have an expiration time set) and user search queries (which have an expiration time set). Under memory pressure, the system must only evict search query data while preserving all product inventory levels. Additionally, you must reserve memory for background processes to ensure stable replication and failover operations. Which two configuration settings should you implement to meet these requirements?

  1. Configure the maxmemory-policy setting to volatile-lfuAnswer
  2. Configure the maxmemory-reserved setting to allocate memory for non-data operationsAnswer
  3. C
    Configure the maxmemory-policy setting to allkeys-lfu
  4. D
    Configure the maxmemory-policy setting to allkeys-random

Answer

To configure the Azure Cache for Redis instance correctly, you should set the maxmemory-policy setting to volatile-lfu and configure the maxmemory-reserved setting to allocate memory for non-data operations.
Configuring volatile-lfu ensures that only keys with an expiration time set (the transient search queries) are evicted when the cache is full. Configuring maxmemory-reserved ensures that a portion of memory is reserved for non-cache operations such as replication and clustering overhead, preventing out-of-memory errors during failovers.

Step-by-Step Solution

1
Identify that product inventory levels do not have an expiration time (TTL) set, whereas search query data does.
Product inventory levels require protection from eviction policies that target non-expiring keys.
This establishes the logical constraint for selecting the eviction policy.
2
Choose an eviction policy prefixed with 'volatile-' (such as volatile-lfu) so that only keys with a TTL are eligible for eviction.
Keys without a TTL (such as product inventory levels) are protected from being evicted.
This ensures the transient search query data is sacrificed under memory pressure while keeping critical data.
3
Determine the need to reserve memory for overhead activities like replication and failover, and configure the maxmemory-reserved setting.
Dedicated memory is set aside for replication and fragmentation purposes.
This guarantees stability during failovers and high-write loads.

Key Concept

Memory eviction policies and memory reservation in Azure Cache for Redis
Estimated Time:1m 30s
Rate this question