Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis.conf 中文 #8

Open
meigea opened this issue Jun 24, 2019 · 0 comments
Open

Redis.conf 中文 #8

meigea opened this issue Jun 24, 2019 · 0 comments
Labels
duplicate This issue or pull request already exists good first issue Good for newcomers invalid This doesn't seem right

Comments

@meigea
Copy link

meigea commented Jun 24, 2019

#Redis配置文件示例。
#
#注意,为了读取配置文件,Redis必须是
#以文件路径作为第一个参数开始:
#
#。/ redis-server /path/to/redis.conf

#单位注意事项:当需要内存大小时,可以指定
#通常以1k 5GB 4M的形式出现,以此类推:
#
#1k => 1000字节
#1kb => 1024字节
#1m => 1000000字节
#1mb => 1024 * 1024字节
#1g => 1000000000字节
#1gb => 1024 * 1024 * 1024字节
#
#单位不区分大小写,因此1GB 1Gb 1gB都是相同的。

################################## INCLUDES ############### ####################

#在此处包含一个或多个其他配置文件。如果你这很有用
#有一个标准模板,可以转到所有Redis服务器,但也需要
#自定义一些每服务器设置。包含文件可以包括
#the other files,所以明智地使用它。
#
#通知选项“include”不会被命令“CONFIG REWRITE”重写
#来自admin或Redis Sentinel。由于Redis总是使用最后一次处理
#line作为配置指令的值,你最好把include包括在内
#在此文件的开头,以避免在运行时覆盖配置更改。
#
#如果您有兴趣使用includes来覆盖配置
#options,最好使用include作为最后一行。
#
#include /path/to/local.conf
#include /path/to/other.conf

################################## MODULES ############### ######################

#启动时加载模块。如果服务器无法加载模块
#它会中止。可以使用多个loadmodule指令。
#
#loadmodule /path/to/my_module.so
#loadmodule /path/to/other_module.so

################################## NETWORK ############### ######################

#默认情况下,如果未指定“bind”配置指令,则Redis将侦听
#来自服务器上所有可用网络接口的连接。
#可以使用只听一个或多个选定的接口
#“bind”配置指令,后跟一个或多个IP地址。
#
# 例子:
#
#bind 192.168.1.100 10.0.0.1
#bind 127.0.0.1 :: 1
#
#~~~警告~~~如果运行Redis的计算机直接暴露在
#internet,绑定到所有接口是危险的,并将暴露
互联网上每个人的#instance。因此,默认情况下我们取消注释
#nit bind指令,这将强制Redis只收听
#IPv4环回接口地址(这意味着Redis将能够
#仅接受来自运行到同一台计算机的客户端的连接
# 在跑)。
#
#如果您确定您希望您不要听到所有接口
#JUST评论以下内容。
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
绑定127.0.0.1

#保护模式是一层安全保护,以避免这种情况
在互联网上打开的Redis实例被访问和利用。
#
#当保护模式打开且如果:
#
#1)服务器没有显式绑定到一组地址使用
#“bind”指令。
#2)没有配置密码。
#
#服务器只接受来自客户端连接的连接
#IPv4和IPv6环回地址127.0.0.1和:: 1,以及Unix域
#sockets。
#
#默认情况下启用保护模式。你应该只在禁用它时禁用它
#您确定希望其他主机的客户端连接到Redis
#即使未配置身份验证,也不配置特定的接口集
#使用“bind”指令明确列出。
保护模式是

#接受指定端口上的连接,默认为6379(IANA#815344)。
#如果指定了端口0,Redis将不会侦听TCP套接字。
港口6379

#TCP listen()backlog。
#
#在每秒高请求的环境中,您需要按顺序存储高积压
#以避免缓慢的客户端连接问题。注意Linux内核
#将默默地将其截断为/ proc / sys / net / core / somaxconn的值
#确保同时提高somaxconn和tcp_max_syn_backlog的值
#以获得所需的效果。
tcp-backlog 511

#Unix socket。
#
#指定将用于侦听的Unix套接字的路径
#incoming connections。没有默认值,所以Redis不会听
#未指定时在unix套接字上。
#
#unixsocket /tmp/redis.sock
#unixsocketperm 700

#客户端空闲N秒后关闭连接(0表示禁用)
超时0

#TCP keepalive。
#
#如果非零,则使用SO_KEEPALIVE将TCP ACK发送给缺席的客户端
沟通#。这有两个原因:
#
#1)检测死对等体。
#2)从网络的角度来看连接是否存在
#设备在中间。
#
#在Linux上,指定的值(以秒为单位)是用于发送ACK的时间段。
#请注意,要关闭连接,需要两倍的时间。
#在其他内核上,周期取决于内核配置。
#
#此选项的合理值为300秒,这是新的
#Redis默认以Redis 3.2.1开头。
tcp-keepalive 300

################################# 一般 ################ #####################

#默认情况下,Redis不作为守护程序运行。如果需要,请使用“是”。
#请注意,当守护进程时,Redis会在/var/run/redis.pid中编写一个pid文件。
daemonize no

#如果您从upstart或systemd运行Redis,Redis可以与您的
#监督树。选项:
#supervis no  - 没有监督互动
#supervised upstart  - 将Redis置于SIGSTOP模式,发出信号新贵
#supervised systemd  - 通过将READY = 1写入$ NOTIFY_SOCKET来发送信号
#supervised auto  - 检测基于的upstart或systemd方法
#UPSTART_JOB或NOTIFY_SOCKET环境变量
#注意:这些监督方法仅表示“过程准备就绪”。
#他们不会将持续的活跃状态恢复给您的主管。
监督没有

#如果指定了pid文件,Redis会将其写入启动时指定的位置
#并在退出时将其删除。
#
#当服务器运行非守护进程时,如果没有,则不会创建pid文件
#在配置中指定。当服务器被守护进程时,pid文件
#即使未指定也使用,默认为“/var/run/redis.pid”。
#
#创建一个pid文件是最好的:如果Redis无法创建它
#没有什么不好的事情,服务器将启动并正常运行。
pidfile /var/run/redis_6379.pid

#指定服务器详细级别。
#这可以是以下之一:
#debug(很多信息,对开发/测试很有用)
#verbose(许多很少有用的信息,但不像调试级别一样混乱)
#notice(中等冗长,你想要生产什么)
#warning(仅记录非常重要/关键的消息)
loglevel通知

#指定日志文件名。空字符串也可用于强制
#Redis登录标准输出。请注意,如果您使用标准
#output for logging but daemonize,logs将被发送到/ dev / null
logfile“”

#要启用日志记录到系统记录器,只需将'syslog-enabled'设置为yes,
#并可选择更新其他syslog参数以满足您的需求。
#syslog-enabled no

#指定syslog标识。
#syslog-ident redis

#指定syslog工具。必须是USER或LOCAL0-LOCAL7之间。
#syslog-facility local0

#设置数据库的数量。默认数据库是DB 0,您可以选择
#使用SELECT <dbid>在每个连接的基础上使用另一个
#dbid是介于0和'databases'-1之间的数字
数据库16

#默认情况下,Redis仅在开始登录时显示ASCII艺术徽标
#standard输出,如果标准输出是TTY。基本上这意味着
#通常只在交互式会话中显示徽标。
#
#但是可以强制执行4.0之前的行为并始终显示
#启动日志中的ASCII art徽标,将以下选项设置为yes。
always-show-logo yes

################################ SNAPSHOTTING ################# ###############
#
#将数据库保存在磁盘上:
#
#save <seconds> <changes>
#
#如果给定的秒数和给定的数量,将保存数据库
#发生了针对DB的写操作次数。
#
#在下面的示例中,行为将是保存:
#900秒(15分钟)后,如果至少更改了1个键
#30秒后(5分钟)如果至少改变了10个键
#60秒后如果至少改变了10000个键
#
#注意:您可以通过注释掉所有“保存”行来完全禁用保存。
#
#也可以删除所有先前配置的保存
#通过添加带有单个空字符串参数的save指令来指向
#like如下例所示:
#
# 保存 ””

节省900 1
节省300 10
节省60 10000

#默认情况下,如果启用了RDB快照,Redis将停止接受写入
#(至少一个保存点)和最新的后台保存失败。
#这将使用户意识到(以一种困难的方式)数据不会持久存在
#在磁盘上正常,否则很可能没有人会注意到一些
#disaster将会发生。
#
#如果后台保存过程将再次开始工作,Redis会
#自动允许再次写入。
#
#但是,如果您已设置正确的Redis服务器监视
#和持久性,你可能想要禁用此功能,以便Redis将
#即使磁盘出现问题,也能继续正常工作,
#permissions,等等。
stop-writes-on-bgsave-error是的

#转储.rdb数据库时使用LZF压缩字符串对象?
#默认设置为'yes',因为它几乎总是一场胜利。
#如果要在保存子节点中保存一些CPU,请将其设置为“否”
#如果您有可压缩的值或键,数据集可能会更大。
rdbcompression是的

#自RDB第5版以来,CRC64校验和位于文件末尾。
#这使得格式更耐腐败,但有一个性能
保存和加载RDB文件时,命中付费(大约10%),因此您可以禁用它
#表现最佳。
#
禁用校验和创建的#RDB文件的校验和为零
#告诉加载代码跳过检查。
rdbchecksum是的

#转储数据库的文件名
dbfilename dump.rdb

#工作目录。
#
#DB将写入此目录,并指定文件名
#above使用'dbfilename'配置指令。
#
#还将在此目录中创建仅附加文件。
#
#请注意,您必须在此处指定目录,而不是文件名。
dir ./

################################# REPLICATION ################ #################

#Master-Replica复制。使用replicaof将Redis实例作为副本
#另一台Redis服务器。关于Redis复制的一些事情要尽快理解。
#
#+ ------------------ + + --------------- +
#| 大师| ---> | 副本|
#| (接收写)| | (确切的副本)|
#+ ------------------ + + --------------- +
#
#1)Redis复制是异步的,但您可以将master配置为
#如果看起来与至少没有连接,则停止接受写入
#给定数量的副本。
#2)Redis副本能够执行部分重新同步
#master如果复制链接丢失的次数相对较少
# 时间。您可能希望配置复制积压大小(请参阅下一步
#该文件的部分)根据您的需要具有合理的价值。
#3)复制是自动的,不需要用户干预。之后
#network partition replicas会自动尝试重新连接到master
#并与它们重新同步。
#
#replicaof <masterip> <masterport>

#如果主设备受密码保护(使用“requirepass”配置)
#directive下面的命令)可以告诉副本以前进行身份验证
#开始复制同步过程,否则主人会
#拒绝副本请求。
#
#masterauth <master-password>

#当副本丢失与主服务器的连接时,或者复制时
#仍在进行中,副本可以采用两种不同的方式:
#
#1)如果replica-serve-stale-data设置为'yes'(默认值)副本将
#仍然回复客户端请求,可能是过期数据,或者
如果这是第一次同步,#data set可能只是空的。
#
#2)如果replica-serve-stale-data设置为'no',副本将回复
对所有类型的命令都出现错误“SYNC with master in progress”
#但是INFO,replicaOF,AUTH,PING,SHUTDOWN,REPLCONF,ROLE,CONFIG,
#SubBSCRIBE,UNSUBSCRIBE,PSUBSCRIBE,PUNSUBSCRIBE,PUBLISH,PUBSUB,
#COMMAND,POST,HOST:和LATENCY。
#
replica-serve-stale-data是的

#您可以配置副本实例以接受或不接受写入。写作反对
#副本实例可能对存储一些短暂的数据很有用(因为数据
写在副本上的#将在与主服务器重新同步后轻松删除)但是
如果客户因为a而写信,#也可能会导致问题
#配置错误。
#
#由于Redis 2.6默认情况下副本是只读的。
#
#注意:只读副本不是为了暴露给不受信任的客户端而设计的
# 在网上。它只是一个防止滥用实例的保护层。
#仍然是只读副本默认导出所有管理命令
#例如CONFIG,DEBUG等。在一定程度上你可以改进
使用'rename-command'来隐藏所有的只读副本的#security
#administration / dangerous命令。
replica-read-only是的

