问题描述

使用StackExchange.Redis 作为Redis客户端SDK,连接Azure Redis服务,长期运行后发现,每天都偶发 Timeout Error。

错误消息如下:

  • StackExchange.Redis.RedisTimeoutException: Timeout performing HGETALL (15000ms), next: HGETALL new_town, inst: 0, qu: 0, qs: 17, aw: False, rs: ReadAsync, ws: Idle, in: 0, serverEndpoint: xxxxxxxx.redis.cache.chinacloudapi.cn:6380, mc: 1/1/0, mgr: 10 of 10 available, clientName: xxxxxxxxxxxx, IOCP: (Busy=0,Free=1000,Min=2,Max=1000), WORKER: (Busy=17,Free=8174,Min=2,Max=8191), v: 2.1.30.38891 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)
  • ERROR log - Timeout performing HSET (15000ms), next: HGET token, inst: 1, qu: 0, qs: 35, aw: False, rs: ReadAsync, ws: Idle, in: 0, serverEndpoint: xxxxxxxx.redis.cache.chinacloudapi.cn:6380, mc: 1/1/0, mgr: 10 of 10 available, clientName: xxxxxxxxxxxx, IOCP: (Busy=0,Free=1000,Min=50,Max=1000), WORKER: (Busy=29,Free=8162,Min=100,Max=8191), v: 2.1.30.38891 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)
  • ERROR log - Timeout performing EXPIRE (15000ms), next: HGET token, inst: 0, qu: 0, qs: 35, aw: False, rs: ReadAsync, ws: Idle, in: 0, serverEndpoint: xxxxxxxx.redis.cache.chinacloudapi.cn:6380, mc: 1/1/0, mgr: 10 of 10 available, clientName: xxxxxxxxxxxx, IOCP: (Busy=0,Free=1000,Min=50,Max=1000), WORKER: (Busy=29,Free=8162,Min=100,Max=8191), v: 2.1.30.38891 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)

排查方向

在第一个错误中,可以发现 WORKER 的Busy 数量 远大于 Min 数量 WORKER: (Busy=17,Free=8174,Min=2,Max=8191),,所以可以通过设置Worker/IOCP的线程数来解决这个问题。详细的说明见文档:https://docs.azure.cn/zh-cn/azure-cache-for-redis/cache-management-faq#recommendation

而之后继续出现Timeout 问题,这需要从如下几个方面优化:

1)查看慢指令(slowlogs) : 

there are slowlogs like HGET, HGETALL, HSCAN on this cache. Some commands are more expensive than others to execute, depending on their complexity. Because Redis is a single-threaded server side system, the time needed to run some more time expensive commands may cause some latency or timeouts on client side, as server can be busy dealing with these expensive commands.
Please refer Troubleshoot Azure Cache for Redis latency and timeouts | Microsoft Learn

2)查看客户端CPU及网络带宽

Check client host CPU or Network bandwidth. Please refer https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-troubleshoot-timeouts#high-cpu-on-client-hosts

3)查看大键值(bigkeys)

  • Optimize your application for a large number of small values, rather than a few large values.
  • The preferred solution is to break up your data into related smaller values.

Please refer: https://docs.azure.cn/zh-cn/azure-cache-for-redis/cache-troubleshoot-timeouts#large-key-value

4)升级Azure Redis到更高的定价层

5)Additional suggestion:
The memory reservations are not configured properly: Maxmemory-reserved and Maxfragmentationmemory-reserved have only set 50 MB each. Recommend to update the maxmemory-reserved and maxfragmentationmemory-reserved [atleast equal to 10% of the cache size].
For more details refer : Best practices for memory management - Azure Cache for Redis | Microsoft Learn

