根据官方的建议,redis-server的相关配置建议如下,但是有些并不合适,LZ会进行说明(如果redis使用的内存还不到1GB,或者大量qps还不到1000的应用,这已经淘汰了99%的应用,很多配置基本上就无所谓了,基本上没这么大影响,保证高可用即可,不会有性能问题的;):

1、vm.overcommit_memory = 1。实际中最好让redis主节点仅使用50-60%的内存,剩余的用于执行bgsave和创建写命令的缓冲区,保证最大可能的sla。

2、禁用linux内核特性transparent huge pages,echo never > /sys/kernel/mm/transparent_hugepage/enabled,oracle也如此要求,TPH和传统的大页在机制上有些不同,参见http://blog.itpub.net/26736162/viewspace-2214374/。

3、避免使用swap或禁用

4、设置maxmemory,限制redis使用的内存数量,而非自动,否则发生交换就奇慢无比了;

5、如果是ssd的话,复制模式下建议master节点启用持久化选项(当超过数GB时,保存快照会对前端影响较大,如果能够容忍极端情况下小部分更新丢失,应在slave节点机进行,而非master节点,主要可能是国外数据没国内这么大);

6、一般应使用显示的redis.conf,而非使用内置的配置,可在启动时通过命令行指定/etc/redis.conf;

7、应显示设置rdb、aof日志文件目录及文件名,logfile参数;默认为工作目录:

# The filename where to dump the DB
dbfilename dump.rdb # rdb文件名 # The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name. # rdb存储目录
dir ./
[root@XXX redis-3.2.12]# ll | grep dump
-rw-r--r-- 1 root root 19274 Aug 8 20:12 dump_16379.rdb
-rw-r--r-- 1 root root 1259 Aug 8 22:23 dump_46379.rdb
-rw-r--r-- 1 root root 446620 Nov 23 02:05 dump.rdb
############################## APPEND ONLY MODE ###############################

# By default Redis asynchronously dumps the dataset on disk. This mode is
# good enough in many applications, but an issue with the Redis process or
# a power outage may result into a few minutes of writes lost (depending on
# the configured save points).
#
# The Append Only File is an alternative persistence mode that provides
# much better durability. For instance using the default data fsync policy
# (see later in the config file) Redis can lose just one second of writes in a
# dramatic event like a server power outage, or a single write if something
# wrong with the Redis process itself happens, but the operating system is
# still running correctly.
#
# AOF and RDB persistence can be enabled at the same time without problems.
# If the AOF is enabled on startup Redis will load the AOF, that is the file
# with the better durability guarantees.
#
# Please check http://redis.io/topics/persistence for more information. appendonly yes # The name of the append only file (default: "appendonly.aof") appendfilename "appendonly.aof" # The fsync() call tells the Operating System to actually write data on disk
# instead of waiting for more data in the output buffer. Some OS will really flush
# data on disk, some other OS will just try to do it ASAP.
#
# Redis supports three different modes:
#
# no: don't fsync, just let the OS flush the data when it wants. Faster.
# always: fsync after every write to the append only log. Slow, Safest.
# everysec: fsync only one time every second. Compromise.
#
# The default is "everysec", as that's usually the right compromise between
# speed and data safety. It's up to you to understand if you can relax this to
# "no" that will let the operating system flush the output buffer when
# it wants, for better performances (but if you can live with the idea of
# some data loss consider the default persistence mode that's snapshotting),
# or on the contrary, use "always" that's very slow but a bit safer than
# everysec.
#
# More details please check the following article:
# http://antirez.com/post/redis-persistence-demystified.html
#
# If unsure, use "everysec". # appendfsync always AOF默认每秒写一次,跟mysql的innodb redo刷新机制是一样的
appendfsync everysec
# appendfsync no

8、各个版本的详细配置可参考:

9、重要的是:

1、单进程架构,这意味着单个key的value不能过大,例如几兆,这会严重影响TPS,具体拆分可以参考:https://blog.csdn.net/beyond59241/article/details/78889867/
2、支持多database,不过最好使用多个instance的方式,有些客户端可能不支持多instance,同时性能也比较难以排查
3、不支持namespace的概念,所以最好使用前提前规划,比如namespace:key_name的方式,避免日后混乱
4、vm.swappiness=0 在os swap期间,进程会block直到完成,所以应该尽量避免

10、客户端缓冲大小配置,尤其是是在行情接收场景中。https://blog.csdn.net/luyaoying001/article/details/80264347

11、其它实践可以参考:https://www.cnblogs.com/ajianbeyourself/p/4472788.html

12、避免快照所在盘磁盘空间满,否则容易出现redis挂起。