#Replication SYNC策略:磁盘或套接字。
#
#------------------------------------------------- ------
#警告:目前无实际的复制是实验性的
#------------------------------------------------- ------
#
#新副本和重新连接无法继续复制的副本
#process只是收到差异,需要做一个所谓的“完整”
#synchronization“.RDB文件从主服务器传输到副本服务器。
#传输可以通过两种不同的方式进行:
#
#1)磁盘支持:Redis主服务器创建一个写入RDB的新进程
磁盘上的#file。稍后该文件由父母传输
#逐步处理副本。
#2)无盘:Redis主机创建一个直接写入的新进程
#RDB文件到副本套接字,根本不接触磁盘。
#
#使用磁盘支持的复制,在生成RDB文件时,会有更多副本
当前子进程生成时,#可以排队并与RDB文件一起提供
#RDB文件完成其工作。使用无盘复制而不是一次
#转移开始,到达的新副本将排队并进行新的转移
#将在当前终止时启动。
#
#使用无盘复制时,主机等待可配置的数量
#开始传输之前的#time(以秒为单位),希望有多个副本
#将到达并且传输可以并行化。
#
#使用慢速磁盘和快速(大带宽)网络,无盘复制
#效果更好。
repl-diskless-sync no

#启用无盘复制时,可以配置延迟
#服务器等待生成通过套接字传输RDB的子节点
#复制品。
#
#这很重要,因为一旦转移开始,就无法提供服务
#new replicas到达,将排队等待下一次RDB传输,所以服务器
#等待延迟以便让更多的副本到达。
#
#延迟以秒为单位指定,默认为5秒。要禁用
#完全将它设置为0秒,传输将尽快开始。
repl-diskless-sync-delay 5

#Replicas以预定义的时间间隔将PING发送到服务器。有可能改变
使用repl_ping_replica_period选项#this interval。默认值为10
#秒。
#
#rep-ping-replica-period 10

#以下选项设置复制超时:
#
#1)从副本的角度来看,在SYNC期间批量传输I / O.
#2)从副本(数据,ping)的角度来看主超时。
#3)从主设备的角度来看副本超时(REPLCONF ACK ping)。
#
#确保此值大于该值非常重要
#为repl-ping-replica-period指定,否则将检测到超时
#每次主服务器和副本服务器之间的流量都很低。
#
#repl-timeout 60

#在SYNC后禁用副本套接字上的TCP_NODELAY?
#
#如果选择“是”,Redis将使用较少数量的TCP数据包和
#将数据发送到副本的带宽减少。但这可能会增加延迟
#在副本端出现的数据,最多40毫秒
#Linux内核使用默认配置。
#
#如果选择“否”,数据在副本端出现的延迟将会出现
减少#但将使用更多带宽进行复制。
#
#默认情况下,我们针对低延迟进行优化,但是在非常高的流量条件下
#或当主人和副本很多跳时,将其转为“是”可能
#是个好主意。
repl-disable-tcp-nodelay no

#设置复制积压大小。积压是积累的缓冲区
#relica数据在副本断开一段时间后,以便复制时
#想再次重新连接,通常不需要完全重新同步,但需要部分重新同步
#resync就足够了,只需传递副本错过的数据部分
#disconnected。
#
#复制积压越大,副本的时间就越长
#已断开连接,之后可以执行部分​​重新同步。
#
#只有在连接了至少一个副本时才分配积压。
#
#repl-backlog-size 1mb

#在主服务器不再连接副本一段时间之后,积压
#将被释放。以下选项配置秒数
#需要经过,从最后一个副本断开的时间开始,为
#要释放的待办事项缓冲区。
#
#请注意,副本永远不会释放积压超时,因为它们可能是
#后来提升为大师,应该能够正确地“部分地”
#resynchronize“与副本:因此他们应该总是积累积压。
#
#值为0表示永远不会释放积压。
#
#repl-backlog-ttl 3600

#副本优先级是Redis在INFO输出中发布的整数。
#Redis Sentinel使用它来选择要升级到的副本
#master如果主服务器不再正常工作。
#
#具有低优先级编号的副本被认为更适合升级,因此
#例如,如果有三个副本,优先级为10,100,25 Sentinel将
#选择优先级为10的那个,即最低的。
#
#但是特殊优先级为0会将副本标记为无法执行
#master的角色,因此永远不会选择优先级为0的副本
#Redis Sentinel进行推广。
#
#默认优先级为100。
复制优先级100

#如果小于,则主机可以停止接受写入
#N个副本连接,滞后小于或等于M秒。
#
#N个副本需要处于“在线”状态。
#
#以秒为单位的延迟,必须<=指定值,由...计算
#从副本收到的最后一次ping,通常每秒发送一次。
#
#此选项不保证N个副本将接受写入,但是
#将限制丢失写入的窗口,以防副本不足
#可用,达到指定的秒数。
#
#例如要求至少3个副本使用滞后<= 10秒:
#
#min-replicas-to-write 3
#min-replicas-max-lag 10
#
#将其中一个设置为0将禁用该功能。
#
#默认情况下,min-replicas-to-write设置为0(禁用功能)和
#min-replicas-max-lag设置为10。

#Redis master能够列出附加的地址和端口
#sliclicas以不同的方式。例如“INFO复制”部分
#提供此信息,在其他工具中使用
#Redis Sentinel以发现副本实例。
#此信息可用的另一个地方是输出
#“ROLE”命令的主人。
#
#获取通常由副本报告的列出的IP和地址
#以下列方式:
#
#IP:通过检查对端地址自动检测地址
副本用于与主节点连接的套接字的#。
#
#Port:端口在复制期间由副本进行通信
#crack,通常是副本用于的端口
#listen for connections。
#
#但是当端口转发或网络地址转换(NAT)时
#used,副本实际上可以通过不同的IP和端口访问
#对。副本可以使用以下两个选项
#向其master报告一组特定的IP和端口,以便同时使用INFO
#和ROLE将报告这些值。
#
#如果您只需要覆盖,则无需使用这两个选项
#端口或IP地址。
#
#revlica-announce-ip 5.5.5.5
#revlica-announce-port 1234

################################## SECURITY ############### ####################

#要求客户端在处理任何其他客户端之前发出AUTH <PASSWORD>
#命令。这可能在您不信任的环境中很有用
#有权访问运行redis-server的主机的其他人。
#
#这应该保持注释以便向后兼容,因为大多数
#people不需要auth(例如,他们运行自己的服务器)。
#
#警告:由于Redis非常快,外部用户可以尝试
#150k密码每秒对一个好盒子。这意味着你应该
#使用非常强大的密码,否则很容易破解。
#
#requirepass foobared

#命令重命名。
#
#可以在共享中更改危险命令的名称
# 环境。例如,CONFIG命令可以重命名为某些内容
#难以猜测,因此仍可用于内部使用工具
#但不适用于一般客户。
#
#示例:
#
#rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
#也可以通过将命令重命名为完全终止命令
#空字符串:
#
#rename-command CONFIG“”
#
#请注意更改登录到的命令的名称
#OF文件或传输到副本可能会导致问题。

###################################客户############## ######################

#同时设置已连接客户端的最大数量。默认情况下
#此限制设置为10000个客户端,但是如果Redis服务器不是
#能够配置进程文件限制以允许指定的限制
#允许的最大客户端数设置为当前文件限制
#-minus 32(因为Redis为内部用途保留了一些文件描述符)。
#
#达到限制后,Redis将关闭所有发送的新连接
#错误'达到的最大客户端数'。
#
#maxclients 10000

############################## 内存管理 ################## ##############

#设置内存使用限制为指定的字节数。
#达到内存限制时,Redis将尝试删除密钥
#根据所选的驱逐政策(参见maxmemory-policy)。
#
#如果Redis无法根据策略删除密钥,或者策略是否
#set to'noeviction',Redis将开始回复命令错误
#将使用更多内存,如SET,LPUSH等,并将继续
#回复GET等只读命令。
#
#将Redis用作LRU或LFU缓存时,此选项通常很有用
#设置实例的硬内存限制(使用'noeviction'策略)。
#
#警告:如果你有一个附加到maxmemory on的实例的副本,
#减去提供副本所需的输出缓冲区的大小
#来自使用的内存计数,以便网络问题/重新同步
#不会触发关键被驱逐的循环,反过来输出
#副本的缓冲区已满,删除的键被删除触发删除
更多密钥的数量,等等,直到数据库完全清空。
#
#简而言之......如果您附加了副本,建议您设置较低的副本
#maxumemeory的限制,以便系统上有一些可用的RAM用于副本
#output buffers(但如果策略是'noeviction'则不需要这样做)。
#
#maxmemory <bytes>

#MAXMEMORY POLICY:Redis将如何选择maxmemory时要删除的内容
# 到达了。您可以选择五种行为:
#
#molatile-lru  - >使用过期集在密钥中使用近似LRU的Evict。
#allkeys-lru  - >使用近似LRU逐出任何键。
#molatile-lfu  - >在具有过期集的密钥中使用近似LFU进行Evict。
#allkeys-lfu  - >使用近似的LFU逐出任何键。
#folatile-random  - >删除设置了expire的随机密钥。
#allkeys-random  - >删除随机密钥,任意密钥。
#molatile -ttl  - >删除具有最近到期时间的密钥(次要TTL)
#noeviction  - >不要驱逐任何东西,只是在写操作上返回错误。
#
#LRU表示最近最少使用
#LFU意味着最少使用
#
#LWU,LFU和volatile-ttl都是使用近似值实现的
#随机算法。
#
#注意:使用上述任何策略时,Redis将在写入时返回错误
#operations,当没有合适的驱逐钥匙时。
#
#在编写之日,这些命令是:set setnx setex append
#incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
#sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
#zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
#getset mset msetnx exec sort
#
#默认为:
#
#maxmemory-policy noeviction

#LRU,LFU和最小TTL算法不是精确的算法,而是近似的
#algorithms(为了节省内存),所以你可以调整它的速度或
# 准确性。默认情况下,Redis将检查五个键并选择一个键
#最近使用较少,您可以使用以下更改样本大小
#configuration指令。
#
#默认值为5会产生足够好的结果。10近似非常接近
#true LRU但成本更高的CPU。3更快但不是很准确。
#
#maxmemory-samples 5

#从Redis 5开始,默认情况下,副本将忽略其maxmemory设置
#(除非在故障转移后或手动将其提升为master)。它的意思是
#钥匙的驱逐将由主人处理,发送
#DEL命令到副本,因为密钥在主端驱逐。
#
#此行为可确保主服务器和副本服务器保持一致,通常也是如此
#您想要什么,但是如果您的副本是可写的,或者您希望副本具有
#一个不同的内存设置,你确定所有写入的内容都是
#recrelica是幂等的,那么你可以改变这个默认值(但一定要明白
# 你在做什么)。
#
#请注意,由于默认情况下副本不会逐出,因此可能会使用更多副本
#memory比通过maxmemory设置的内存(可能有某些缓冲区
#在副本上更大,或者数据结构有时可能会占用更多内存
# 向前)。因此,请确保您监控副本并确保它们足够
#memory在主人命中之前从未达到真正的内存不足状态
#配置的maxmemory设置。
#
#recrelica-ignore-maxmemory是的

############################# LAZY FREEING ################### #################

