ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

机制以及应对方案。影响Redis性能的五大方面的潜在因素DAR

2021-01-13 23:58:33  阅读:280  来源: 互联网

标签:www http Redis html DAR 五大 com book itangyuan


Redis被广泛使用的一个很重要的原因是它的高性能。因此我们必要要重视所有可能影响Redis性能的因素、机制以及应对方案。影响Redis性能的五大方面的潜在因素,分别是:

Redis内部的阻塞式操作
CPU核和NUMA架构的影响
Redis关键系统配置
Redis内存碎片
Redis缓冲区
在前面的2讲中,学习了会导致Redis变慢的潜在阻塞点以及相应的解决方案,即异步线程机制和CPU绑核。除此之外,还有一些因素会导致Redis变慢。

这一讲,介绍如何系统性应对Redis变慢这个问题。从问题认定、系统性排查和应对方案这3个方面来讲解。

判断Redis是否变慢?
最直接的方法,查看Redis的响应延迟。通过绝对值来判断,比如执行时间突然增长到几秒。

但是这个方法在不同配置的机器上的误差比较大。第二个方法是基于当前环境下的Redis基线性能做判断。

基线性能指一个系统在低压力、无干扰下的基本性能。

怎么确定基线性能?从2.8.7版本开始,redis-cli命令提供了-intrinsic-latency选项,可以用来监测和统计测试期间内的最大延迟,这个延迟可以作为Redis的基线性能。其中,测试时长可以用-intrinsic-latency选项的参数来指定。

一般来说,运行时延和基线性能对比,如果运行时延是基线性能的2倍及以上时,就可以认定Redis变慢了。为了避免网络对基线性能的影响,直接在服务器端运行。

如何应对Redis变慢?
影响Redis的关键因素有三个:Redis自身的操作特性、文件系统和操作系统。

Redis自身操作特性的影响
Redis有两个操作会对性能造成较大影响,分别是慢查询命令和过期key操作。

慢查询命令
慢查询命令,就是指在Redis中执行速度慢的命令,这会导致Redis延迟增加。

排查:通过Redis日志、或者是latency monitor工具。

解决方法:

用其他高效命令代替。比如不要使用SMEMBERS命令,而是用SSCAN多次迭代返回;
当需要执行排序、交集、并集操作时,可以在客户端完成,而不要用SORT、SUNION、SINTER这些命令。
还有一个比较容易遗漏的慢查询命令是KEYS命令,它用于返回和输入模式的所有key。因为KEYS命令需要遍历存储的键值对,所以操作延时高。KEYS命令一般不被建议用于生产环境中。

过期key操作
过期key的自动删除机制,它是Redis用来回收内存空间的常用机制,本身会引起Redis操作阻塞,导致性能变慢。

排查:检查业务代码在使用EXPIREAT命令设置key过期时间时,是否使用了相同的UNIX时间戳。因为这会造成大量key在同一时间过期,导致性能变慢。

解决方法:

根据实际业务需求来决定EXPIREAT和EXPIRE的过期时间参数。
如果一批key的确是同时过期,可以在EXPIREAT和EXPIRE的过期时间参数上,加上一个一定大小范围内的随机参数
文件系统的影响
在基础篇讲过,为了保证数据可靠性,Redis会采用AOF日志或者RDB快照。其中,AOF日志提供了三种日志写回策略:no、everysec、always。这三种写回策略依赖文件系统的两个系统调用完成:write和fsync。

write只要把日志记录写到内核缓冲区即可;Redis被广泛使用的一个很重要的原因是它的高性能。因此我们必要要重视所有可能影响Redis性能的因素、机制以及应对方案。影响Redis性能的五大方面的潜在因素,分别是:

Redis内部的阻塞式操作
CPU核和NUMA架构的影响
Redis关键系统配置
Redis内存碎片
Redis缓冲区
在前面的2讲中,学习了会导致Redis变慢的潜在阻塞点以及相应的解决方案,即异步线程机制和CPU绑核。除此之外,还有一些因素会导致Redis变慢。

这一讲,介绍如何系统性应对Redis变慢这个问题。从问题认定、系统性排查和应对方案这3个方面来讲解。

判断Redis是否变慢?
最直接的方法,查看Redis的响应延迟。通过绝对值来判断,比如执行时间突然增长到几秒。
Redis被广泛使用的一个很重要的原因是它的高性能。因此我们必要要重视所有可能影响Redis性能的因素、机制以及应对方案。影响Redis性能的五大方面的潜在因素,分别是:

