Home › Studies › AI-200 › AI Data Services › Azure Managed Redis

Azure Managed Redis

Caching · expiration and eviction · invalidation · connection practices · clustering policies · RediSearch vector indexing

By the tools4free.dev team · Last reviewed November 13, 2026

Practice questions for this topic →

Azure Managed Redis basics

Azure Managed Redis is an in-memory data store based on Redis Enterprise software. It supports Redis version 7.4.x. Four tiers are available.

TierMemory-to-vCPUNotes
Memory Optimized8:1High memory, lower throughput; lower price point, good for dev and test.
Balanced4:1Standard workloads: balance of memory and compute.
Compute Optimized2:1Performance-intensive workloads that need maximum throughput.
Flash Optimized-Moves less frequently accessed data from RAM to NVMe storage. No search (so no vector search), no active geo-replication, no non-clustered instances.
Python connection (redis-py)Detail
Packagesredis, redis-entraid, azure-identity
Port10000 for Azure Managed Redis and Enterprise caches; 6380 for Azure Cache for Redis.
Credentialcreate_from_default_azure_credential(("https://redis.azure.com/.default",),)
Clientredis.Redis(host=redis_host, port=redis_port, ssl=True, decode_responses=True, credential_provider=credential_provider)
Operationsr.ping(), r.set("Message", "Hello from Azure Managed Redis!"), r.get("Message")
AccessYou must add yourself (or a system principal) as a Redis user on the cache.

Caching, expiration and invalidation

Cache-aside

  1. The application tries to read the item from the cache.
  2. On a cache miss, it reads the item from the data store.
  3. It adds the item to the cache and returns it.
  4. On an update, it writes to the data store and then invalidates the cached item. The next read reloads it.
Memory settingRule
Default eviction policyvolatile-lru: only keys with a TTL (for example set with EXPIRE) can be evicted. If no keys have a TTL, nothing is evicted.
Allow any key to be evictedallkeys-lru
ExpirationSet an expiration on keys. It removes keys proactively instead of waiting for memory pressure; eviction under pressure adds load to the server.
Expiration costKeys with a TTL use extra memory for expiration bookkeeping.
Used Memory metricIncludes all shards and, with high availability, primary and replica memory: it can be about twice the dataset size. Alert on Used Memory Percentage; consider scaling if it stays over 75%.
Key memoryMEMORY USAGE <your_key_name> returns the total bytes consumed by a key.

Client and server best practices

PracticeDetail
Value sizePrefer more keys and smaller values; keep values under 100 kB. Large responses can make later pipelined requests time out.
Large responsesBreak data into smaller values, use a VM with more bandwidth, or use more connection objects round-robin.
PipeliningChoose a client that supports it for best throughput.
Expensive commandsAvoid commands such as KEYS. Redis is single-threaded; a long-running command blocks other requests.
RetriesRetry commands with exponential backoff.
TimeoutsConnect timeout of five seconds; command timeout initially under five seconds, tuned to your value sizes.
Connection spikesCreating and closing connections is expensive and new connections are rate limited: stagger reconnects.
Linux clientsRecommended net.ipv4.tcp_retries2 = 5 (default TCP settings can cause connection failures for 13 minutes or more).
MonitoringAlert on Used Memory Percentage, CPU and Connected Clients above 75%; keep server load under 80%.

Clustering policies

PolicyBehaviorRediSearch
OSSClient connects directly to shards (needs Redis Cluster API support). Initial connection on port 10000; 85XX ports for nodes, don't hardcode them. Generally the lowest latency and best throughput.Not supported
EnterpriseSingle endpoint; a proxy node routes requests. Looks non-clustered, but the proxy can be a bottleneck.Supported
Non-clusteredNo sharding; only for caches of 25 GB or smaller; not as performant. To scale up you must first change the policy.Supported

Vector indexing with RediSearch

TermMeaning
FLATExact brute-force index; for smaller datasets or exhaustive search.
HNSWApproximate nearest-neighbor index (Hierarchical Navigable Small World graphs); larger datasets where latency matters more than exhaustive precision.
KNNReturns the top K most similar vectors.
ANNApproximate nearest neighbors: trades some precision for lower latency and less compute.
Distance metricsL2, COSINE, IP
Hybrid searchMetadata filters narrow the candidates before or during vector comparison, for example only documents the current user may access.
Semantic cachingReuse a cached LLM completion when a new prompt is semantically similar, to reduce LLM cost and latency.

Exam Tips

Tick each tip once you can answer it without looking.

“Data changed in the database; cache must not serve old value” → Cache-aside: write to the data store, then invalidate the cached item. Trap: Cache-aside doesn't guarantee consistency; a reader may briefly see stale data or a cache miss.

“Cache-aside expiration setting” → Match it to the access pattern. Trap: Too short: constant reloads from the data store. Too long: stale data.

“Default eviction policy of Azure Managed Redis” → volatile-lru: only keys with a TTL are eligible. Trap: With no TTLs set nothing is evicted; use allkeys-lru if any key may be evicted.

“Avoid eviction load under memory pressure” → Set an expiration on keys. Trap: TTL keys use extra memory for bookkeeping, but expiration removes keys proactively.

“Used Memory shows about 20 GB for a 10 GB dataset” → High availability: the metric includes primary and replica shards. Trap: The metric counts replica memory too. Alert on Used Memory Percentage (consistently over 75%: consider scaling).

“Python port for Azure Managed Redis” → 10000 (ssl=True, Entra credential provider). Trap: 6380 is the port for Azure Cache for Redis instances.

“Periodic backups of cache data to a storage account” → Import/export (RDB). Trap: Data persistence is a recovery point on a disk you can't access, not for periodic backups.

“Lower the price by turning off high availability” → Only for dev and test. Trap: Without HA data isn't replicated: data loss and downtime during maintenance.

“Timeouts after one very large response” → Smaller values, more bandwidth, or more connection objects. Trap: Avoid KEYS and other expensive commands; Redis is single-threaded.

“Vector search on Azure Managed Redis” → Enable the RediSearch module at creation. Trap: Modules can't be added or loaded after the instance exists.

“Clustering policy for RediSearch on a 60 GB cache” → Enterprise. Trap: OSS isn't supported with RediSearch; Non-clustered is only for 25 GB or smaller.

“Cheapest large tier but need vector search” → Not Flash Optimized: use Memory Optimized, Balanced or Compute Optimized. Trap: Flash Optimized has no search functionality.

“Exact search vs. approximate search” → FLAT is exact brute force; HNSW is approximate and faster for large sets. Trap: ANN trades some precision for lower latency; KNN just returns the top K.

“RAG search limited to what the current user may read” → Store access-control or tenant metadata with each vector and filter on it. Trap: Without metadata the query can't narrow candidates.

“Cut LLM cost by reusing answers to similar prompts” → Semantic caching with vector similarity. Trap: Use it only when the data supports semantic equivalence and holds no private or sensitive data.

Sources

Checked against Microsoft Learn on November 13, 2026.

← PostgreSQL & pgvectorAI Data Services overview →