#Redis有两个基元来删除键。一个叫DEL,是一个阻塞
#删除对象。这意味着服务器停止处理新命令
#以便回收与同步中的对象关联的所有内存
# 办法。如果删除的密钥与小对象相关联,则需要时间
#为了执行DEL命令非常小并且与大多数其他命令相当
Redis中的#O(1)或O(log_N)命令。但是,如果密钥与a关联
#credated value包含数百万个元素,服务器可以阻止
#很长一段时间(甚至几秒钟)才能完成操作。
#
#由于上述原因,Redis还提供非阻塞删除原语
#例如UNLINK(非阻塞DEL)和FLUSHALL和ASYNC选项
#FLUSHDB命令,以便在后台回收内存。那些命令
#在恒定时间内执行。另一个线程将逐步释放
#对象在后台尽可能快。
#
FLUSHALL和FLUSHDB的#DEL,UNLINK和ASYNC选项由用户控制。
#这取决于应用程序的设计,以了解什么时候它是好的
#idea使用其中一个。但是Redis服务器有时必须这样做
#删除密钥或刷新整个数据库作为其他操作的副作用。
#具体而言,Redis删除对象,而不依赖于用户调用
#以下场景:
#
#1)在驱逐时,由于maxmemory和maxmemory策略配置,
#为了给新数据腾出空间,而不必超过指定的数据
#内存限制。
#2)因为过期:当一个关键时间存在的时候(参见
必须从内存中删除#EXPRIRE命令。
#3)由于将数据存储在可能的密钥上的命令的副作用
# 已经存在。例如,RENAME命令可以删除旧密钥
#content替换为另一个。同样是SUNIONSTORE
#或SORT with STORE选项可能会删除现有密钥。SET命令
#本身删除指定键的任何旧内容以便替换
#with指定的字符串。
#4)在复制期间,当副本执行完全重新同步时
#the master,整个数据库的内容被删除
#加载刚刚传输的RDB文件。
#
#在以上所有情况下,默认是以阻塞方式删除对象,
#就像调用DEL一样。但是,您可以专门配置每个案例
#以便以非阻塞的方式释放内存,就像UNLINK一样
#被调用,使用以下配置指令:

lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no

############################## APPEND ONLY MODE ################# ##############

#默认情况下,Redis异步转储磁盘上的数据集。这种模式是
#在许多应用程序中已经足够好了,但是Redis进程或者是一个问题
#停电可能导致几分钟的写入丢失(取决于
#配置的保存点)。
#
#Onadnd Only File是另一种提供的持久性模式
#更好的耐用性。例如,使用默认数据fsync策略
#(参见配置文件中的后面部分)Redis只能丢失一秒的写入时间
#戏剧性事件,如服务器断电,或单个写入的东西
#Rinis进程本身发生错误,但操作系统是
#仍然正常运行。
#
#AOF和RDB持久性可以同时启用而不会出现问题。
#如果在启动时启用AOF,Redis将加载AOF,即文件
#具有更好的耐用性保证。
#
#请查看http://redis.io/topics/persistence以获取更多信息。

附带没有

#仅附加文件的名称(默认值:“appendonly.aof”)

appendfilename“appendonly.aof”

#fsync()调用告诉操作系统实际在磁盘上写入数据
#而不是在输出缓冲区中等待更多数据。有些操作系统会真正刷新
在磁盘上的数据,其他一些操作系统将尽快尝试。
#
#Redis支持三种不同的模式:
#
#no:不要fsync,只需让操作系统在需要时刷新数据。快点。
每次写入仅附加日志后#always:fsync。慢,最安全。
#everysec:fsync每秒只有一次。妥协。
#
#默认为“everysec”,因为这通常是正确的妥协
#速度和数据安全。如果你能放松一下,你可以理解
#“no”表示操作系统在刷新输出缓冲区时
#它想要,为了更好的表现(但如果你能接受这个想法
#一些数据丢失考虑了快照的默认持久模式,
#或相反,使用“总是”,这是非常缓慢,但比...更安全
#verysec。
#
#更多细节请查看以下文章:
#http://antirez.com/post/redis-persistence-demystified.html
#
#如果不确定,请使用“everysec”。

#appendfsync总是
appendfsync everysec
#appendfsync no

#当AOF fsync策略设置为always或everysec,以及后台时
#saving process(后台保存或AOF日志后台重写)是
#在某些Linux配置中对磁盘执行大量I / O操作
#redis可能会在fsync()调用中阻塞太长时间。请注意,没有修复
#this目前,因为即使在不同的线程中执行fsync也会阻塞
#我们的同步write(2)调用。
#
#为了缓解此问题,可以使用以下选项
#会阻止fsync()在主进程中被调用
#BGSAVE或BGREWRITEAOF正在进行中。
#
#这意味着当另一个孩子正在储蓄时,Redis的耐用性是
#与“appendfsync none”相同。实际上,这意味着它
#可能在最糟糕的情况下丢失最多30秒的日志(使用
#default Linux设置)。
#
#如果遇到延迟问题,请将其转为“是”。否则保留为
从持久性的角度来看,#“no”是最安全的选择。

no-appendfsync-on-rewrite no

#自动重写仅附加文件。
#Redis能够自动重写隐式调用的日志文件
#OFREWRITEAOF当AOF日志大小增长指定的百分比时。
#
#这是它的工作原理:Redis会在记忆之后记住AOF文件的大小
#revent rewrite(如果重启后没有重写,则大小为
#使用启动时的AOF)。
#
#将此基本大小与当前大小进行比较。如果当前大小是
#大于指定的百分比,触发重写。也
#您需要指定要重写的AOF文件的最小大小,这个
#即使百分比增加,也有助于避免重写AOF文件
#已达到,但仍然很小。
#
#指定零的百分比以禁用自动AOF
#rewrite功能。

auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

#在Redis期间,可能会发现AOF文件被截断
#auvent进程,当AOF数据加载回内存时。
#当运行Redis的系统时,可能会发生这种情况
#crashes,特别是在没有安装ext4文件系统的情况下
#data = ordered选项(但是Redis本身不会发生这种情况
#崩溃或中止,但操作系统仍能正常工作)。
#
#Redis可以在发生这种情况时退出,或者加载尽可能多的错误
#data尽可能(现在是默认值)并在找到AOF文件时启动
#在最后被截断。以下选项控制此行为。
#
#如果aof-load-truncated设置为yes,则加载截断的AOF文件
#Redis服务器开始发出日志以通知用户该事件。
#否则,如果该选项设置为no,则服务器将中止并显示错误
#并拒绝开始。当该选项设置为no时,用户需要
#在重启之前使用“redis-check-aof”实用程序修复AOF文件
# 服务器。
#
#请注意,如果发现AOF文件在中间被破坏
#服务器仍将退出并显示错误。此选项仅适用于
#Redis将尝试从AOF文件中读取更多数据但没有足够的字节
#将被找到。
aof-load-truncated是的

#重写AOF文件时,Redis可以在中使用RDB前导码
#AOF文件,可以更快地重写和恢复。转动此选项时
重写的AOF文件上的#由两个不同的节组成:
#
#[RDB文件] [AOF尾]
#
#加载时Redis识别出AOF文件以“REDIS”开头
#tring并加载带前缀的RDB文件,并继续加载AOF
# 尾巴。
aof-use-rdb-preamble是的

################################ LUA SCRIPTING ################ ###############

#Lua脚本的最大执行时间(以毫秒为单位)。
#
#如果达到最大执行时间,Redis将记录脚本
#在最大允许时间后仍然执行并将开始执行
#回复带有错误的查询。
#
#当一个长时间运行的脚本超过最大执行时间时
#SCRIPT KILL和SHUTDOWN NOSAVE命令可用。第一个可以
#用于停止尚未调用write命令的脚本。第二
在写入命令的情况下,#是关闭服务器的唯一方法
#已经由脚本发布但用户不想等待自然
#终止脚本。
#
#将其设置为0或负值,以便在没有警告的情况下无限制地执行。
lua-time-limit 5000

################################ REDIS CLUSTER ################ ###############

#Normal Redis实例不能是Redis群集的一部分; 只有节点
#作为集群节点启动即可。为了启动Redis实例
#cluster node启用集群支持,取消注释以下内容:
#
#etanet-enabled yes

#每个群集节点都有一个群集配置文件。这个文件不是
#打算手工编辑。它由Redis节点创建和更新。
#每个Redis群集节点都需要不同的群集配置文件。
#确保在同一系统中运行的实例没有
#重叠群集配置文件名。
#
#cluster-config-file nodes-6379.conf

#集群节点超时是节点必须无法访问的毫秒数
#因为它被认为是失败状态。
#大多数其他内部时间限制是节点超时的倍数。
#
#cluster-node-timeout 15000

#失败主服务器的副本将避免在其数据时启动故障转移
#看起来太旧了。
#
#副本实际上没有简单的方法可以精确测量
#其“数据时代”,因此执行以下两项检查:
#
#1)如果有多个副本能够进行故障转移,则它们会交换消息
#为了试图给最好的副本带来优势
#re replication offset(处理主数据的更多数据)。
#Replicas将尝试通过偏移获得他们的排名,并应用于开始
故障转移的#与其排名成比例的延迟。
#
#2)每个副本计算最后一次交互的时间
#the master。这可以是收到的最后一个ping或命令(如果是主服务器
#仍处于“已连接”状态),或者自...以来经过的时间
#与master断开连接(如果复制链接当前已关闭)。
#如果上次交互太旧,副本将不会尝试进行故障转移
#tt all。
#
#点“2”可以由用户调整。特别是副本不会执行
#the failover if,自上次与master的交互,时间
#逝去大于:
#
#(node-timeout * replica-validity-factor)+ repl-ping-replica-period
#
#例如,如果node-timeout为30秒,则为replica-validity-factor
#是10,假设默认的repl-ping-replica-period为10秒,那么
如果无法与主服务器通信,#replica将不会尝试进行故障转移
#超过310秒。
#
#大型副本 - 有效性因子可能允许具有过旧数据的副本进行故障转移
#a master,而值太小可能会阻止群集
#根本就选一个复制品。
#
#为了获得最大可用性,可以设置副本有效性因子
#的值为0,这意味着,副本将始终尝试进行故障转移
#master无论他们最后一次与主人交流。
#(但是他们总是试图应用与他们成比例的延迟
#offset rank。
#
#Zero是唯一能够保证所有分区愈合的值
#群集将始终能够继续。
#
#cluster-replica-validity-factor 10

#集群副本能够迁移到孤立主服务器,即主服务器
#没有工作副本。这提高了集群能力
#抵制失败,否则孤儿大师无法进行故障转移
#如果没有工作副本,则失败。
#
#只有在至少仍存在a的情况下,Replicas才会迁移到孤立的主服务器
#给他们的老主人的其他工作副本的数量。这个号码
#是“迁移障碍”。迁移障碍为1表示副本
#仅在其主服务器至少有一个其他工作副本时才会迁移
#等等。它通常反映了您想要的每个副本的数量
您的群集中的#master。
#
#默认值为1(仅当主人至少保留时,才会迁移副本
#一个副本)。要禁用迁移,只需将其设置为非常大的值。
#可以设置值0,但仅用于调试和危险
#在生产中。
#
#cluster-migration-barrier 1

#默认情况下,Redis Cluster节点在检测到时会停止接受查询
#至少是一个未覆盖的哈希槽(没有可用的节点正在服务它)。
#这样,如果群集部分关闭(例如一系列哈希槽)
#不再被覆盖)所有群集最终都变得不可用。
#一旦所有插槽再次被覆盖,它就会自动返回。
#
#但有时你想要集群的子集正在工作,
#继续接受对仍然存在的密钥空间部分的查询
#cover。为此,只需设置cluster-require-full-coverage
#no选项。
#
#cluster-require-full-coverage yes

#此选项设置为yes时,会阻止副本尝试对其进行故障转移
#master在主故障期间​​。然而,主人仍然可以执行
#手动故障转移,如果强制这样做。
#
#这在不同的场景中很有用,特别是在多个情况下
#数据中心运营,如果没有,我们希望一方永远不会被提升
#在总DC故障的情况下。
#
#cluster-replica-no-failover no

#要设置群集,请务必阅读文档
#可在http://redis.io网站上找到。

DERSER / NAT支持################## #####