Redis内部的阻塞式操作
CPU核和NUMA架构的影响
Redis关键系统配置
Redis内存碎片
Redis缓冲区
在前面的2讲中,学习了会导致Redis变慢的潜在阻塞点以及相应的解决方案,即异步线程机制和CPU绑核。除此之外,还有一些因素会导致Redis变慢。

这一讲,介绍如何系统性应对Redis变慢这个问题。从问题认定、系统性排查和应对方案这3个方面来讲解。

判断Redis是否变慢?
最直接的方法,查看Redis的响应延迟。通过绝对值来判断,比如执行时间突然增长到几秒。

但是这个方法在不同配置的机器上的误差比较大。第二个方法是基于当前环境下的Redis基线性能做判断。

基线性能指一个系统在低压力、无干扰下的基本性能。

怎么确定基线性能?从2.8.7版本开始,redis-cli命令提供了-intrinsic-latency选项,可以用来监测和统计测试期间内的最大延迟,这个延迟可以作为Redis的基线性能。其中,测试时长可以用-intrinsic-latency选项的参数来指定。

一般来说,运行时延和基线性能对比,如果运行时延是基线性能的2倍及以上时,就可以认定Redis变慢了。为了避免网络对基线性能的影响,直接在服务器端运行。

如何应对Redis变慢?
影响Redis的关键因素有三个:Redis自身的操作特性、文件系统和操作系统。

Redis自身操作特性的影响
Redis有两个操作会对性能造成较大影响,分别是慢查询命令和过期key操作。

慢查询命令
慢查询命令,就是指在Redis中执行速度慢的命令,这会导致Redis延迟增加。

排查:通过Redis日志、或者是latency monitor工具。

解决方法:

用其他高效命令代替。比如不要使用SMEMBERS命令,而是用SSCAN多次迭代返回;
当需要执行排序、交集、并集操作时,可以在客户端完成,而不要用SORT、SUNION、SINTER这些命令。
还有一个比较容易遗漏的慢查询命令是KEYS命令,它用于返回和输入模式的所有key。因为KEYS命令需要遍历存储的键值对,所以操作延时高。KEYS命令一般不被建议用于生产环境中。

过期key操作
过期key的自动删除机制,它是Redis用来回收内存空间的常用机制,本身会引起Redis操作阻塞,导致性能变慢。

排查:检查业务代码在使用EXPIREAT命令设置key过期时间时,是否使用了相同的UNIX时间戳。因为这会造成大量key在同一时间过期,导致性能变慢。