【Azure Redis 缓存】使用StackExchange.Redis,偶发ERROR - Timeout performing HSET (15000ms)的更多相关文章

  1. Redis系列(一)StackExchange.Redis的使用

    Redis系列(一)StackExchange.Redis的使用 一.DLL安装 用NuGet搜索StackExchange.Redis,然后下载就可以. ConnectionMultiplexer对 ...

  2. 【11】Redis .net 实例 StackExchange.Redis框架

    1.创建测试项目并下载nuget包:StackExchange.Redis PM> Install-Package StackExchange.Redis 2.创建 RedisHelper类 p ...

  3. Redis 系列 (一) StackExchange.Redis的使用

    一.DLL安装 用NuGet搜索StackExchange.Redis,然后下载就可以. ConnectionMultiplexer对象是StackExchange.Redis最中枢的对象.这个类的实 ...

  4. Redis学习笔记~StackExchange.Redis实现分布式Session

    回到目录 对于多WEB的环境现在已经是必须的了,很难想像一台WEB服务器面对百万并发的响应,所以,我们需要多台WEB服务器集群合作,来缓解这种高并发,高吞吐的场景,而对于多WEB的场景又会有个问题出现 ...

  5. 关于 Senparc.Weixin.Cache.Redis 引用的 StackExchange.Redis 版本不匹配的反馈测试

    推测原因是老系统中有地方引用了旧版本的 StackExchange.Redis,原因是 StackExchange.Redis 1.2.6 版本未提供针对 .net 4.6 以上的支持,导致库引用会失 ...

  6. NET 5 MemoryCache与Redis使用以及StackExchange.Redis和CSRedisCore

    简介以及区别 ASP.NET Core 缓存Caching,.NET Core 中为我们提供了Caching 的组件. 目前Caching 组件提供了三种存储方式. Memory Redis SqlS ...

  7. Redis集群~StackExchange.redis连接Twemproxy代理服务器

    回到目录 本文是Redis集群系列的一篇文章,主要介绍使用StackExchange.Redis进行Twemproxy(文中简称TW)代理服务的连接过程,事务上,对于TW来说,我们需要理解一下它的物理 ...

  8. Redis集群~StackExchange.redis连接Sentinel服务器并订阅相关事件(原创)

    回到目录 对于redis-sentinel我在之前的文章中已经说过,它是一个仲裁者,当主master挂了后,它将在所有slave服务器中进行选举,选举的原则当然可以看它的官方文章,这与我们使用者没有什 ...

  9. Redis集群~StackExchange.Redis(10月6号版1.1.608.0)连接Twemproxy支持Auth指令了

    回到目录 对于StackExchange.Redis这个驱动来说,之前的版本在使用Proxy为Twemproxy代理时,它是不支持Password属性的,即不支持原始的Auth指令,而我也修改过源代码 ...

  10. Redis缓存 ava-Jedis操作Redis,基本操作以及 实现对象保存

    源代码下载: http://download.csdn.net/detail/jiangtao_st/7623113 1.Maven配置 <dependency> <groupId& ...

随机推荐

  1. es6 Array.form将类数组或者对象转化为数组

    Array.from()方法就是将一个[类数组对象][或者可遍历对象]转换成一个[真正的数组] 那么什么是类数组对象呢?所谓类数组对象,最基本的要求就是具有length属性的对象. let array ...

  2. windowsbat命令大全

    Bat文件的创建及其命令大全 一.bat文件的创建 新建txt文本文件 向文本文件中输入命令 保存并修改文本文件后缀为.bat 双击保存后的bat文件,运行 二.bat命令大全 echo 和 @ @ ...

  3. C# Contains()、 == 和Equals() 比较

    目前在开发中前端页面有搜索条件 和后端的方法进行匹配 有一个Student表,其中有字段:name.age.address.tel CREATE TABLE Student ( Name varcha ...

  4. silce的扩容,截取,使用规范总结

    切片 什么是slice slice的创建使用 slice使用的一点规范 slice和数组的区别 slice的append是如何发生的 复制Slice和Map注意事项 接收 Slice 和 Map 作为 ...

  5. 8.1 TEB与PEB概述

    在开始使用TEB/PEB获取进程或线程ID之前,我想有必要解释一下这两个名词,PEB指的是进程环境块(Process Environment Block),用于存储进程状态信息和进程所需的各种数据.每 ...

  6. 2.8 PE结构:资源表详细解析

    在Windows PE中,资源是指可执行文件中存放的一些固定不变的数据集合,例如图标.对话框.字符串.位图.版本信息等.PE文件中每个资源都会被分配对应的唯一资源ID,以便在运行时能够方便地查找和调用 ...

  7. ROS节点通信(一)消息发布和订阅

    目录 1.说明 2.创建工作空间 3.创建功能包 4.编写自定义传输类型文件 5.编写源代码 5.1.编写发布者代码 5.2.编写订阅者代码 6.编译 7.启动运行 8.查看ROS网络结构图 1.说明 ...

  8. C#中DataTable数据导出为HTML格式文件

    /// <summary> /// DataTable导出为HTML的Table并保存到本地 /// </summary> /// <param name="d ...

  9. VB6各类源码开源 - 开源研究系列文章

    今天把以前下载整理的关于VB6的一些代码进行了开源,覆盖了多个分类内容,需要的朋友请下载: VB6源码.part1 https://download.csdn.net/download/lzhdim/ ...

  10. 【奶奶看了也不会】AI绘画 Mac安装stable-diffusion-webui绘制AI妹子保姆级教程

    1.作品图 2.准备工作 目前网上能搜到的stable-diffusion-webui的安装教程都是Window和Mac M1芯片的,而对于因特尔芯片的文章少之又少,这就导致我们还在用老Intel 芯 ...