#在某些部署中,Redis Cluster节点地址发现失败,因为
#地址是NAT-ted或因为端口被转发(典型情况是
#Docker和其他容器)。
#
#为了使Redis Cluster在这样的环境中工作,静态
#configuration,其中每个节点都需要知道其公共地址。该
#以下两个选项用于此范围,并且是:
#
#* cluster-announce-ip
#* cluster-announce-port
#* cluster-announce-bus-port
#
#每个都指示节点有关其地址,客户端端口和群集消息的信息
#bus port。然后将信息发布在总线包的标题中
#以便其他节点能够正确映射节点的地址
#发布信息。
#
#如果未使用上述选项,则正常的Redis群集自动检测
#将被替代使用。
#
#注意,重新映射时,总线端口可能不在固定偏移量处
#clients port + 10000,因此您可以指定任何端口和总线端口
#关于如何重新映射。如果未设置总线端口,则固定偏移量为
通常会使用#10000。
#
#示例:
#
#cluster-announce-ip 10.1.1.5
#cluster-announce-port 6379
#cluster-announce-bus-port 6380

##################################慢日志############## #####################

#Redis Slow Log是一个记录超过指定查询的系统
# 执行时间处理时间。执行时间不包括I / O操作
#喜欢与客户交谈,发送回复等等,
#但只是实际执行命令所需的时间(这是唯一的
#命令执行阶段,其中线程被阻止且无法提供服务
#在此期间的其他请求)。
#
#您可以使用两个参数配置慢速日志:一个告诉Redis
#执行时间是多少,以微秒为单位,以便超过
#command得到记录,另一个参数是长度
#慢日志。记录新命令时,将从中删除最旧的命令
#已记录命令的队列。

#以下时间以微秒表示,因此1000000是等效的
#到一秒钟。请注意,负数会禁用慢速日志,而
#a值为零会强制记录每个命令。
slowlog-log-slow-than 10000

#这个长度没有限制。请注意它会消耗内存。
#您可以使用SLOWLOG RESET回收慢速日志使用的内存。
slowlog-max-len 128

################################ LATENCY MONITOR ################ ##############

#Redis延迟监控子系统对不同的操作进行采样
#在运行时为了收集与可能来源相关的数据
#Redis实例的延迟。
#
#通过LATENCY命令,该信息可供用户使用
#打印图表并获取报告。
#
#系统仅记录在等于或等于的时间内执行的操作
#大于通过指定的毫秒数
#latency-monitor-threshold配置指令。设置其值时
#到零,延迟监视器关闭。
#
#默认情况下,延迟监视被禁用,因为它几乎不需要
#如果没有延迟问题,并且收集数据有性能
#impact,即虽然很小,但可以在大负载下测量。潜伏
使用该命令可以在运行时轻松启用#monitoring
#“CONFIG SET latency-monitor-threshold <milliseconds>”如果需要。
latency-monitor-threshold 0

############################# EVENT NOTIFICATION ################### ###########

#Redis可以向Pub / Sub客户端通知密钥空间中发生的事件。
#此功能记录在http://redis.io/topics/notifications中
#
#例如,如果启用了密钥空间事件通知,则为客户端
#对存储在数据库0中的密钥“foo”执行DEL操作,两个
#messages将通过Pub / Sub发布:
#
#PUBLISH __keyspace @ 0 __:foo del
#PUBLISH __keyevent @ 0 __:del foo
#
#可以选择Redis将在集合中通知的事件
班级数量。每个类都由一个字符标识:
#
#K Keyspace事件,以__keyspace @ <db> __前缀发布。
#E Keyevent事件,使用__keyevent @ <db> __前缀发布。
#g通用命令(非特定类型),如DEL,EXPIRE,RENAME,......
#$ String命令
#l列出命令
#s设置命令
#h哈希命令
#z排序集命令
#x过期事件(每次密钥到期时生成的事件)
#e Evicted events(当一个密钥被驱逐出maxmemory时生成的事件)
#g $ lshzxe的别名,因此“AKE”字符串表示所有事件。
#
#“notify-keyspace-events”将组成的字符串作为参数
零个或多个字符的数量。空字符串表示通知
#被禁用。
#
#示例:从启用列表和通用事件的角度来看
#event name,use:
#
#notify-keyspace-events Elg
#
#示例2:获取订阅频道的过期密钥流
#name __keyevent @ 0 __:过期使用:
#
#notify-keyspace-events例如
#
#默认情况下,所有通知都被禁用,因为大多数用户不需要
#此功能和该功能有一些开销。请注意,如果你不这样做
#指定K或E中的至少一个,不会传递任何事件。
notify-keyspace-events“”

高级配置############## ##############

#Hehes使用内存高效的数据结构进行编码
#少数条目,最大条目不超过给定
#threshold。可以使用以下指令配置这些阈值。
hash-max-ziplist-entries 512
hash-max-ziplist-value 64

#Lists也以特殊方式编码以节省大量空间。
#可以指定每个内部列表节点允许的条目数
#作为固定的最大大小或最大元素数。
#对于固定的最大大小,请使用-5到-1,表示:
#-5:最大大小:64 Kb < - 不建议用于正常工作负载
#-4:最大尺寸:32 Kb < - 不推荐
#-3:最大尺寸:16 Kb < - 可能不推荐
#-2:最大尺寸:8 Kb < - 良好
#-1:最大尺寸:4 Kb < - 良好
#正数意味着存储_exactly_那个元素的数量
#每个列表节点。
#性能最高的选项通常为-2(8 Kb大小)或-1(4 Kb大小),
#但如果您的用例是唯一的,请根据需要调整设置。
list-max-ziplist-size -2

#Lists也可以压缩。
#Compress depth是来自* * *的快速列表ziplist节点的数量
#要从压缩中排除*的列表。列表的头部和尾部
对于快速推送/弹出操作,#总是未压缩。设置是:
#0:禁用所有列表压缩
#1:深度1表示“直到1个节点进入列表后才开始压缩,
#从头部或尾部走“
#所以:[head]  - > node-> node  - > ...-> node  - > [tail]
#[head],[tail]将始终未压缩; 内部节点将压缩。
#2:[head]  - > [next]  - > node-> node  - > ...-> node  - > [prev]  - > [tail]
#2在这里意味着:不要压缩头部或头部 - >下一个或尾部 - >上一个或尾部,
#但压缩它们之间的所有节点。
#3:[head]  - > [next]  - > [next]  - > node-> node  - > ...-> node  - > [prev]  - > [prev]  - > [tail]
#等
list-compress-depth 0

#集合在一种情况下具有特殊编码:组成集合时
恰好在该范围内的基数为10的整数字符串
64位有符号整数的#。
#以下配置设置设置了大小的限制
#set以便使用这种特殊的内存保存编码。
set-max-intset-entries 512

#与散列和列表类似,排序集也是特殊编码的
#命令以节省大量空间。此编码仅在长度和时使用
排序集的#个元素低于以下限制:
zset-max-ziplist-entries 128
zset-max-ziplist-value 64

#HyperLogLog稀疏表示字节限制。限制包括
#16字节标头。当使用稀疏表示的HyperLogLog交叉时
#the limit,将其转换为密集表示。
#
#大于16000的值完全没用,因为那时候
#密集表示更节省内存。
#
#建议值为~3000,以获得好处
#空间高效编码而不会减慢过多的PFADD,
#是稀疏编码的O(N)。该值可以提升为
当CPU不是问题时,#~10000,但空间是,数据集是
#由许多HyperLogLog组成,基数为0  -  15000。
hll-sparse-max-bytes 3000

#Streams宏节点最大大小/项目。流数据结构是基数
#sree大型节点,用于编码内部的多个项目。使用此配置
#可以配置单个节点的字节数,以及
#切换到新节点之前可能包含的最大项目数
#追加新的流条目。如果以下任何设置设置为
#zero,忽略限制,所以例如可以设置一个
#max entires limit将max-bytes设置为0,将max-entries设置为所需的
#value。
stream-node-max-bytes 4096
stream-node-max-entries 100

#Active rehashing每100毫秒的CPU时间使用1毫秒
#order帮助重新散列主Redis哈希表(一个映射顶层
#键到值)。Redis使用的哈希表实现(参见dict.c)
#执行一个懒惰的rehashing:你在哈希表中运行的操作越多
正在重复的#,执行的重复“步骤”越多,所以如果
#server处于空闲状态,rehashing永远不会完成,并且会使用更多内存
#由哈希表。
#
#默认是每秒使用这个毫秒10次
#主动重写主要词典,尽可能释放内存。
#
#如果不确定:
#如果您有严格的延迟要求,请使用“activerehashing no”
#Renis可以不时回复您的环境中的好事
#对延迟2毫秒的查询。
#
#如果你没有这样的硬性要求,请使用“activerehashing yes”
#尽可能尽快释放内存。
activerehashing是的

#客户端输出缓冲区限制可用于强制断开客户端
#由于某种原因,没有足够快地从服务器读取数据(#
#常见的原因是Pub / Sub客户端不能像消息一样快地消费消息
#publisher可以生成它们。
#
#可以为三种不同类型的客户端设置不同的限制:
#
#normal  - >普通客户端,包括MONITOR客户端
#replica  - >副本客户端
#pubsub  - >客户端订阅了至少一个pubsub通道或模式
#
#每个client-output-buffer-limit指令的语法如下:
#
#client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
#
#达到硬限制后,客户端立即断开连接,或者如果
#达到软限制并保持达到指定的数量
#秒(连续)。
#例如,如果硬限制为32兆字节且软限制为
#16兆字节/ 10秒,客户端将立即断开连接
#如果输出缓冲区的大小达到32兆字节,但也会得到
#如果客户端达到16兆字节并且不断克服,则会断开连接
#10秒的限制。
#
#默认情况下,普通客户端不受限制,因为它们不接收数据
#没有询问(以推送方式),但只是在请求之后,所以只有
#synchronous clients可能会创建一个更快地请求数据的场景
#比它可以阅读。
#
#而不是pubsub和副本客户端的默认限制,因为
#subler和replicas以推送方式接收数据。
#
#可以通过将硬限制设置为零来禁用硬限制或软限制。
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

#客户端查询缓冲区累积新命令。它们仅限于固定的
默认情况下,#amount以避免协议失步(for
#instance由于客户端中的错误而导致未绑定的内存使用量
#查询缓冲区。但是,如果您有特殊要求,可以在此处进行配置
#需要,比如我们巨大的多/执行请求或类似的。
#
#client-query-buffer-limit 1gb

#在Redis协议中,批量请求,即表示单个的元素
#strings,通常限制为512 MB。但是,您可以更改此限制
# 这里。
#
#proto-max-bulk-len 512mb

#Redis调用内部函数来执行许多后台任务,比如
#在超时时关闭客户端的连接,清除过期的密钥
#从未请求,等等。
#
#并非所有任务都以相同的频率执行,但Redis会检查
#根据指定的“hz”值执行的任务。
#
#默认情况下,“hz”设置为10.提高值时将使用更多的CPU
#Redis是空闲的,但同时会使Redis更具响应性
#有很多键同时到期,超时可能会到期
#处理更精确。
#
#范围在1到500之间,但是超过100的值通常不是
# 一个好主意。大多数用户应该使用默认值10并将其提高到
#100仅适用于需要极低延迟的环境。
hz 10

#通常,HZ值与其成比例是有用的
#连接的客户端数量。例如,这对于顺序非常有用
#避免为每个后台任务调用处理太多客户端
#以避免延迟峰值。
#
#由于默认情况下默认的HZ值保守地设置为10,Redis
#offers,默认情况下启用使用自适应HZ值的功能
#当有许多连接的客户端时,它将临时引发。
#
#启用动态HZ时,实际配置的HZ将用作
#作为基线,但实际上是配置的HZ值的倍数
#再次连接客户端时根据需要使用。就这样闲着
#emplent实例将占用很少的CPU时间
#反应更快。
dynamic-hz是的