解决方法:
http://www.itangyuan.com/book/15892720.html
http://m.itangyuan.com/book/15892720.html
http://www.itangyuan.com/book/15892723.html
http://m.itangyuan.com/book/15892723.html
http://www.itangyuan.com/book/15892722.html
http://m.itangyuan.com/book/15892722.html
http://www.itangyuan.com/book/15892721.html
http://m.itangyuan.com/book/15892721.html
http://www.itangyuan.com/book/15892724.html
http://m.itangyuan.com/book/15892724.html
http://www.itangyuan.com/book/15892741.html
http://m.itangyuan.com/book/15892741.html
http://www.itangyuan.com/book/15892742.html
http://m.itangyuan.com/book/15892742.html
http://www.itangyuan.com/book/15892743.html
http://m.itangyuan.com/book/15892743.html
http://www.itangyuan.com/book/15892744.html
http://m.itangyuan.com/book/15892744.html
http://www.itangyuan.com/book/15892757.html
http://m.itangyuan.com/book/15892757.html
http://www.itangyuan.com/book/15892758.html
http://m.itangyuan.com/book/15892758.html
http://www.itangyuan.com/book/15892760.html
http://m.itangyuan.com/book/15892760.html
http://www.itangyuan.com/book/15892761.html
http://m.itangyuan.com/book/15892761.html
http://www.itangyuan.com/book/15892763.html
http://m.itangyuan.com/book/15892763.html
http://www.itangyuan.com/book/15892774.html
http://m.itangyuan.com/book/15892774.html
http://www.itangyuan.com/book/15892777.html
http://m.itangyuan.com/book/15892777.html
http://www.itangyuan.com/book/15892778.html
http://m.itangyuan.com/book/15892778.html
http://www.itangyuan.com/book/15892779.html
http://m.itangyuan.com/book/15892779.html
http://www.itangyuan.com/book/15892783.html
http://m.itangyuan.com/book/15892783.html
http://www.itangyuan.com/book/15892802.html
http://m.itangyuan.com/book/15892802.html
http://www.itangyuan.com/book/15892803.html
http://m.itangyuan.com/book/15892803.html
http://www.itangyuan.com/book/15892804.html
http://m.itangyuan.com/book/15892804.html
http://www.itangyuan.com/book/15892806.html
http://m.itangyuan.com/book/15892806.html
http://www.itangyuan.com/book/15892808.html
http://m.itangyuan.com/book/15892808.html
http://www.itangyuan.com/book/15892810.html
http://m.itangyuan.com/book/15892810.html
http://www.itangyuan.com/book/15892811.html
http://m.itangyuan.com/book/15892811.html
http://www.itangyuan.com/book/15892812.html
http://m.itangyuan.com/book/15892812.html
http://www.itangyuan.com/book/15892813.html
http://m.itangyuan.com/book/15892813.html
http://www.itangyuan.com/book/15892814.html
http://m.itangyuan.com/book/15892814.html
http://www.itangyuan.com/book/15892815.html
http://m.itangyuan.com/book/15892815.html
http://www.itangyuan.com/book/15892816.html
http://m.itangyuan.com/book/15892816.html
http://www.itangyuan.com/book/15892817.html
http://m.itangyuan.com/book/15892817.html
http://www.itangyuan.com/book/15892818.html
http://m.itangyuan.com/book/15892818.html
http://www.itangyuan.com/book/15892819.html
http://m.itangyuan.com/book/15892819.html
http://www.itangyuan.com/book/15892821.html
http://m.itangyuan.com/book/15892821.html
http://www.itangyuan.com/book/15892822.html
http://m.itangyuan.com/book/15892822.html
http://www.itangyuan.com/book/15892823.html
http://m.itangyuan.com/book/15892823.html
http://www.itangyuan.com/book/15892824.html
http://m.itangyuan.com/book/15892824.html
http://www.itangyuan.com/book/15892825.html
http://m.itangyuan.com/book/15892825.html
40岁学英语改变命运
0基础英语4级难吗
英语学多久能正常交流
音标记忆顺口溜(48个)
英语改变人生真实例子
英语听力在线听初三
每日英语听力app
全国卷英语听力在线听
听力英语网
英语听力训练
初二英语听力免费训练
高中英语听力在线
初中生英语听力app
英语听力材料mp3
图片在线拍照翻译器
翻译器在线语音翻译
百度翻译转换器
手机悬浮窗翻译器
不会吧这是
我说我说!
恐怕是武灵境界!
武灵境界?
呵呵探路?
就由你去!
好好我这就去
咕噜一声。
还不快走!
下一刻异变突生。
横冲直撞!

