【Azure Redis 缓存】Azure Cache for Redis 中如何快速查看慢指令情况(Slowlogs)
问题描述
当 Azure Redis 服务器负载过高的情况下,使用时就会遇见连接超时,命令超时,IO Socket超时等异常。为了能定位是那些因素引起的,可以参考微软官方文档( 管理 Azure Cache for Redis 的服务器负载 : https://docs.azure.cn/zh-cn/azure-cache-for-redis/cache-best-practices-server-load#avoid-long-running-commands) 开始以下因素的分析:
- 值大小 : 可以通过Redis-cli.exe 的bigkeys来进行分析 [redis-benchmark -h <your redis name>.redis.cache.chinacloudapi.cn -a [xxxxxxxxxxxxxxxxxx your access key ] -t GET -n 1000000 -d 1024 -P 50 -c 50]
- 避免出现客户端连接高峰 : 可以查看Redis Metrics中的连接数
- 内存压力 : 通过查看Redis Metrics中的内存使用量
- 避免长时间运行的命令 : 通过Azure Redis门户上的console或者是Redis-cli.exe 来执行 slowlog get 100指令
本文就重点演示在Azure Redis门户上的console页面执行 slowlog get 100 指令。
问题回答
因为Redis 服务器是单线程系统。 长时间运行的命令(官名:慢指令, Slowlog)可能导致客户端出现延迟或超时,因为服务器在忙于处理长时间运行的命令时无法响应任何其他请求。那么,如何来查看慢指令呢?
第一步: 登录Azure门户,选择需要查看的Redis服务,进入Console页面
第二步:在Console命令页输入:slowlog get 100
- slowlog get 100: 获取当前Redis服务中所记录的慢指令信息,每一个指令包含六部分内容,id,unix时间,指令执行时间(ms 微秒), 指令内容,客户端IP:端口,客户端机器名。
- slowlog len : 返回当前Redis服务器中所记录的慢指令日志中所记录指令数
- slowlog reset :清空当前慢指令记录
指令输出示例:
Welcome to secure redis console! This console connects to your live redis server and all commands are run on the server. WARNING: Use expensive commands with caution as they can impact your server load! >slowlog get 100
1) 1) (integer) 16
2) (integer) 1639993957
3) (integer) 10012
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:14835"
6) ""
2) 1) (integer) 15
2) (integer) 1639993727
3) (integer) 10195
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:19468"
6) ""
3) 1) (integer) 14
2) (integer) 1639992068
3) (integer) 13279
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:46504"
6) ""
4) 1) (integer) 13
2) (integer) 1639990412
3) (integer) 14152
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:39900"
6) ""
5) 1) (integer) 12
2) (integer) 1639990251
3) (integer) 10710
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:52381"
6) ""
6) 1) (integer) 11
2) (integer) 1639989209
3) (integer) 11665
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:38779"
6) ""
7) 1) (integer) 10
2) (integer) 1639989142
3) (integer) 13642
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:12348"
6) ""
8) 1) (integer) 9
2) (integer) 1639988822
3) (integer) 22073
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:51454"
6) ""
9) 1) (integer) 8
2) (integer) 1639988414
3) (integer) 13668
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:1550"
6) ""
10) 1) (integer) 7
2) (integer) 1639987239
3) (integer) 18846
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:57350"
6) ""
11) 1) (integer) 6
2) (integer) 1639986196
3) (integer) 12921
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:1739"
6) ""
12) 1) (integer) 5
2) (integer) 1639986196
3) (integer) 15833
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:1739"
6) ""
13) 1) (integer) 4
2) (integer) 1639985175
3) (integer) 14434
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:1649"
6) ""
14) 1) (integer) 3
2) (integer) 1639984227
3) (integer) 61332
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:24878"
6) ""
15) 1) (integer) 2
2) (integer) 1639984227
3) (integer) 27560
4) 1) "GET"
2) "key:__rand_int__"
5) "167.220.233.137:7637"
6) ""
16) 1) (integer) 1
2) (integer) 1639983695
3) (integer) 10361
4) 1) "SET"
2) "Message_dd2_0"
3) "eyJ0eXAiOiJKV1QiLCJub25jZSI6Inp1d2hMNzhSWDJsdGZITlN1TDYyOEhpRDNrTzhWSnJXZl9CNEtVcjBFTWsiLCJhbGciOiJSUzI1NiIsIng1dCI6IkpSNGxDdzkw... (4140520 more bytes)"
5) "167.220.233.137:1166"
6) "MININT-S4MGVOU"
17) 1) (integer) 0
2) (integer) 1639983310
3) (integer) 16577
4) 1) "SET"
2) "Message_dd_2222"
3) "eyJ0eXAiOiJKV1QiLCJub25jZSI6Inp1d2hMNzhSWDJsdGZITlN1TDYyOEhpRDNrTzhWSnJXZl9CNEtVcjBFTWsiLCJhbGciOiJSUzI1NiIsIng1dCI6IkpSNGxDdzkw... (7774 more bytes)"
5) "167.220.233.137:58313"
6) "MININT-S4MGVOU"
>slowlog len
(integer) 17
>slowlog reset
OK
>slowlog len
(integer) 0
Each entry from the slow log is comprised of the following six values:
- A unique progressive identifier for every slow log entry.
- The unix timestamp at which the logged command was processed.
- The amount of time needed for its execution, in microseconds.
- The array composing the arguments of the command.
- Client IP address and port.
- Client name if set via the CLIENT SETNAME command.
参考资料
SLOWLOG GET [count]:https://redis.io/commands/slowlog-get
管理 Azure Cache for Redis 的服务器负载: https://docs.azure.cn/zh-cn/azure-cache-for-redis/cache-best-practices-server-load#value-sizes
【Azure Redis 缓存】Azure Cache for Redis 中如何快速查看慢指令情况(Slowlogs)的更多相关文章
- 【Azure Redis 缓存 Azure Cache For Redis】如何设置让Azure Redis中的RDB文件暂留更久(如7天)
问题描述 Azure Redis和所有的Redis服务一样,可以让你保留存储在Redis中的数据.以防万一在Redis服务器出现故障的时候能尽可能小的减少数据的损失.在Azure Redis服务中,默 ...
- 【Azure Redis 缓存 Azure Cache For Redis】Azure Redis由低级别(C)升级到高级别(P)的步骤和注意事项, 及对用户现有应用的潜在影响,是否需要停机时间窗口,以及这个时间窗口需要多少的预估问题
问题描述 由于Azure Redis的性能在不同级别表现不同,当需要升级/缩放Redis的时候,从使用者的角度,需要知道有那些步骤? 注意事项? 潜在影响?停机事件窗口? 升级预估时间? 解决方案 从 ...
- spring boot redis 缓存(cache)集成
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
- 【Azure Redis 缓存 Azure Cache For Redis】在创建高级层Redis(P1)集成虚拟网络(VNET)后,如何测试VNET中资源如何成功访问及配置白名单的效果
当使用Azure Redis高级版时候,为了能更好的保护Redis的安全,启用了虚拟网路,把Redis集成在Azure中的虚拟网络,只能通过虚拟网络VENT中的资源进行访问,而公网是不可以访问的.但是 ...
- 【Azure Redis 缓存 Azure Cache For Redis】Redis性能问题,发现Server Load非常的高,导致正常连接/操作不成功
问题描述 在正常使用Azure Redis的服务中,突然发现Redis 的CPU达到了100%, 正常的使用中发现性能问题严重.从Redis的门户图表中,观察到CPU, Connection,Lent ...
- 【Azure Redis 缓存 Azure Cache For Redis】使用Redis自带redis-benchmark.exe命令测试Azure Redis的性能
问题描述 关于Azure Redis的性能问题,在官方文档中,可以查看到不同层级Redis的最大连接数,每秒处理请求的性能. 基本缓存和标准缓存 C0 (250 MB) 缓存 - 最多支持 256 个 ...
- 【Azure Redis 缓存 Azure Cache For Redis】Redis连接池
问题描述 Redis根据定价层说明,不同级别支持的连接数最多可达4万(同时),但是当短时间又大量连接请求建立的时候,Redis服务的服务压力非常大,到达100%.严重影响了高响应的要求.最严重时,经常 ...
- 高级运维(六):源码安装Redis缓存服务、常用Redis数据库操作指令、配置Redis主从服务器
一.源码安装Redis缓存服务 目标: 本案例要求先快速搭建好一台Redis服务器,并测试该缓存服务器: 1> 设置变量test,值为123 2> 查看变量test的值 3> 设置计 ...
- 【Redis缓存机制】1.Redis介绍和使用场景
(1)持久化数据库的缺点平常我们使用的关系型数据库有Mysql.Oracle以及SqlServer等,在开发的过程中,数据通常都是通过Web提供的数据库驱动来链接数据库进行增删改查. 那么,我们日常使 ...
随机推荐
- [atARC100F]Colorful Sequences
考虑求任意序列中$a$出现次数之和减去不合法序列中$a$出现次数之和,前者即为$(n-m+1)k^{n-m}$(一个序列重复次数恰好为$a$出现次数),对于后者,先忽略$a$的次数,即统计有多少个不合 ...
- jpa生成uuid
使用jpa可以生成uuid,但是我直接添加数据没有id值会报错,只在程序中有效,如果直接修改数据库需要手动填写,另外长度不要乱填 ,之前填了200,找了半天才找到原因. package com.jav ...
- 提升 RTC 音频体验 - 从搞懂硬件开始
前言 RTC(实时音视频通信)技术的快速发展,助力了直播.短视频等互动娱乐形式的普及:在全球疫情持续蔓延的态势下,云会议需求呈现爆发式增长,进一步推动了 RTC 行业的快速发展.为了给客户提供稳定可靠 ...
- 第41篇-JNIEnv与JavaVM的初始化
JavaVM和JNIEnv的初始化和JVM各模块的初始化都是在JNI_CreateJavaVM()函数中完成.这一篇将详细介绍JavaVM和JNIEnv的初始化过程. 1.初始化JavaVM Java ...
- nmap相关
nmap -sT IP-sT(全链接扫描),获取目标IP+PORT的状态,其实是发了三个包:SYN,SYN/ACK,ACK,类似于TCP三次握手 状态: open 开放的 closed 关闭的 fil ...
- pcm-pcie 解析
简介 pcm 全称为 Performance Counter Monitor,该项目是针对 intel 平台处理器的资源利用率进行监控的工具.在现代 Intel 处理器已经提供了监视处理器内部性能事件 ...
- mac 下 如何在同一窗口打开多个终端并实现快捷键切换
相信大家编代码的时候都会遇到,每次需要在头文件,库文件和源码文件中编代码的时候,总是需要在几个文件中切换来切换去的,而且一个文件就一个终端窗口,每次都要用鼠标点来点去,非常麻烦,所以如果能把这几个文件 ...
- javaSE高级篇5 — java8新特性详解———更新完毕
java8新特性 在前面已经见过一些东西了,但是:挖得有坑儿 1.lambda表达式 lambda表达式是jdk1.8引入的全新语法特性 它支持的是:只有单个抽象方法的函数式接口.什么意思? 就是说: ...
- 一次线上GC故障解决过程记录
排查了三四个小时,终于解决了这个GC问题,记录解决过程于此,希望对大家有所帮助.本文假定读者已具备基本的GC常识和JVM调优知识,关于JVM调优工具使用可以查看我在同一分类下的另一篇文章: http: ...
- 13个酷炫的JavaScript一行程序
1. 获得一个随机的布尔值(true/false) const randomBoolean = () => Math.random() >= 0.5; console.log(random ...