#当孩子重写AOF文件时,如果启用了以下选项
#生成的每32 MB数据将对文件进行fsync。这很有用
#以便以递增方式将文件提交到磁盘并避免
#大延迟峰值。
aof-rewrite-incremental-fsync是的

#当redis保存RDB文件时,如果启用了以下选项
#生成的每32 MB数据将对文件进行fsync。这很有用
#以便以递增方式将文件提交到磁盘并避免
#大延迟峰值。
rdb-save-incremental-fsync是的

#Redis LFU驱逐(参见maxmemory设置)可以调整。不过这很好
#idea以默认设置开始,仅在调查后更改它们
#如何提高性能以及按键LFU随时间的变化情况如何
#可以通过OBJECT FREQ命令进行检查。
#
#Redis LFU实现中有两个可调参数:
#counter对数因子和计数器衰减时间。重要的是要
#在更改之前了解这两个参数的含义。
#
#LFU计数器每个键只有8位,它的最大值是255,所以Redis
#使用具有对数行为的概率增量。鉴于价值
旧计数器的#,当访问密钥时,计数器递增
# 这条路:
#
#1提取0到1之间的随机数R.
#2。概率P计算为1 /(old_value * lfu_log_factor + 1)。
#3。仅当R <P时,计数器才会递增。
#
#默认的lfu-log-factor是10.这是一个如何表的频率
#counter使用不同的访问次数进行更改
#logarithmic因素:
#
#+ -------- + ------------ + ------------ + ------------ + ------------ + ------------ +
#| 因素| 100次点击| 1000次点击| 100K命中| 1M次点击| 10M点击|
#+ -------- + ------------ + ------------ + ------------ + ------------ + ------------ +
#| 0 | 104 | 255 | 255 | 255 | 255 |
#+ -------- + ------------ + ------------ + ------------ + ------------ + ------------ +
#| 1 | 18 | 49 | 255 | 255 | 255 |
#+ -------- + ------------ + ------------ + ------------ + ------------ + ------------ +
#| 10 | 10 | 18 | 142 | 255 | 255 |
#+ -------- + ------------ + ------------ + ------------ + ------------ + ------------ +
#| 100 | 8 | 11 | 49 | 143 | 255 |
#+ -------- + ------------ + ------------ + ------------ + ------------ + ------------ +
#
#注意:上表是通过运行以下命令获得的:
#
#redis-benchmark-1000000 incr foo
#redis-cli object freq foo
#
#NOTE 2:计数器初始值为5,以便为新对象提供机会
#累积命中率。
#
#计数器衰减时间是必须按顺序经过的时间(以分钟为单位)
#用于将密钥计数器除以2(如果有值则递减)
#less <= 10)。
#
#lfu-decay-time的默认值为1.特殊值0表示
#每次碰巧扫描时都会对计数器进行衰减。
#
#lfu-log-factor 10
#lfu-decay-time 1

活动拆解##################### ##
#
#警告这个功能是实验性的。然而,它是压力测试
#甚至在生产中,由多个工程师手动测试一些
# 时间。
#
#什么是主动碎片整理?
#-------------------------------
#
#Active(在线)碎片整理允许Redis服务器压缩
#在内存中的小分配和数据释放之间留下空格,
#因此允许回收内存。
#
#Fragmentation是每个分配器都会发生的自然过程(但是
#幸运的是,对于Jemalloc来说,#更少,以及某些工作负载。通常是服务器
需要#reboot以降低碎片,或者至少要刷新
#away所有数据并再次创建。但是由于这个功能
#由Oran Agra为Redis 4.0实现,此过程可以在运行时进行
#以“热”方式,在服务器运行时。
#
#基本上当碎片超过一定水平时(参见
下面的#配置选项)Redis将开始创建新的副本
#利用某些特定的Jemalloc在连续的内存区域中进行值
#features(以了解分配是否导致碎片)
#并在更好的地方分配它,同时,将释放
#旧数据副本。此过程以递增方式重复所有键
#将导致碎片回落到正常值。
#
#需要了解的重要事项:
#
#1。默认情况下禁用此功能,仅在编译Redis时有效
#使用我们随Redis源代码一起提供的Jemalloc副本。
#这是Linux版本的默认设置。
#
#2。如果没有碎片,则永远不需要启用此功能
#问题。
#
#3。一旦遇到碎片,您可以在何时启用此功能
#需要命令“CONFIG SET activedefrag yes”。
#
#配置参数能够微调其行为
#defragmentation进程。如果你不确定它们是什么意思的话
#一个好主意,保持默认不变。

#启用主动碎片整理
#activedefrag是的

#启动活动碎片整理的最小碎片浪费量
#active-defrag-ignore-bytes 100mb

#启动活动碎片整理的最小碎片百分比
#active-defrag-threshold-lower 10

#我们使用最大努力的最大碎片百分比
#active-defrag-threshold-upper 100

#CPU百分比中碎片整理的最小努力
#active-defrag-cycle-min 5

#CPU百分比中碎片整理的最大努力量
#active-defrag-cycle-max 75

#将从中处理的set / hash / zset / list字段的最大数量
#主词典扫描
#active-defrag-max-scan-fields 1000

原文

# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
#
# ./redis-server /path/to/redis.conf

# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.

################################## INCLUDES ###################################

# Include one or more other config files here.  This is useful if you
# have a standard template that goes to all Redis servers but also need
# to customize a few per-server settings.  Include files can include
# other files, so use this wisely.
#
# Notice option "include" won't be rewritten by command "CONFIG REWRITE"
# from admin or Redis Sentinel. Since Redis always uses the last processed
# line as value of a configuration directive, you'd better put includes
# at the beginning of this file to avoid overwriting config change at runtime.
#
# If instead you are interested in using includes to override configuration
# options, it is better to use include as the last line.
#
# include /path/to/local.conf
# include /path/to/other.conf

################################## MODULES #####################################

# Load modules at startup. If the server is not able to load modules
# it will abort. It is possible to use multiple loadmodule directives.
#
# loadmodule /path/to/my_module.so
# loadmodule /path/to/other_module.so

################################## NETWORK #####################################

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 loopback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 2) No password is configured.
#
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
# sockets.
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode yes

# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379

# TCP listen() backlog.
#
# In high requests-per-second environments you need an high backlog in order
# to avoid slow clients connections issues. Note that the Linux kernel
# will silently truncate it to the value of /proc/sys/net/core/somaxconn so
# make sure to raise both the value of somaxconn and tcp_max_syn_backlog
# in order to get the desired effect.
tcp-backlog 511

# Unix socket.
#
# Specify the path for the Unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified.
#
# unixsocket /tmp/redis.sock
# unixsocketperm 700

# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0

# TCP keepalive.
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
#
# 1) Detect dead peers.
# 2) Take the connection alive from the point of view of network
#    equipment in the middle.
#
# On Linux, the specified value (in seconds) is the period used to send ACKs.
# Note that to close the connection the double of the time is needed.
# On other kernels the period depends on the kernel configuration.
#
# A reasonable value for this option is 300 seconds, which is the new
# Redis default starting with Redis 3.2.1.
tcp-keepalive 300

################################# GENERAL #####################################

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no

# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
#   supervised no      - no supervision interaction
#   supervised upstart - signal upstart by putting Redis into SIGSTOP mode
#   supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
#   supervised auto    - detect upstart or systemd method based on
#                        UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal "process is ready."
#       They do not enable continuous liveness pings back to your supervisor.
supervised no

# If a pid file is specified, Redis writes it where specified at startup
# and removes it at exit.
#
# When the server runs non daemonized, no pid file is created if none is
# specified in the configuration. When the server is daemonized, the pid file
# is used even if not specified, defaulting to "/var/run/redis.pid".
#
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
pidfile /var/run/redis_6379.pid

# Specify the server verbosity level.
# This can be one of:
# debug (a lot of information, useful for development/testing)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel notice

# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile ""

# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# syslog-enabled no

# Specify the syslog identity.
# syslog-ident redis

# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# syslog-facility local0

# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
databases 16

# By default Redis shows an ASCII art logo only when started to log to the
# standard output and if the standard output is a TTY. Basically this means
# that normally a logo is displayed only in interactive sessions.
#
# However it is possible to force the pre-4.0 behavior and always show a
# ASCII art logo in startup logs by setting the following option to yes.
always-show-logo yes

################################ SNAPSHOTTING  ################################
#
# Save the DB on disk:
#
#   save <seconds> <changes>
#
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#
#   In the example below the behaviour will be to save:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
#
#   Note: you can disable saving completely by commenting out all "save" lines.
#
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
#
#   save ""

save 900 1
save 300 10
save 60 10000

# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
#
# If the background saving process will start working again Redis will
# automatically allow writes again.
#
# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
stop-writes-on-bgsave-error yes

# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
rdbcompression yes

# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
# This makes the format more resistant to corruption but there is a performance
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
# for maximum performances.
#
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
rdbchecksum yes

# The filename where to dump the DB
dbfilename dump.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.
dir ./

################################# REPLICATION #################################

# Master-Replica replication. Use replicaof to make a Redis instance a copy of
# another Redis server. A few things to understand ASAP about Redis replication.
#
#   +------------------+      +---------------+
#   |      Master      | ---> |    Replica    |
#   | (receive writes) |      |  (exact copy) |
#   +------------------+      +---------------+
#
# 1) Redis replication is asynchronous, but you can configure a master to
#    stop accepting writes if it appears to be not connected with at least
#    a given number of replicas.
# 2) Redis replicas are able to perform a partial resynchronization with the
#    master if the replication link is lost for a relatively small amount of
#    time. You may want to configure the replication backlog size (see the next
#    sections of this file) with a sensible value depending on your needs.
# 3) Replication is automatic and does not need user intervention. After a
#    network partition replicas automatically try to reconnect to masters
#    and resynchronize with them.
#
# replicaof <masterip> <masterport>

# If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the replica to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the replica request.
#
# masterauth <master-password>

# When a replica loses its connection with the master, or when the replication
# is still in progress, the replica can act in two different ways:
#
# 1) if replica-serve-stale-data is set to 'yes' (the default) the replica will
#    still reply to client requests, possibly with out of date data, or the
#    data set may just be empty if this is the first synchronization.
#
# 2) if replica-serve-stale-data is set to 'no' the replica will reply with
#    an error "SYNC with master in progress" to all the kind of commands
#    but to INFO, replicaOF, AUTH, PING, SHUTDOWN, REPLCONF, ROLE, CONFIG,
#    SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB,
#    COMMAND, POST, HOST: and LATENCY.
#
replica-serve-stale-data yes

# You can configure a replica instance to accept writes or not. Writing against
# a replica instance may be useful to store some ephemeral data (because data
# written on a replica will be easily deleted after resync with the master) but
# may also cause problems if clients are writing to it because of a
# misconfiguration.
#
# Since Redis 2.6 by default replicas are read-only.
#
# Note: read only replicas are not designed to be exposed to untrusted clients
# on the internet. It's just a protection layer against misuse of the instance.
# Still a read only replica exports by default all the administrative commands
# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve
# security of read only replicas using 'rename-command' to shadow all the
# administrative / dangerous commands.
replica-read-only yes

# Replication SYNC strategy: disk or socket.
#
# -------------------------------------------------------
# WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY
# -------------------------------------------------------
#
# New replicas and reconnecting replicas that are not able to continue the replication
# process just receiving differences, need to do what is called a "full
# synchronization". An RDB file is transmitted from the master to the replicas.
# The transmission can happen in two different ways:
#
# 1) Disk-backed: The Redis master creates a new process that writes the RDB
#                 file on disk. Later the file is transferred by the parent
#                 process to the replicas incrementally.
# 2) Diskless: The Redis master creates a new process that directly writes the
#              RDB file to replica sockets, without touching the disk at all.
#
# With disk-backed replication, while the RDB file is generated, more replicas
# can be queued and served with the RDB file as soon as the current child producing
# the RDB file finishes its work. With diskless replication instead once
# the transfer starts, new replicas arriving will be queued and a new transfer
# will start when the current one terminates.
#
# When diskless replication is used, the master waits a configurable amount of
# time (in seconds) before starting the transfer in the hope that multiple replicas
# will arrive and the transfer can be parallelized.
#
# With slow disks and fast (large bandwidth) networks, diskless replication
# works better.
repl-diskless-sync no