redis配置注意事项(适合于较大配置)的更多相关文章

  1. Redis相关注意事项

    本文介绍了五个使用Redis使用时的注意事项.如果你在使用或者考虑使用Redis,你可以学习一下下面的一些建议,避免遇到以下提到的问题. 一.配置相关注意事项 1.涉及到内存的单位注意添加 b 1k ...

  2. DUBBO安装配置注意事项

    DUBBO安装配置注意事项 参考URL:http://blog.csdn.net/lichunan/article/details/40349645 ====== 管理端: 记得更改TOMCAT的端口 ...

  3. Redis在Windows上使用和集群配置

    一.什么是Redis Redis是一个开源的,使用C语言编写的面向键值对类型的分布式Nosql数据库系统,功能类似Memcache,但比Memcache功能更丰富.官网地址:https://redis ...

  4. .Net下Redis使用注意事项

    .Net下Redis使用注意事项 注:Redis的安装方法和桌面端工具很多,不在本文讨论范围内. 一:不结合适用场景的技术都是耍流氓,Redis主要适用场景: 简单字符串缓存 简单队列 简单发布订阅 ...

  5. Redis Cluster 原理说的头头是道,这些配置不懂就是纸上谈兵

    Redis Cluster 原理说的头头是道,这些配置不懂就是纸上谈兵 Redis Cluster 集群相关配置,使用集群方式的你必须重视和知晓.别嘴上原理说的头头是道,而集群有哪些配置?如何配置让集 ...

  6. Hibernate框架大配置关联小配置

    1 <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-// ...

  7. Redis及虚拟机windows两种环境安装配置

    ---恢复内容开始--- Redis  /rae  dis/是一个开源的Key-Value数据库.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链 ...

  8. Redis入门很简单之三【常见参数配置】

    Redis入门很简单之三[常见参数配置] 博客分类: NoSQL/Redis/MongoDB redisnosql缓存中间件memcached  Redis的一下常见设置都是通过对redis.conf ...

  9. Spring,SpringMvc配置常见的坑,注解的使用注意事项,applicationContext.xml和spring.mvc.xml配置注意事项,spring中的事务失效,事务不回滚原因

    1.Spring中的applicationContext.xml配置错误导致的异常 异常信息: org.apache.ibatis.binding.BindingException: Invalid ...

随机推荐

  1. CentOS7安装CDH 第七章:CDH集群Hadoop的HA配置

    相关文章链接 CentOS7安装CDH 第一章:CentOS7系统安装 CentOS7安装CDH 第二章:CentOS7各个软件安装和启动 CentOS7安装CDH 第三章:CDH中的问题和解决方法 ...

  2. Python函数Day4

    一.内容补充 __iter__() 就是 iter(),iter() 调用的就是__iter__() __next__() 就是 next(),next()调用的就是__next__() __clos ...

  3. 利用 Python django 框架 输入汉字,数字,字符,等。。转成二维码!

    利用 Python django 框架 输入汉字,数字,字符,等..转成二维码! 模块必备:Python环境 + pillow  + qrcode 模块 核心代码import qrcode qr = ...

  4. 【OF框架】在Azure DevOps中配置项目持续集成CI服务,推送镜像到Azure容器注册表

    准备工作 开通Azure账号,具有开通服务权限,关键是里面要有钱. 开通Azure DevOps,能够创建组织和项目. 具备一定的DevOps知识,了解CICD概念.Docker基本操作. 一.创建& ...

  5. kvm虚拟化环境的搭建

    首先搭建kvm的虚拟化环境,我选择的环境是在vmvare上的Centos 7的虚拟机,在该环境上搭建kvm的虚拟化环境 1:安装虚拟机(该过程自行安装) 2:操作系统环境的设置 (1)修改内核模式为兼 ...

  6. JVM堆空间用途分析与划分依据

    在上一次[https://www.cnblogs.com/webor2006/p/9876493.html]已经对JVM的内存空间的划分进行了理论化的学习,这次还是对上一次提到的理论进行进一步的补充, ...

  7. evpp http response_http_code_

    response_http_code_  909 例子代码   evpp  代码内例子 注释 可以读一下

  8. numpy 参考:https://mp.weixin.qq.com/s?__biz=MzU1MjYzNjQwOQ==&mid=2247486010&idx=1&sn=e42e6706e0e285ecbfdbbd76fb4ff352&chksm=fbfe50accc89d9ba56a3167c519638f1327a5c5bf12ed59dd8c6de9b2c25baeec1f1f8ad5fb7&

    a=np.array([,,,]) b=np.arange() print(a,b) [ ] [ ] 对应相乘 c2=a*b      [ 0  2  6 12] 对应相乘再求和  c3=a.dot( ...

  9. 金蝶二次开发C#

    1 建立C#类库项目 2 引用EBOS组建Kingdee.K3.BOS.PlugInModel 3 示例代码 usingSystem; usingSystem.Collections.Generic; ...

  10. UWB DWM1000 开源项目框架

    UWB 目前比较火热,不论国内还是国外目前都掀起一股热潮. 但是实际工程代码很少,开源代码更少. 目前代码主要有 1 DecaWave Release的定位源码,代码基于TWR,一个非常大的状态机. ...