儿童不收费的英语软件
英语自学app哪个好
30岁自学英语35当老师
35岁学英语会不会晚
适合自学英语的app
http://www.itangyuan.com/book/15892826.html
http://m.itangyuan.com/book/15892826.html
http://www.itangyuan.com/book/15892827.html
http://m.itangyuan.com/book/15892827.html
http://www.itangyuan.com/book/15892829.html
http://m.itangyuan.com/book/15892829.html
http://www.itangyuan.com/book/15892830.html
http://m.itangyuan.com/book/15892830.html
http://www.itangyuan.com/book/15892831.html
http://m.itangyuan.com/book/15892831.html
http://www.itangyuan.com/book/15892833.html
http://m.itangyuan.com/book/15892833.html
http://www.itangyuan.com/book/15892835.html
http://m.itangyuan.com/book/15892835.html
http://www.itangyuan.com/book/15892836.html
http://m.itangyuan.com/book/15892836.html
http://www.itangyuan.com/book/15892837.html
http://m.itangyuan.com/book/15892837.html
http://www.itangyuan.com/book/15892838.html
http://m.itangyuan.com/book/15892838.html
http://www.itangyuan.com/book/15892839.html
http://m.itangyuan.com/book/15892839.html
http://www.itangyuan.com/book/15892841.html
http://m.itangyuan.com/book/15892841.html
http://www.itangyuan.com/book/15892842.html
http://m.itangyuan.com/book/15892842.html
http://www.itangyuan.com/book/15892843.html
http://m.itangyuan.com/book/15892843.html
http://www.itangyuan.com/book/15892844.html
http://m.itangyuan.com/book/15892844.html
http://www.itangyuan.com/book/15892848.html
http://m.itangyuan.com/book/15892848.html
http://www.itangyuan.com/book/15892849.html
http://m.itangyuan.com/book/15892849.html
http://www.itangyuan.com/book/15892850.html
http://m.itangyuan.com/book/15892850.html
http://www.itangyuan.com/book/15892851.html
http://m.itangyuan.com/book/15892851.html
http://www.itangyuan.com/book/15892852.html
http://m.itangyuan.com/book/15892852.html
http://www.itangyuan.com/book/15892853.html
http://m.itangyuan.com/book/15892853.html
http://www.itangyuan.com/book/15892854.html
http://m.itangyuan.com/book/15892854.html
http://www.itangyuan.com/book/15892855.html
http://m.itangyuan.com/book/15892855.html
http://www.itangyuan.com/book/15892856.html
http://m.itangyuan.com/book/15892856.html
http://www.itangyuan.com/book/15892857.html
http://m.itangyuan.com/book/15892857.html
http://www.itangyuan.com/book/15892858.html
http://m.itangyuan.com/book/15892858.html
http://www.itangyuan.com/book/15892859.html
http://m.itangyuan.com/book/15892859.html
http://www.itangyuan.com/book/15892861.html
http://m.itangyuan.com/book/15892861.html
http://www.itangyuan.com/book/15892862.html
http://m.itangyuan.com/book/15892862.html
http://www.itangyuan.com/book/15892863.html
http://m.itangyuan.com/book/15892863.html
http://www.itangyuan.com/book/15892864.html
http://m.itangyuan.com/book/15892864.html
http://www.itangyuan.com/book/15892865.html
http://m.itangyuan.com/book/15892865.html
http://www.itangyuan.com/book/15892867.html
http://m.itangyuan.com/book/15892867.html
http://www.itangyuan.com/book/15892868.html
http://m.itangyuan.com/book/15892868.html
http://www.itangyuan.com/book/15892869.html
http://m.itangyuan.com/book/15892869.html
http://www.itangyuan.com/book/15892870.html
http://m.itangyuan.com/book/15892870.html
http://www.itangyuan.com/book/15892871.html
http://m.itangyuan.com/book/15892871.html
http://www.itangyuan.com/book/15892873.html
http://m.itangyuan.com/book/15892873.html
http://www.itangyuan.com/book/15892874.html
http://m.itangyuan.com/book/15892874.html
http://www.itangyuan.com/book/15892875.html
http://m.itangyuan.com/book/15892875.html
http://www.itangyuan.com/book/15892877.html
http://m.itangyuan.com/book/15892877.html
http://www.itangyuan.com/book/15892878.html
http://m.itangyuan.com/book/15892878.html
http://www.itangyuan.com/book/15892879.html
http://m.itangyuan.com/book/15892879.html
http://www.itangyuan.com/book/15892901.html
http://m.itangyuan.com/book/15892901.html
http://www.itangyuan.com/book/15892903.html
http://m.itangyuan.com/book/15892903.html
http://www.itangyuan.com/book/15892904.html
http://m.itangyuan.com/book/15892904.html
http://www.itangyuan.com/book/15892905.html
http://m.itangyuan.com/book/15892905.html
http://www.itangyuan.com/book/15892906.html
http://m.itangyuan.com/book/15892906.html
http://www.itangyuan.com/book/15892909.html
http://m.itangyuan.com/book/15892909.html
http://www.itangyuan.com/book/15892911.html
http://m.itangyuan.com/book/15892911.html
http://www.itangyuan.com/book/15892912.html
http://m.itangyuan.com/book/15892912.html
http://www.itangyuan.com/book/15892914.html
http://m.itangyuan.com/book/15892914.html
http://www.itangyuan.com/book/15892916.html
http://m.itangyuan.com/book/15892916.html
http://www.itangyuan.com/book/15892917.html
http://m.itangyuan.com/book/15892917.html
http://www.itangyuan.com/book/15892919.html
http://m.itangyuan.com/book/15892919.html
http://www.itangyuan.com/book/15892921.html
http://m.itangyuan.com/book/15892921.html
http://www.itangyuan.com/book/15892922.html
http://m.itangyuan.com/book/15892922.html
http://www.itangyuan.com/book/15892923.html
http://m.itangyuan.com/book/15892923.html
http://www.itangyuan.com/book/15892925.html
http://m.itangyuan.com/book/15892925.html
http://www.itangyuan.com/book/15892926.html
http://m.itangyuan.com/book/15892926.html
http://www.itangyuan.com/book/15892927.html
http://m.itangyuan.com/book/15892927.html
http://www.itangyuan.com/book/15892928.html
http://m.itangyuan.com/book/15892928.html
http://www.itangyuan.com/book/15892929.html
http://m.itangyuan.com/book/15892929.html
http://www.itangyuan.com/book/15892930.html
http://m.itangyuan.com/book/15892930.html
http://www.itangyuan.com/book/15892931.html
http://m.itangyuan.com/book/15892931.html
http://www.itangyuan.com/book/15892934.html
http://m.itangyuan.com/book/15892934.html
http://www.itangyuan.com/book/15892935.html
http://m.itangyuan.com/book/15892935.html
http://www.itangyuan.com/book/15892936.html
http://m.itangyuan.com/book/15892936.html
http://www.itangyuan.com/book/15892938.html
http://m.itangyuan.com/book/15892938.html
http://www.itangyuan.com/book/15892940.html
http://m.itangyuan.com/book/15892940.html
http://www.itangyuan.com/book/15892941.html
http://m.itangyuan.com/book/15892941.html
http://www.itangyuan.com/book/15892942.html
http://m.itangyuan.com/book/15892942.html
http://www.itangyuan.com/book/15892943.html
http://m.itangyuan.com/book/15892943.html
http://www.itangyuan.com/book/15892944.html
http://m.itangyuan.com/book/15892944.html
http://www.itangyuan.com/book/15892950.html
http://m.itangyuan.com/book/15892950.html
http://www.itangyuan.com/book/15892953.html
http://m.itangyuan.com/book/15892953.html
根据实际业务需求来决定EXPIREAT和EXPIRE的过期时间参数。
如果一批key的确是同时过期,可以在EXPIREAT和EXPIRE的过期时间参数上,加上一个一定大小范围内的随机参数
文件系统的影响
在基础篇讲过,为了保证数据可靠性,Redis会采用AOF日志或者RDB快照。其中,AOF日志提供了三种日志写回策略:no、everysec、always。这三种写回策略依赖文件系统的两个系统调用完成:write和fsync。