# When diskless replication is enabled, it is possible to configure the delay
# the server waits in order to spawn the child that transfers the RDB via socket
# to the replicas.
#
# This is important since once the transfer starts, it is not possible to serve
# new replicas arriving, that will be queued for the next RDB transfer, so the server
# waits a delay in order to let more replicas arrive.
#
# The delay is specified in seconds, and by default is 5 seconds. To disable
# it entirely just set it to 0 seconds and the transfer will start ASAP.
repl-diskless-sync-delay 5

# Replicas send PINGs to server in a predefined interval. It's possible to change
# this interval with the repl_ping_replica_period option. The default value is 10
# seconds.
#
# repl-ping-replica-period 10

# The following option sets the replication timeout for:
#
# 1) Bulk transfer I/O during SYNC, from the point of view of replica.
# 2) Master timeout from the point of view of replicas (data, pings).
# 3) Replica timeout from the point of view of masters (REPLCONF ACK pings).
#
# It is important to make sure that this value is greater than the value
# specified for repl-ping-replica-period otherwise a timeout will be detected
# every time there is low traffic between the master and the replica.
#
# repl-timeout 60

# Disable TCP_NODELAY on the replica socket after SYNC?
#
# If you select "yes" Redis will use a smaller number of TCP packets and
# less bandwidth to send data to replicas. But this can add a delay for
# the data to appear on the replica side, up to 40 milliseconds with
# Linux kernels using a default configuration.
#
# If you select "no" the delay for data to appear on the replica side will
# be reduced but more bandwidth will be used for replication.
#
# By default we optimize for low latency, but in very high traffic conditions
# or when the master and replicas are many hops away, turning this to "yes" may
# be a good idea.
repl-disable-tcp-nodelay no

# Set the replication backlog size. The backlog is a buffer that accumulates
# replica data when replicas are disconnected for some time, so that when a replica
# wants to reconnect again, often a full resync is not needed, but a partial
# resync is enough, just passing the portion of data the replica missed while
# disconnected.
#
# The bigger the replication backlog, the longer the time the replica can be
# disconnected and later be able to perform a partial resynchronization.
#
# The backlog is only allocated once there is at least a replica connected.
#
# repl-backlog-size 1mb

# After a master has no longer connected replicas for some time, the backlog
# will be freed. The following option configures the amount of seconds that
# need to elapse, starting from the time the last replica disconnected, for
# the backlog buffer to be freed.
#
# Note that replicas never free the backlog for timeout, since they may be
# promoted to masters later, and should be able to correctly "partially
# resynchronize" with the replicas: hence they should always accumulate backlog.
#
# A value of 0 means to never release the backlog.
#
# repl-backlog-ttl 3600

# The replica priority is an integer number published by Redis in the INFO output.
# It is used by Redis Sentinel in order to select a replica to promote into a
# master if the master is no longer working correctly.
#
# A replica with a low priority number is considered better for promotion, so
# for instance if there are three replicas with priority 10, 100, 25 Sentinel will
# pick the one with priority 10, that is the lowest.
#
# However a special priority of 0 marks the replica as not able to perform the
# role of master, so a replica with priority of 0 will never be selected by
# Redis Sentinel for promotion.
#
# By default the priority is 100.
replica-priority 100

# It is possible for a master to stop accepting writes if there are less than
# N replicas connected, having a lag less or equal than M seconds.
#
# The N replicas need to be in "online" state.
#
# The lag in seconds, that must be <= the specified value, is calculated from
# the last ping received from the replica, that is usually sent every second.
#
# This option does not GUARANTEE that N replicas will accept the write, but
# will limit the window of exposure for lost writes in case not enough replicas
# are available, to the specified number of seconds.
#
# For example to require at least 3 replicas with a lag <= 10 seconds use:
#
# min-replicas-to-write 3
# min-replicas-max-lag 10
#
# Setting one or the other to 0 disables the feature.
#
# By default min-replicas-to-write is set to 0 (feature disabled) and
# min-replicas-max-lag is set to 10.

# A Redis master is able to list the address and port of the attached
# replicas in different ways. For example the "INFO replication" section
# offers this information, which is used, among other tools, by
# Redis Sentinel in order to discover replica instances.
# Another place where this info is available is in the output of the
# "ROLE" command of a master.
#
# The listed IP and address normally reported by a replica is obtained
# in the following way:
#
#   IP: The address is auto detected by checking the peer address
#   of the socket used by the replica to connect with the master.
#
#   Port: The port is communicated by the replica during the replication
#   handshake, and is normally the port that the replica is using to
#   listen for connections.
#
# However when port forwarding or Network Address Translation (NAT) is
# used, the replica may be actually reachable via different IP and port
# pairs. The following two options can be used by a replica in order to
# report to its master a specific set of IP and port, so that both INFO
# and ROLE will report those values.
#
# There is no need to use both the options if you need to override just
# the port or the IP address.
#
# replica-announce-ip 5.5.5.5
# replica-announce-port 1234

################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared

# Command renaming.
#
# It is possible to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# hard to guess so that it will still be available for internal-use tools
# but not available for general clients.
#
# Example:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# It is also possible to completely kill a command by renaming it into
# an empty string:
#
# rename-command CONFIG ""
#
# Please note that changing the name of commands that are logged into the
# AOF file or transmitted to replicas may cause problems.

################################### CLIENTS ####################################

# Set the max number of connected clients at the same time. By default
# this limit is set to 10000 clients, however if the Redis server is not
# able to configure the process file limit to allow for the specified limit
# the max number of allowed clients is set to the current file limit
# minus 32 (as Redis reserves a few file descriptors for internal uses).
#
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
#
# maxclients 10000

############################## MEMORY MANAGEMENT ################################

# Set a memory usage limit to the specified amount of bytes.
# When the memory limit is reached Redis will try to remove keys
# according to the eviction policy selected (see maxmemory-policy).
#
# If Redis can't remove keys according to the policy, or if the policy is
# set to 'noeviction', Redis will start to reply with errors to commands
# that would use more memory, like SET, LPUSH, and so on, and will continue
# to reply to read-only commands like GET.
#
# This option is usually useful when using Redis as an LRU or LFU cache, or to
# set a hard memory limit for an instance (using the 'noeviction' policy).
#
# WARNING: If you have replicas attached to an instance with maxmemory on,
# the size of the output buffers needed to feed the replicas are subtracted
# from the used memory count, so that network problems / resyncs will
# not trigger a loop where keys are evicted, and in turn the output
# buffer of replicas is full with DELs of keys evicted triggering the deletion
# of more keys, and so forth until the database is completely emptied.
#
# In short... if you have replicas attached it is suggested that you set a lower
# limit for maxmemory so that there is some free RAM on the system for replica
# output buffers (but this is not needed if the policy is 'noeviction').
#
# maxmemory <bytes>

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
#
# volatile-lru -> Evict using approximated LRU among the keys with an expire set.
# allkeys-lru -> Evict any key using approximated LRU.
# volatile-lfu -> Evict using approximated LFU among the keys with an expire set.
# allkeys-lfu -> Evict any key using approximated LFU.
# volatile-random -> Remove a random key among the ones with an expire set.
# allkeys-random -> Remove a random key, any key.
# volatile-ttl -> Remove the key with the nearest expire time (minor TTL)
# noeviction -> Don't evict anything, just return an error on write operations.
#
# LRU means Least Recently Used
# LFU means Least Frequently Used
#
# Both LRU, LFU and volatile-ttl are implemented using approximated
# randomized algorithms.
#
# Note: with any of the above policies, Redis will return an error on write
#       operations, when there are no suitable keys for eviction.
#
#       At the date of writing these commands are: set setnx setex append
#       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
#       sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
#       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
#       getset mset msetnx exec sort
#
# The default is:
#
# maxmemory-policy noeviction

# LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated
# algorithms (in order to save memory), so you can tune it for speed or
# accuracy. For default Redis will check five keys and pick the one that was
# used less recently, you can change the sample size using the following
# configuration directive.
#
# The default of 5 produces good enough results. 10 Approximates very closely
# true LRU but costs more CPU. 3 is faster but not very accurate.
#
# maxmemory-samples 5

# Starting from Redis 5, by default a replica will ignore its maxmemory setting
# (unless it is promoted to master after a failover or manually). It means
# that the eviction of keys will be just handled by the master, sending the
# DEL commands to the replica as keys evict in the master side.
#
# This behavior ensures that masters and replicas stay consistent, and is usually
# what you want, however if your replica is writable, or you want the replica to have
# a different memory setting, and you are sure all the writes performed to the
# replica are idempotent, then you may change this default (but be sure to understand
# what you are doing).
#
# Note that since the replica by default does not evict, it may end using more
# memory than the one set via maxmemory (there are certain buffers that may
# be larger on the replica, or data structures may sometimes take more memory and so
# forth). So make sure you monitor your replicas and make sure they have enough
# memory to never hit a real out-of-memory condition before the master hits
# the configured maxmemory setting.
#
# replica-ignore-maxmemory yes

############################# LAZY FREEING ####################################

# Redis has two primitives to delete keys. One is called DEL and is a blocking
# deletion of the object. It means that the server stops processing new commands
# in order to reclaim all the memory associated with an object in a synchronous
# way. If the key deleted is associated with a small object, the time needed
# in order to execute the DEL command is very small and comparable to most other
# O(1) or O(log_N) commands in Redis. However if the key is associated with an
# aggregated value containing millions of elements, the server can block for
# a long time (even seconds) in order to complete the operation.
#
# For the above reasons Redis also offers non blocking deletion primitives
# such as UNLINK (non blocking DEL) and the ASYNC option of FLUSHALL and
# FLUSHDB commands, in order to reclaim memory in background. Those commands
# are executed in constant time. Another thread will incrementally free the
# object in the background as fast as possible.
#
# DEL, UNLINK and ASYNC option of FLUSHALL and FLUSHDB are user-controlled.
# It's up to the design of the application to understand when it is a good
# idea to use one or the other. However the Redis server sometimes has to
# delete keys or flush the whole database as a side effect of other operations.
# Specifically Redis deletes objects independently of a user call in the
# following scenarios:
#
# 1) On eviction, because of the maxmemory and maxmemory policy configurations,
#    in order to make room for new data, without going over the specified
#    memory limit.
# 2) Because of expire: when a key with an associated time to live (see the
#    EXPIRE command) must be deleted from memory.
# 3) Because of a side effect of a command that stores data on a key that may
#    already exist. For example the RENAME command may delete the old key
#    content when it is replaced with another one. Similarly SUNIONSTORE
#    or SORT with STORE option may delete existing keys. The SET command
#    itself removes any old content of the specified key in order to replace
#    it with the specified string.
# 4) During replication, when a replica performs a full resynchronization with
#    its master, the content of the whole database is removed in order to
#    load the RDB file just transferred.
#
# In all the above cases the default is to delete objects in a blocking way,
# like if DEL was called. However you can configure each case specifically
# in order to instead release memory in a non-blocking way like if UNLINK
# was called, using the following configuration directives:

lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no

############################## 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 no

# 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
appendfsync everysec
# appendfsync no

