Redis 缓存 - "Server Closed the connection" 错误

Redis Cache - "Server Closed the connection" error

我正在 运行 进行一些测试以了解 MaxMemory-Reserved 和 MaxMemory-Policy,我们遇到了“Server Closed the connection”错误有几次 Redis DB 是 almost 满的。详情如下:

1) 创建了标准 C1(1 GB) 层和 chose “allkeys-lru” 和 max-memory-reserved 为 50 MB

的 Redis 缓存

2) 运行 Redis Benchmark 工具,用于在 Redis 数据库中添加键以确保 Redis 数据库已满os。

3) 一旦数据库达到约 960-980 MB,再次 运行 基准工具添加更多键并出现以下错误。哪些场景os会出现这个错误? 注意:当我们 运行 遇到此错误之前的信息命令时, Connected_Clients 值为 0。

4) 同时 运行 Azure 门户控制台上的 info 命令,得到的输出为“错误”。 5) 这个错误持续了大约 2-3 分钟,之后我们就可以添加密钥了。一旦我们再次 运行 信息命令,我们就会得到以下统计信息。在这里我们看到 used_memory 和 used_memory_rss 之间的差异约为 76 MB。您认为上述错误可能是因为这个吗?

info

Server redis_version:3.2.3

redis_mode:独立

os:Windows

arch_bits:64

multiplexing_api:winsock_IOCP

赫兹:10

客户

connected_clients:2

client_longest_output_list:0

client_biggest_input_buf:0

client_total_writes_outstanding:0

client_total_sent_bytes_outstanding:0

blocked_clients:0

内存

used_memory:968991592

used_memory_human:924.10M

used_memory_rss:1049776128

used_memory_rss_human:1001.14M

used_memory_peak:1070912296

used_memory_peak_human:1021.30M

used_memory_lua:37888

最大内存:1100000000

maxmemory_human:1.02G

maxmemory_policy:allkeys-lru

mem_allocator:jemalloc-3.6.0 #

很可能您 运行 处于高 un-authenticated 连接的场景中。 Redis-benchmark 首先创建所有客户端连接(在您的情况下为 -c 400 连接),然后对它们进行身份验证。身份验证延迟会导致来自单个 IP 的大量未经身份验证的连接,并且 Azure Redis 缓存会关闭它们以进行 DOS 保护。因此,错误“服务器关闭了连接” 您可以尝试 here 中的 redis-benchmark,我已将其修改为在建立连接后立即进行身份验证,应该可以解决此问题。