write只要把日志记录写到内核缓冲区即可;Redis被广泛使用的一个很重要的原因是它的高性能。因此我们必要要重视所有可能影响Redis性能的因素、机制以及应对方案。影响Redis性能的五大方面的潜在因素,分别是:

Redis内部的阻塞式操作
CPU核和NUMA架构的影响
Redis关键系统配置
Redis内存碎片
Redis缓冲区
在前面的2讲中,学习了会导致Redis变慢的潜在阻塞点以及相应的解决方案,即异步线程机制和CPU绑核。除此之外,还有一些因素会导致Redis变慢。
35岁学英语成功了
零基础学英语要从哪里开始
48个英语音标正确读法
一分钟记10个英语单词
自学了一年的英语感觉没什么
每天听英语忽然听懂了
一张图看懂英语语法
小学初学英语的步骤
学好英语的42个要诀
学好英语的十个方法
最常用20000英语单词表
100个水果英文
雅思8000词汇大全
英语单词3500图片
日常单词500个
20000个英语单词带音标
8000个情绪词汇
高端有意境的英文单词
最常用10000英语单词表
ins超火英文网名
初中必背单词3000
1000个最常用英语单词
简单干净的英文网名
10000英语单词表和读音
小学生英语单词大全10000个
特殊意义小众的英文单词
初中最常用5000英语单词表
自学英语能找到工作吗
牛人三个月学会英语
自学英语能考什么证书

这一讲,介绍如何系统性应对Redis变慢这个问题。从问题认定、系统性排查和应对方案这3个方面来讲解。

判断Redis是否变慢?
最直接的方法,查看Redis的响应延迟。通过绝对值来判断,比如执行时间突然增长到几秒。

标签:www,http,Redis,html,DAR,五大,com,book,itangyuan
来源: https://blog.csdn.net/xhsxxf2007/article/details/112597434

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有