# When the AOF fsync policy is set to always or everysec, and a background
# saving process (a background save or AOF log background rewriting) is
# performing a lot of I/O against the disk, in some Linux configurations
# Redis may block too long on the fsync() call. Note that there is no fix for
# this currently, as even performing fsync in a different thread will block
# our synchronous write(2) call.
#
# In order to mitigate this problem it's possible to use the following option
# that will prevent fsync() from being called in the main process while a
# BGSAVE or BGREWRITEAOF is in progress.
#
# This means that while another child is saving, the durability of Redis is
# the same as "appendfsync none". In practical terms, this means that it is
# possible to lose up to 30 seconds of log in the worst scenario (with the
# default Linux settings).
#
# If you have latency problems turn this to "yes". Otherwise leave it as
# "no" that is the safest pick from the point of view of durability.

no-appendfsync-on-rewrite no

# Automatic rewrite of the append only file.
# Redis is able to automatically rewrite the log file implicitly calling
# BGREWRITEAOF when the AOF log size grows by the specified percentage.
#
# This is how it works: Redis remembers the size of the AOF file after the
# latest rewrite (if no rewrite has happened since the restart, the size of
# the AOF at startup is used).
#
# This base size is compared to the current size. If the current size is
# bigger than the specified percentage, the rewrite is triggered. Also
# you need to specify a minimal size for the AOF file to be rewritten, this
# is useful to avoid rewriting the AOF file even if the percentage increase
# is reached but it is still pretty small.
#
# Specify a percentage of zero in order to disable the automatic AOF
# rewrite feature.

auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

# An AOF file may be found to be truncated at the end during the Redis
# startup process, when the AOF data gets loaded back into memory.
# This may happen when the system where Redis is running
# crashes, especially when an ext4 filesystem is mounted without the
# data=ordered option (however this can't happen when Redis itself
# crashes or aborts but the operating system still works correctly).
#
# Redis can either exit with an error when this happens, or load as much
# data as possible (the default now) and start if the AOF file is found
# to be truncated at the end. The following option controls this behavior.
#
# If aof-load-truncated is set to yes, a truncated AOF file is loaded and
# the Redis server starts emitting a log to inform the user of the event.
# Otherwise if the option is set to no, the server aborts with an error
# and refuses to start. When the option is set to no, the user requires
# to fix the AOF file using the "redis-check-aof" utility before to restart
# the server.
#
# Note that if the AOF file will be found to be corrupted in the middle
# the server will still exit with an error. This option only applies when
# Redis will try to read more data from the AOF file but not enough bytes
# will be found.
aof-load-truncated yes

# When rewriting the AOF file, Redis is able to use an RDB preamble in the
# AOF file for faster rewrites and recoveries. When this option is turned
# on the rewritten AOF file is composed of two different stanzas:
#
#   [RDB file][AOF tail]
#
# When loading Redis recognizes that the AOF file starts with the "REDIS"
# string and loads the prefixed RDB file, and continues loading the AOF
# tail.
aof-use-rdb-preamble yes

################################ LUA SCRIPTING  ###############################

# Max execution time of a Lua script in milliseconds.
#
# If the maximum execution time is reached Redis will log that a script is
# still in execution after the maximum allowed time and will start to
# reply to queries with an error.
#
# When a long running script exceeds the maximum execution time only the
# SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be
# used to stop a script that did not yet called write commands. The second
# is the only way to shut down the server in the case a write command was
# already issued by the script but the user doesn't want to wait for the natural
# termination of the script.
#
# Set it to 0 or a negative value for unlimited execution without warnings.
lua-time-limit 5000

################################ REDIS CLUSTER  ###############################

# Normal Redis instances can't be part of a Redis Cluster; only nodes that are
# started as cluster nodes can. In order to start a Redis instance as a
# cluster node enable the cluster support uncommenting the following:
#
# cluster-enabled yes

# Every cluster node has a cluster configuration file. This file is not
# intended to be edited by hand. It is created and updated by Redis nodes.
# Every Redis Cluster node requires a different cluster configuration file.
# Make sure that instances running in the same system do not have
# overlapping cluster configuration file names.
#
# cluster-config-file nodes-6379.conf

# Cluster node timeout is the amount of milliseconds a node must be unreachable
# for it to be considered in failure state.
# Most other internal time limits are multiple of the node timeout.
#
# cluster-node-timeout 15000

# A replica of a failing master will avoid to start a failover if its data
# looks too old.
#
# There is no simple way for a replica to actually have an exact measure of
# its "data age", so the following two checks are performed:
#
# 1) If there are multiple replicas able to failover, they exchange messages
#    in order to try to give an advantage to the replica with the best
#    replication offset (more data from the master processed).
#    Replicas will try to get their rank by offset, and apply to the start
#    of the failover a delay proportional to their rank.
#
# 2) Every single replica computes the time of the last interaction with
#    its master. This can be the last ping or command received (if the master
#    is still in the "connected" state), or the time that elapsed since the
#    disconnection with the master (if the replication link is currently down).
#    If the last interaction is too old, the replica will not try to failover
#    at all.
#
# The point "2" can be tuned by user. Specifically a replica will not perform
# the failover if, since the last interaction with the master, the time
# elapsed is greater than:
#
#   (node-timeout * replica-validity-factor) + repl-ping-replica-period
#
# So for example if node-timeout is 30 seconds, and the replica-validity-factor
# is 10, and assuming a default repl-ping-replica-period of 10 seconds, the
# replica will not try to failover if it was not able to talk with the master
# for longer than 310 seconds.
#
# A large replica-validity-factor may allow replicas with too old data to failover
# a master, while a too small value may prevent the cluster from being able to
# elect a replica at all.
#
# For maximum availability, it is possible to set the replica-validity-factor
# to a value of 0, which means, that replicas will always try to failover the
# master regardless of the last time they interacted with the master.
# (However they'll always try to apply a delay proportional to their
# offset rank).
#
# Zero is the only value able to guarantee that when all the partitions heal
# the cluster will always be able to continue.
#
# cluster-replica-validity-factor 10

# Cluster replicas are able to migrate to orphaned masters, that are masters
# that are left without working replicas. This improves the cluster ability
# to resist to failures as otherwise an orphaned master can't be failed over
# in case of failure if it has no working replicas.
#
# Replicas migrate to orphaned masters only if there are still at least a
# given number of other working replicas for their old master. This number
# is the "migration barrier". A migration barrier of 1 means that a replica
# will migrate only if there is at least 1 other working replica for its master
# and so forth. It usually reflects the number of replicas you want for every
# master in your cluster.
#
# Default is 1 (replicas migrate only if their masters remain with at least
# one replica). To disable migration just set it to a very large value.
# A value of 0 can be set but is useful only for debugging and dangerous
# in production.
#
# cluster-migration-barrier 1

# By default Redis Cluster nodes stop accepting queries if they detect there
# is at least an hash slot uncovered (no available node is serving it).
# This way if the cluster is partially down (for example a range of hash slots
# are no longer covered) all the cluster becomes, eventually, unavailable.
# It automatically returns available as soon as all the slots are covered again.
#
# However sometimes you want the subset of the cluster which is working,
# to continue to accept queries for the part of the key space that is still
# covered. In order to do so, just set the cluster-require-full-coverage
# option to no.
#
# cluster-require-full-coverage yes

# This option, when set to yes, prevents replicas from trying to failover its
# master during master failures. However the master can still perform a
# manual failover, if forced to do so.
#
# This is useful in different scenarios, especially in the case of multiple
# data center operations, where we want one side to never be promoted if not
# in the case of a total DC failure.
#
# cluster-replica-no-failover no

# In order to setup your cluster make sure to read the documentation
# available at http://redis.io web site.

########################## CLUSTER DOCKER/NAT support  ########################

# In certain deployments, Redis Cluster nodes address discovery fails, because
# addresses are NAT-ted or because ports are forwarded (the typical case is
# Docker and other containers).
#
# In order to make Redis Cluster working in such environments, a static
# configuration where each node knows its public address is needed. The
# following two options are used for this scope, and are:
#
# * cluster-announce-ip
# * cluster-announce-port
# * cluster-announce-bus-port
#
# Each instruct the node about its address, client port, and cluster message
# bus port. The information is then published in the header of the bus packets
# so that other nodes will be able to correctly map the address of the node
# publishing the information.
#
# If the above options are not used, the normal Redis Cluster auto-detection
# will be used instead.
#
# Note that when remapped, the bus port may not be at the fixed offset of
# clients port + 10000, so you can specify any port and bus-port depending
# on how they get remapped. If the bus-port is not set, a fixed offset of
# 10000 will be used as usually.
#
# Example:
#
# cluster-announce-ip 10.1.1.5
# cluster-announce-port 6379
# cluster-announce-bus-port 6380

################################## SLOW LOG ###################################

# The Redis Slow Log is a system to log queries that exceeded a specified
# execution time. The execution time does not include the I/O operations
# like talking with the client, sending the reply and so forth,
# but just the time needed to actually execute the command (this is the only
# stage of command execution where the thread is blocked and can not serve
# other requests in the meantime).
#
# You can configure the slow log with two parameters: one tells Redis
# what is the execution time, in microseconds, to exceed in order for the
# command to get logged, and the other parameter is the length of the
# slow log. When a new command is logged the oldest one is removed from the
# queue of logged commands.

# The following time is expressed in microseconds, so 1000000 is equivalent
# to one second. Note that a negative number disables the slow log, while
# a value of zero forces the logging of every command.
slowlog-log-slower-than 10000

# There is no limit to this length. Just be aware that it will consume memory.
# You can reclaim memory used by the slow log with SLOWLOG RESET.
slowlog-max-len 128

################################ LATENCY MONITOR ##############################

# The Redis latency monitoring subsystem samples different operations
# at runtime in order to collect data related to possible sources of
# latency of a Redis instance.
#
# Via the LATENCY command this information is available to the user that can
# print graphs and obtain reports.
#
# The system only logs operations that were performed in a time equal or
# greater than the amount of milliseconds specified via the
# latency-monitor-threshold configuration directive. When its value is set
# to zero, the latency monitor is turned off.
#
# By default latency monitoring is disabled since it is mostly not needed
# if you don't have latency issues, and collecting data has a performance
# impact, that while very small, can be measured under big load. Latency
# monitoring can easily be enabled at runtime using the command
# "CONFIG SET latency-monitor-threshold <milliseconds>" if needed.
latency-monitor-threshold 0

############################# EVENT NOTIFICATION ##############################

# Redis can notify Pub/Sub clients about events happening in the key space.
# This feature is documented at http://redis.io/topics/notifications
#
# For instance if keyspace events notification is enabled, and a client
# performs a DEL operation on key "foo" stored in the Database 0, two
# messages will be published via Pub/Sub:
#
# PUBLISH __keyspace@0__:foo del
# PUBLISH __keyevent@0__:del foo
#
# It is possible to select the events that Redis will notify among a set
# of classes. Every class is identified by a single character:
#
#  K     Keyspace events, published with __keyspace@<db>__ prefix.
#  E     Keyevent events, published with __keyevent@<db>__ prefix.
#  g     Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ...
#  $     String commands
#  l     List commands
#  s     Set commands
#  h     Hash commands
#  z     Sorted set commands
#  x     Expired events (events generated every time a key expires)
#  e     Evicted events (events generated when a key is evicted for maxmemory)
#  A     Alias for g$lshzxe, so that the "AKE" string means all the events.
#
#  The "notify-keyspace-events" takes as argument a string that is composed
#  of zero or multiple characters. The empty string means that notifications
#  are disabled.
#
#  Example: to enable list and generic events, from the point of view of the
#           event name, use:
#
#  notify-keyspace-events Elg
#
#  Example 2: to get the stream of the expired keys subscribing to channel
#             name __keyevent@0__:expired use:
#
#  notify-keyspace-events Ex
#
#  By default all notifications are disabled because most users don't need
#  this feature and the feature has some overhead. Note that if you don't
#  specify at least one of K or E, no events will be delivered.
notify-keyspace-events ""

############################### ADVANCED CONFIG ###############################

# Hashes are encoded using a memory efficient data structure when they have a
# small number of entries, and the biggest entry does not exceed a given
# threshold. These thresholds can be configured using the following directives.
hash-max-ziplist-entries 512
hash-max-ziplist-value 64

