You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Troubleshoot data loss in Azure Cache for Redis
3
-
description: Learn how to resolve data-loss problems with Azure Cache for Redis, such as partial loss of keys, key expiration, or complete loss of keys.
2
+
title: Troubleshoot data loss
3
+
description: Learn to troubleshoot data-loss problems with Azure Cache for Redis, including partial or complete loss of keys.
4
4
5
5
6
6
7
7
ms.topic: conceptual
8
-
ms.date: 03/05/2025
8
+
ms.date: 05/22/2025
9
9
appliesto:
10
10
- ✅ Azure Cache for Redis
11
11
12
12
---
13
13
14
14
# Troubleshoot data loss in Azure Cache for Redis
15
15
16
-
This article discusses how to diagnose actual or perceived data losses that might occur in Azure Cache for Redis.
16
+
This article discusses how to diagnose [partial](#partial-key-loss) or [complete](#complete-key-loss) data losses that occur in Azure Cache for Redis.
17
17
18
-
-[Partial loss of keys](#partial-loss-of-keys)
19
-
-[Key expiration](#key-expiration)
20
-
-[Key eviction](#key-eviction)
21
-
-[Key deletion](#key-deletion)
22
-
-[Async replication](#async-replication)
23
-
-[Major or complete loss of keys](#major-or-complete-loss-of-keys)
> Several of the troubleshooting steps in this guide include instructions to run Redis commands and monitor various performance metrics. For more information and instructions, see the articles in the [Related Content](#related-content).
30
-
>
20
+
Azure Cache for Redis doesn't randomly delete keys after they've been stored in memory, but it does remove keys in response to expiration policies, eviction policies, and explicit key-deletion commands. You can run these commands on the [console](cache-configure.md#redis-console) or through the [Redis CLI](cache-how-to-redis-cli-tool.md).
31
21
32
-
## Partial loss of keys
22
+
Keys written to the primary node in a Premium or Standard Azure Redis instance might not be available on a replica right away. Data is replicated from the primary to the replica in an asynchronous and non-blocking manner.
33
23
34
-
Azure Cache for Redis doesn't randomly delete keys after they've been stored in memory. However, it does remove keys in response to expiration policies, eviction policies, and to explicit key-deletion commands. You can run these commands on the [console](cache-configure.md#redis-console) or through the [CLI](cache-how-to-redis-cli-tool.md).
35
-
36
-
Keys that have been written to the primary node in a Premium or Standard Azure Cache for Redis instance also might not be available on a replica right away. Data is replicated from the primary to the replica in an asynchronous and non-blocking manner.
37
-
38
-
If you find that keys have disappeared from your cache, check the following possible causes:
24
+
If some keys disappeared from your cache, check the following possible causes:
39
25
40
26
| Cause | Description |
41
27
|---|---|
42
-
|[Key expiration](#key-expiration)| Keys are removed because of time-outs set on them. |
28
+
|[Key expiration](#key-expiration)| Keys are removed because of timeouts set on them. |
43
29
|[Key eviction](#key-eviction)| Keys are removed under memory pressure. |
44
30
|[Key deletion](#key-deletion)| Keys are removed by explicit delete commands. |
45
-
|[Async replication](#async-replication)| Keys are not available on a replica because of data-replication delays. |
31
+
|[Async replication](#async-replication)| Keys aren't available on a replica because of datareplication delays. |
46
32
47
33
### Key expiration
48
34
49
-
Azure Cache for Redis removes a key automatically if the key is assigned a time-out and that period has passed. For more information about Redis key expiration, see the [EXPIRE](https://redis.io/commands/expire) command documentation. Time-out values also can be set by using the [SET](https://redis.io/commands/set), [SETEX](https://redis.io/commands/setex), [GETSET](https://redis.io/commands/getset), and other **\*STORE** commands.
35
+
Azure Cache for Redis removes a key automatically if the key is assigned a timeout and that period passes. For more information about Redis key expiration, see the Redis [EXPIRE](https://redis.io/commands/expire) command documentation. Timeout values can also be set by using the [SET](https://redis.io/commands/set), [SETEX](https://redis.io/commands/setex), [GETSET](https://redis.io/commands/getset), and other `*STORE` commands.
50
36
51
-
To get stats on how many keys have expired, use the [INFO](https://redis.io/commands/info) command. The `Stats` section shows the total number of expired keys. The `Keyspace` section provides more information about the number of keys with time-outs and the average time-out value.
37
+
To get statistics on how many keys have expired, use the [INFO](https://redis.io/commands/info) command. The `Stats` section shows the total number of expired keys. The `Keyspace` section provides more information about the number of keys with timeouts and the average timeout value.
Azure Cache for Redis requires memory space to store data. It purges keys to free up available memory when necessary. When the **used_memory** or **used_memory_rss** values in the [INFO](https://redis.io/commands/info) command approach the configured **maxmemory** setting, Azure Cache for Redis starts evicting keys from memory based on [cache policy](https://redis.io/topics/lru-cache).
52
+
Azure Cache for Redis requires memory space to store data and purges keys to free up available memory when necessary. When the `used_memory` or `used_memory_rss` values in the [INFO](https://redis.io/commands/info) command approach the configured `maxmemory` setting, Azure Redis starts evicting keys from memory based on [cache policy](https://redis.io/topics/lru-cache).
67
53
68
54
You can monitor the number of evicted keys by using the [INFO](https://redis.io/commands/info) command:
69
55
70
-
```azurecli-interactive
56
+
```console
71
57
# Stats
72
58
73
59
evicted_keys:13224
74
60
```
75
61
76
62
### Key deletion
77
63
78
-
Redis clients can issue the [DEL](https://redis.io/commands/del) or [HDEL](https://redis.io/commands/hdel)command to explicitly remove keys from Azure Cache for Redis. You can track the number of delete operations by using the [INFO](https://redis.io/commands/info) command. If **DEL** or **HDEL** commands have been called, they are listed in the `Commandstats` section.
64
+
Redis clients can issue the Redis [DEL](https://redis.io/commands/del) or [HDEL](https://redis.io/commands/hdel)commands to explicitly remove keys from Azure Redis. You can track the number of delete operations by using the [INFO](https://redis.io/commands/info) command. If `DEL` or `HDEL` commands were called, they're listed in the `Commandstats` section.
Any Azure Cache for Redis instance in the Standard or Premium tier is configured with a primary node and at least one replica. Data is copied from the primary to a replica asynchronously by using a background process. The [redis.io](https://redis.io/topics/replication) website describes how Redis data replication works in general. For scenarios where clients write to Redis frequently, partial data loss can occur because replication is not guaranteed to be instantaneous. For example, if the primary goes down *after* a client writes a key to it, but *before* the background process has a chance to send that key to the replica, the key is lost when the replica takes over as the new primary.
76
+
Standard or Premium tier Azure Cache for Redis instances are configured with a primary node and at least one replica. Data is copied from the primary to a replica asynchronously by using a background process.
77
+
78
+
The [redis.io](https://redis.io/topics/replication) website describes how Redis data replication works in general. For scenarios where clients write to Redis frequently, partial data loss can occur because replication isn't guaranteed to be instantaneous.
91
79
92
-
## Major or complete loss of keys
80
+
For example, if the primary goes down after a client writes a key to it, but before the background process has a chance to send that key to the replica, the key is lost when the replica takes over as the new primary.
93
81
94
-
If most or all keys have disappeared from your cache, check the following possible causes:
82
+
## Complete key loss
83
+
84
+
If most or all keys disappear from your cache, check the following possible causes:
95
85
96
86
| Cause | Description |
97
87
|---|---|
98
-
|[Key flushing](#key-flushing)| Keys have been purged manually. |
99
-
|[Incorrect database selection](#incorrect-database-selection)| Azure Cache for Redis is set to use a non-default database. |
88
+
|[Key flushing](#key-flushing)| Keys were purged manually. |
89
+
|[Incorrect database selection](#incorrect-database-selection)| Azure Redis is set to use a nondefault database. |
100
90
|[Redis instance failure](#redis-instance-failure)| The Redis server is unavailable. |
101
91
102
92
### Key flushing
103
93
104
-
Clients can call the [FLUSHDB](https://redis.io/commands/flushdb) command to remove all keys in a *single* database or [FLUSHALL](https://redis.io/commands/flushall) to remove all keys from *all* databases in a Redis cache. To find out whether keys have been flushed, use the [INFO](https://redis.io/commands/info) command. The `Commandstats` section shows whether either `FLUSH` command has been called:
94
+
Azure Redis clients can call the Redis [FLUSHDB](https://redis.io/commands/flushdb) command to remove all keys in a single database or [FLUSHALL](https://redis.io/commands/flushall) to remove all keys from all databases in a Redis cache. To find out whether keys have been flushed, use the [INFO](https://redis.io/commands/info) command. The `Commandstats` section shows whether either `FLUSH` command was called
Azure Cache for Redis uses the `db0` database by default. If you switch to another database (for example,`db1`) and try to read keys from it, Azure Cache for Redis won't find them there. Every database is a logically separate unit and holds a different dataset. Use the [SELECT](https://redis.io/commands/select) command to use other available databases and look for keys in each of them.
106
+
Azure Cache for Redis uses the `db0` database by default. If you switch to another database such as`db1` and try to read keys from it, Azure Redis doesn't find them. Every database is a logically separate unit and holds a different dataset. Use the Redis [SELECT](https://redis.io/commands/select) command to look for keys in other available databases.
117
107
118
108
### Redis instance failure
119
109
120
-
Redis is an in-memory data store. Data is kept on the physical or virtual machines that host the Redis cache. An Azure Cache for Redis instance in the Basic tier runs on only a single virtual machine (VM). If that VM is down, all data that you've stored in the cache is lost.
110
+
Redis is an in-memory data store that keeps data on the physical or virtual machines (VMs) that host the Redis cache. A Basic-tier Azure Cache for Redis instance runs on only a single virtual machine (VM). If that VM is down, all data that you've stored in the cache is lost.
111
+
112
+
Caches in the Standard and Premium tiers offer higher resiliency against data loss by using two VMs in a replicated configuration. When the primary node in such a cache fails, the replica node takes over to serve data automatically.
121
113
122
-
Caches in the Standard and Premium tiers offer much higher resiliency against data loss by using two VMs in a replicated configuration. When the primary node in such a cache fails, the replica node takes over to serve data automatically. These VMs are located on separate domains for faults and updates, to minimize the chance of both becoming unavailable simultaneously. If a major datacenter outage happens, however, the VMs might still go down together. Your data will be lost in these rare cases.
114
+
These VMs are located on separate domains for faults and updates, to minimize the chance of both VMs becoming unavailable at once. If a major datacenter outage happens, however, both VMs could still go down together. In these rare cases, your data is lost.
123
115
124
-
Consider using [Redis data persistence](https://redis.io/topics/persistence) and [geo-replication](./cache-how-to-geo-replication.md) to improve protection of your data against these infrastructure failures.
116
+
Consider using [Redis data persistence](https://redis.io/topics/persistence) and [geo-replication](cache-how-to-geo-replication.md) to improve data protection against infrastructure failures.
125
117
126
118
## Related content
127
119
128
-
-[Troubleshoot Azure Cache for Redis server-side issues](cache-troubleshoot-server.md)
129
-
-[Choosing the right tier](cache-overview.md#choosing-the-right-tier)
120
+
-[Use the Redis command-line tool with Azure Cache for Redis](cache-how-to-redis-cli-tool)
121
+
-[Data persistence in Azure Cache for Redis](cache-how-to-premium-persistence.md)
130
122
-[Monitor Azure Cache for Redis](../redis/monitor-cache.md)
131
-
-[How can I run Redis commands?](cache-development-faq.yml#how-can-i-run-redis-commands-)
0 commit comments