# Lists are also encoded in a special way to save a lot of space.
# The number of entries allowed per internal list node can be specified
# as a fixed maximum size or a maximum number of elements.
# For a fixed maximum size, use -5 through -1, meaning:
# -5: max size: 64 Kb  <-- not recommended for normal workloads
# -4: max size: 32 Kb  <-- not recommended
# -3: max size: 16 Kb  <-- probably not recommended
# -2: max size: 8 Kb   <-- good
# -1: max size: 4 Kb   <-- good
# Positive numbers mean store up to _exactly_ that number of elements
# per list node.
# The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size),
# but if your use case is unique, adjust the settings as necessary.
list-max-ziplist-size -2

# Lists may also be compressed.
# Compress depth is the number of quicklist ziplist nodes from *each* side of
# the list to *exclude* from compression.  The head and tail of the list
# are always uncompressed for fast push/pop operations.  Settings are:
# 0: disable all list compression
# 1: depth 1 means "don't start compressing until after 1 node into the list,
#    going from either the head or tail"
#    So: [head]->node->node->...->node->[tail]
#    [head], [tail] will always be uncompressed; inner nodes will compress.
# 2: [head]->[next]->node->node->...->node->[prev]->[tail]
#    2 here means: don't compress head or head->next or tail->prev or tail,
#    but compress all nodes between them.
# 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail]
# etc.
list-compress-depth 0

# Sets have a special encoding in just one case: when a set is composed
# of just strings that happen to be integers in radix 10 in the range
# of 64 bit signed integers.
# The following configuration setting sets the limit in the size of the
# set in order to use this special memory saving encoding.
set-max-intset-entries 512

# Similarly to hashes and lists, sorted sets are also specially encoded in
# order to save a lot of space. This encoding is only used when the length and
# elements of a sorted set are below the following limits:
zset-max-ziplist-entries 128
zset-max-ziplist-value 64

# HyperLogLog sparse representation bytes limit. The limit includes the
# 16 bytes header. When an HyperLogLog using the sparse representation crosses
# this limit, it is converted into the dense representation.
#
# A value greater than 16000 is totally useless, since at that point the
# dense representation is more memory efficient.
#
# The suggested value is ~ 3000 in order to have the benefits of
# the space efficient encoding without slowing down too much PFADD,
# which is O(N) with the sparse encoding. The value can be raised to
# ~ 10000 when CPU is not a concern, but space is, and the data set is
# composed of many HyperLogLogs with cardinality in the 0 - 15000 range.
hll-sparse-max-bytes 3000

# Streams macro node max size / items. The stream data structure is a radix
# tree of big nodes that encode multiple items inside. Using this configuration
# it is possible to configure how big a single node can be in bytes, and the
# maximum number of items it may contain before switching to a new node when
# appending new stream entries. If any of the following settings are set to
# zero, the limit is ignored, so for instance it is possible to set just a
# max entires limit by setting max-bytes to 0 and max-entries to the desired
# value.
stream-node-max-bytes 4096
stream-node-max-entries 100

# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
# order to help rehashing the main Redis hash table (the one mapping top-level
# keys to values). The hash table implementation Redis uses (see dict.c)
# performs a lazy rehashing: the more operation you run into a hash table
# that is rehashing, the more rehashing "steps" are performed, so if the
# server is idle the rehashing is never complete and some more memory is used
# by the hash table.
#
# The default is to use this millisecond 10 times every second in order to
# actively rehash the main dictionaries, freeing memory when possible.
#
# If unsure:
# use "activerehashing no" if you have hard latency requirements and it is
# not a good thing in your environment that Redis can reply from time to time
# to queries with 2 milliseconds delay.
#
# use "activerehashing yes" if you don't have such hard requirements but
# want to free memory asap when possible.
activerehashing yes

# The client output buffer limits can be used to force disconnection of clients
# that are not reading data from the server fast enough for some reason (a
# common reason is that a Pub/Sub client can't consume messages as fast as the
# publisher can produce them).
#
# The limit can be set differently for the three different classes of clients:
#
# normal -> normal clients including MONITOR clients
# replica  -> replica clients
# pubsub -> clients subscribed to at least one pubsub channel or pattern
#
# The syntax of every client-output-buffer-limit directive is the following:
#
# client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
#
# A client is immediately disconnected once the hard limit is reached, or if
# the soft limit is reached and remains reached for the specified number of
# seconds (continuously).
# So for instance if the hard limit is 32 megabytes and the soft limit is
# 16 megabytes / 10 seconds, the client will get disconnected immediately
# if the size of the output buffers reach 32 megabytes, but will also get
# disconnected if the client reaches 16 megabytes and continuously overcomes
# the limit for 10 seconds.
#
# By default normal clients are not limited because they don't receive data
# without asking (in a push way), but just after a request, so only
# asynchronous clients may create a scenario where data is requested faster
# than it can read.
#
# Instead there is a default limit for pubsub and replica clients, since
# subscribers and replicas receive data in a push fashion.
#
# Both the hard or the soft limit can be disabled by setting them to zero.
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

# Client query buffers accumulate new commands. They are limited to a fixed
# amount by default in order to avoid that a protocol desynchronization (for
# instance due to a bug in the client) will lead to unbound memory usage in
# the query buffer. However you can configure it here if you have very special
# needs, such us huge multi/exec requests or alike.
#
# client-query-buffer-limit 1gb

# In the Redis protocol, bulk requests, that are, elements representing single
# strings, are normally limited ot 512 mb. However you can change this limit
# here.
#
# proto-max-bulk-len 512mb

# Redis calls an internal function to perform many background tasks, like
# closing connections of clients in timeout, purging expired keys that are
# never requested, and so forth.
#
# Not all tasks are performed with the same frequency, but Redis checks for
# tasks to perform according to the specified "hz" value.
#
# By default "hz" is set to 10. Raising the value will use more CPU when
# Redis is idle, but at the same time will make Redis more responsive when
# there are many keys expiring at the same time, and timeouts may be
# handled with more precision.
#
# The range is between 1 and 500, however a value over 100 is usually not
# a good idea. Most users should use the default of 10 and raise this up to
# 100 only in environments where very low latency is required.
hz 10

# Normally it is useful to have an HZ value which is proportional to the
# number of clients connected. This is useful in order, for instance, to
# avoid too many clients are processed for each background task invocation
# in order to avoid latency spikes.
#
# Since the default HZ value by default is conservatively set to 10, Redis
# offers, and enables by default, the ability to use an adaptive HZ value
# which will temporary raise when there are many connected clients.
#
# When dynamic HZ is enabled, the actual configured HZ will be used as
# as a baseline, but multiples of the configured HZ value will be actually
# used as needed once more clients are connected. In this way an idle
# instance will use very little CPU time while a busy instance will be
# more responsive.
dynamic-hz yes

# When a child rewrites the AOF file, if the following option is enabled
# the file will be fsync-ed every 32 MB of data generated. This is useful
# in order to commit the file to the disk more incrementally and avoid
# big latency spikes.
aof-rewrite-incremental-fsync yes

# When redis saves RDB file, if the following option is enabled
# the file will be fsync-ed every 32 MB of data generated. This is useful
# in order to commit the file to the disk more incrementally and avoid
# big latency spikes.
rdb-save-incremental-fsync yes

# Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good
# idea to start with the default settings and only change them after investigating
# how to improve the performances and how the keys LFU change over time, which
# is possible to inspect via the OBJECT FREQ command.
#
# There are two tunable parameters in the Redis LFU implementation: the
# counter logarithm factor and the counter decay time. It is important to
# understand what the two parameters mean before changing them.
#
# The LFU counter is just 8 bits per key, it's maximum value is 255, so Redis
# uses a probabilistic increment with logarithmic behavior. Given the value
# of the old counter, when a key is accessed, the counter is incremented in
# this way:
#
# 1. A random number R between 0 and 1 is extracted.
# 2. A probability P is calculated as 1/(old_value*lfu_log_factor+1).
# 3. The counter is incremented only if R < P.
#
# The default lfu-log-factor is 10. This is a table of how the frequency
# counter changes with a different number of accesses with different
# logarithmic factors:
#
# +--------+------------+------------+------------+------------+------------+
# | factor | 100 hits   | 1000 hits  | 100K hits  | 1M hits    | 10M hits   |
# +--------+------------+------------+------------+------------+------------+
# | 0      | 104        | 255        | 255        | 255        | 255        |
# +--------+------------+------------+------------+------------+------------+
# | 1      | 18         | 49         | 255        | 255        | 255        |
# +--------+------------+------------+------------+------------+------------+
# | 10     | 10         | 18         | 142        | 255        | 255        |
# +--------+------------+------------+------------+------------+------------+
# | 100    | 8          | 11         | 49         | 143        | 255        |
# +--------+------------+------------+------------+------------+------------+
#
# NOTE: The above table was obtained by running the following commands:
#
#   redis-benchmark -n 1000000 incr foo
#   redis-cli object freq foo
#
# NOTE 2: The counter initial value is 5 in order to give new objects a chance
# to accumulate hits.
#
# The counter decay time is the time, in minutes, that must elapse in order
# for the key counter to be divided by two (or decremented if it has a value
# less <= 10).
#
# The default value for the lfu-decay-time is 1. A Special value of 0 means to
# decay the counter every time it happens to be scanned.
#
# lfu-log-factor 10
# lfu-decay-time 1

########################### ACTIVE DEFRAGMENTATION #######################
#
# WARNING THIS FEATURE IS EXPERIMENTAL. However it was stress tested
# even in production and manually tested by multiple engineers for some
# time.
#
# What is active defragmentation?
# -------------------------------
#
# Active (online) defragmentation allows a Redis server to compact the
# spaces left between small allocations and deallocations of data in memory,
# thus allowing to reclaim back memory.
#
# Fragmentation is a natural process that happens with every allocator (but
# less so with Jemalloc, fortunately) and certain workloads. Normally a server
# restart is needed in order to lower the fragmentation, or at least to flush
# away all the data and create it again. However thanks to this feature
# implemented by Oran Agra for Redis 4.0 this process can happen at runtime
# in an "hot" way, while the server is running.
#
# Basically when the fragmentation is over a certain level (see the
# configuration options below) Redis will start to create new copies of the
# values in contiguous memory regions by exploiting certain specific Jemalloc
# features (in order to understand if an allocation is causing fragmentation
# and to allocate it in a better place), and at the same time, will release the
# old copies of the data. This process, repeated incrementally for all the keys
# will cause the fragmentation to drop back to normal values.
#
# Important things to understand:
#
# 1. This feature is disabled by default, and only works if you compiled Redis
#    to use the copy of Jemalloc we ship with the source code of Redis.
#    This is the default with Linux builds.
#
# 2. You never need to enable this feature if you don't have fragmentation
#    issues.
#
# 3. Once you experience fragmentation, you can enable this feature when
#    needed with the command "CONFIG SET activedefrag yes".
#
# The configuration parameters are able to fine tune the behavior of the
# defragmentation process. If you are not sure about what they mean it is
# a good idea to leave the defaults untouched.

# Enabled active defragmentation
# activedefrag yes

# Minimum amount of fragmentation waste to start active defrag
# active-defrag-ignore-bytes 100mb

# Minimum percentage of fragmentation to start active defrag
# active-defrag-threshold-lower 10

# Maximum percentage of fragmentation at which we use maximum effort
# active-defrag-threshold-upper 100

# Minimal effort for defrag in CPU percentage
# active-defrag-cycle-min 5

# Maximal effort for defrag in CPU percentage
# active-defrag-cycle-max 75

# Maximum number of set/hash/zset/list fields that will be processed from
# the main dictionary scan
# active-defrag-max-scan-fields 1000

@xx-zhang xx-zhang added duplicate This issue or pull request already exists good first issue Good for newcomers invalid This doesn't seem right labels Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists good first issue Good for newcomers invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants