• INCLUDES
  • MODULES
  • NETWORK
  • GENERAL
  • SNAPSHOTTING
  • REPLICATION
  • SECURITY
  • CLIENTS
  • MEMORY MANAGEMENT
  • LAZY FREEING
  • APPEND ONLY MODE
  • LUA SCRIPTING
  • REDIS CLUSTER
  • CLUSTER DOCKER/NAT support
  • SLOW LOG
  • LATENCY MONITOR
  • EVENT NOTIFICATION
  • ADVANCED CONFIG
  • ACTIVE DEFRAGMENTATION

    本文来自redis 官方配置文件

    1. # Redis configuration file example.
    2. #
    3. # Note that in order to read the configuration file, Redis must be
    4. # started with the file path as first argument:
    5. #
    6. # ./redis-server /path/to/redis.conf
    7. # Note on units: when memory size is needed, it is possible to specify
    8. # it in the usual form of 1k 5GB 4M and so forth:
    9. #
    10. # 1k => 1000 bytes
    11. # 1kb => 1024 bytes
    12. # 1m => 1000000 bytes
    13. # 1mb => 1024*1024 bytes
    14. # 1g => 1000000000 bytes
    15. # 1gb => 1024*1024*1024 bytes
    16. #
    17. # units are case insensitive so 1GB 1Gb 1gB are all the same.

    INCLUDES

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

    MODULES

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

    NETWORK

    1. ################################## NETWORK #####################################
    2. # By default, if no "bind" configuration directive is specified, Redis listens
    3. # for connections from all the network interfaces available on the server.
    4. # It is possible to listen to just one or multiple selected interfaces using
    5. # the "bind" configuration directive, followed by one or more IP addresses.
    6. #
    7. # Examples:
    8. #
    9. # bind 192.168.1.100 10.0.0.1
    10. # bind 127.0.0.1 ::1
    11. #
    12. # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
    13. # internet, binding to all the interfaces is dangerous and will expose the
    14. # instance to everybody on the internet. So by default we uncomment the
    15. # following bind directive, that will force Redis to listen only into
    16. # the IPv4 lookback interface address (this means Redis will be able to
    17. # accept connections only from clients running into the same computer it
    18. # is running).
    19. #
    20. # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
    21. # JUST COMMENT THE FOLLOWING LINE.
    22. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    23. bind 127.0.0.1
    24. # Protected mode is a layer of security protection, in order to avoid that
    25. # Redis instances left open on the internet are accessed and exploited.
    26. #
    27. # When protected mode is on and if:
    28. #
    29. # 1) The server is not binding explicitly to a set of addresses using the
    30. # "bind" directive.
    31. # 2) No password is configured.
    32. #
    33. # The server only accepts connections from clients connecting from the
    34. # IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
    35. # sockets.
    36. #
    37. # By default protected mode is enabled. You should disable it only if
    38. # you are sure you want clients from other hosts to connect to Redis
    39. # even if no authentication is configured, nor a specific set of interfaces
    40. # are explicitly listed using the "bind" directive.
    41. protected-mode yes
    42. # Accept connections on the specified port, default is 6379 (IANA #815344).
    43. # If port 0 is specified Redis will not listen on a TCP socket.
    44. port 6379
    45. # TCP listen() backlog.
    46. #
    47. # In high requests-per-second environments you need an high backlog in order
    48. # to avoid slow clients connections issues. Note that the Linux kernel
    49. # will silently truncate it to the value of /proc/sys/net/core/somaxconn so
    50. # make sure to raise both the value of somaxconn and tcp_max_syn_backlog
    51. # in order to get the desired effect.
    52. tcp-backlog 511
    53. # Unix socket.
    54. #
    55. # Specify the path for the Unix socket that will be used to listen for
    56. # incoming connections. There is no default, so Redis will not listen
    57. # on a unix socket when not specified.
    58. #
    59. # unixsocket /tmp/redis.sock
    60. # unixsocketperm 700
    61. # Close the connection after a client is idle for N seconds (0 to disable)
    62. timeout 0
    63. # TCP keepalive.
    64. #
    65. # If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
    66. # of communication. This is useful for two reasons:
    67. #
    68. # 1) Detect dead peers.
    69. # 2) Take the connection alive from the point of view of network
    70. # equipment in the middle.
    71. #
    72. # On Linux, the specified value (in seconds) is the period used to send ACKs.
    73. # Note that to close the connection the double of the time is needed.
    74. # On other kernels the period depends on the kernel configuration.
    75. #
    76. # A reasonable value for this option is 300 seconds, which is the new
    77. # Redis default starting with Redis 3.2.1.
    78. tcp-keepalive 300

    GENERAL

    1. ################################# GENERAL #####################################
    2. # By default Redis does not run as a daemon. Use 'yes' if you need it.
    3. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
    4. daemonize yes
    5. # If you run Redis from upstart or systemd, Redis can interact with your
    6. # supervision tree. Options:
    7. # supervised no - no supervision interaction
    8. # supervised upstart - signal upstart by putting Redis into SIGSTOP mode
    9. # supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
    10. # supervised auto - detect upstart or systemd method based on
    11. # UPSTART_JOB or NOTIFY_SOCKET environment variables
    12. # Note: these supervision methods only signal "process is ready."
    13. # They do not enable continuous liveness pings back to your supervisor.
    14. supervised no
    15. # If a pid file is specified, Redis writes it where specified at startup
    16. # and removes it at exit.
    17. #
    18. # When the server runs non daemonized, no pid file is created if none is
    19. # specified in the configuration. When the server is daemonized, the pid file
    20. # is used even if not specified, defaulting to "/var/run/redis.pid".
    21. #
    22. # Creating a pid file is best effort: if Redis is not able to create it
    23. # nothing bad happens, the server will start and run normally.
    24. pidfile /var/run/redis_6379.pid
    25. # Specify the server verbosity level.
    26. # This can be one of:
    27. # debug (a lot of information, useful for development/testing)
    28. # verbose (many rarely useful info, but not a mess like the debug level)
    29. # notice (moderately verbose, what you want in production probably)
    30. # warning (only very important / critical messages are logged)
    31. loglevel notice
    32. # Specify the log file name. Also the empty string can be used to force
    33. # Redis to log on the standard output. Note that if you use standard
    34. # output for logging but daemonize, logs will be sent to /dev/null
    35. logfile ""
    36. # To enable logging to the system logger, just set 'syslog-enabled' to yes,
    37. # and optionally update the other syslog parameters to suit your needs.
    38. # syslog-enabled no
    39. # Specify the syslog identity.
    40. # syslog-ident redis
    41. # Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
    42. # syslog-facility local0
    43. # Set the number of databases. The default database is DB 0, you can select
    44. # a different one on a per-connection basis using SELECT <dbid> where
    45. # dbid is a number between 0 and 'databases'-1
    46. databases 16
    47. # By default Redis shows an ASCII art logo only when started to log to the
    48. # standard output and if the standard output is a TTY. Basically this means
    49. # that normally a logo is displayed only in interactive sessions.
    50. #
    51. # However it is possible to force the pre-4.0 behavior and always show a
    52. # ASCII art logo in startup logs by setting the following option to yes.
    53. always-show-logo yes

    SNAPSHOTTING

    1. ################################ SNAPSHOTTING ################################
    2. #
    3. # Save the DB on disk:
    4. #
    5. # save <seconds> <changes>
    6. #
    7. # Will save the DB if both the given number of seconds and the given
    8. # number of write operations against the DB occurred.
    9. #
    10. # In the example below the behaviour will be to save:
    11. # after 900 sec (15 min) if at least 1 key changed
    12. # after 300 sec (5 min) if at least 10 keys changed
    13. # after 60 sec if at least 10000 keys changed
    14. #
    15. # Note: you can disable saving completely by commenting out all "save" lines.
    16. #
    17. # It is also possible to remove all the previously configured save
    18. # points by adding a save directive with a single empty string argument
    19. # like in the following example:
    20. #
    21. # save ""
    22. save 900 1
    23. save 300 10
    24. save 60 10000
    25. # By default Redis will stop accepting writes if RDB snapshots are enabled
    26. # (at least one save point) and the latest background save failed.
    27. # This will make the user aware (in a hard way) that data is not persisting
    28. # on disk properly, otherwise chances are that no one will notice and some
    29. # disaster will happen.
    30. #
    31. # If the background saving process will start working again Redis will
    32. # automatically allow writes again.
    33. #
    34. # However if you have setup your proper monitoring of the Redis server
    35. # and persistence, you may want to disable this feature so that Redis will
    36. # continue to work as usual even if there are problems with disk,
    37. # permissions, and so forth.
    38. stop-writes-on-bgsave-error yes
    39. # Compress string objects using LZF when dump .rdb databases?
    40. # For default that's set to 'yes' as it's almost always a win.
    41. # If you want to save some CPU in the saving child set it to 'no' but
    42. # the dataset will likely be bigger if you have compressible values or keys.
    43. rdbcompression yes
    44. # Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
    45. # This makes the format more resistant to corruption but there is a performance
    46. # hit to pay (around 10%) when saving and loading RDB files, so you can disable it
    47. # for maximum performances.
    48. #
    49. # RDB files created with checksum disabled have a checksum of zero that will
    50. # tell the loading code to skip the check.
    51. rdbchecksum yes
    52. # The filename where to dump the DB
    53. dbfilename dump.rdb
    54. # The working directory.
    55. #
    56. # The DB will be written inside this directory, with the filename specified
    57. # above using the 'dbfilename' configuration directive.
    58. #
    59. # The Append Only File will also be created inside this directory.
    60. #
    61. # Note that you must specify a directory here, not a file name.
    62. dir ./

    REPLICATION

    1. ################################# REPLICATION #################################
    2. # Master-Slave replication. Use slaveof to make a Redis instance a copy of
    3. # another Redis server. A few things to understand ASAP about Redis replication.
    4. #
    5. # 1) Redis replication is asynchronous, but you can configure a master to
    6. # stop accepting writes if it appears to be not connected with at least
    7. # a given number of slaves.
    8. # 2) Redis slaves are able to perform a partial resynchronization with the
    9. # master if the replication link is lost for a relatively small amount of
    10. # time. You may want to configure the replication backlog size (see the next
    11. # sections of this file) with a sensible value depending on your needs.
    12. # 3) Replication is automatic and does not need user intervention. After a
    13. # network partition slaves automatically try to reconnect to masters
    14. # and resynchronize with them.
    15. #
    16. # slaveof <masterip> <masterport>
    17. # If the master is password protected (using the "requirepass" configuration
    18. # directive below) it is possible to tell the slave to authenticate before
    19. # starting the replication synchronization process, otherwise the master will
    20. # refuse the slave request.
    21. #
    22. # masterauth <master-password>
    23. # When a slave loses its connection with the master, or when the replication
    24. # is still in progress, the slave can act in two different ways:
    25. #
    26. # 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
    27. # still reply to client requests, possibly with out of date data, or the
    28. # data set may just be empty if this is the first synchronization.
    29. #
    30. # 2) if slave-serve-stale-data is set to 'no' the slave will reply with
    31. # an error "SYNC with master in progress" to all the kind of commands
    32. # but to INFO and SLAVEOF.
    33. #
    34. slave-serve-stale-data yes
    35. # You can configure a slave instance to accept writes or not. Writing against
    36. # a slave instance may be useful to store some ephemeral data (because data
    37. # written on a slave will be easily deleted after resync with the master) but
    38. # may also cause problems if clients are writing to it because of a
    39. # misconfiguration.
    40. #
    41. # Since Redis 2.6 by default slaves are read-only.
    42. #
    43. # Note: read only slaves are not designed to be exposed to untrusted clients
    44. # on the internet. It's just a protection layer against misuse of the instance.
    45. # Still a read only slave exports by default all the administrative commands
    46. # such as CONFIG, DEBUG, and so forth. To a limited extent you can improve
    47. # security of read only slaves using 'rename-command' to shadow all the
    48. # administrative / dangerous commands.
    49. slave-read-only yes
    50. # Replication SYNC strategy: disk or socket.
    51. #
    52. # -------------------------------------------------------
    53. # WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY
    54. # -------------------------------------------------------
    55. #
    56. # New slaves and reconnecting slaves that are not able to continue the replication
    57. # process just receiving differences, need to do what is called a "full
    58. # synchronization". An RDB file is transmitted from the master to the slaves.
    59. # The transmission can happen in two different ways:
    60. #
    61. # 1) Disk-backed: The Redis master creates a new process that writes the RDB
    62. # file on disk. Later the file is transferred by the parent
    63. # process to the slaves incrementally.
    64. # 2) Diskless: The Redis master creates a new process that directly writes the
    65. # RDB file to slave sockets, without touching the disk at all.
    66. #
    67. # With disk-backed replication, while the RDB file is generated, more slaves
    68. # can be queued and served with the RDB file as soon as the current child producing
    69. # the RDB file finishes its work. With diskless replication instead once
    70. # the transfer starts, new slaves arriving will be queued and a new transfer
    71. # will start when the current one terminates.
    72. #
    73. # When diskless replication is used, the master waits a configurable amount of
    74. # time (in seconds) before starting the transfer in the hope that multiple slaves
    75. # will arrive and the transfer can be parallelized.
    76. #
    77. # With slow disks and fast (large bandwidth) networks, diskless replication
    78. # works better.
    79. repl-diskless-sync no
    80. # When diskless replication is enabled, it is possible to configure the delay
    81. # the server waits in order to spawn the child that transfers the RDB via socket
    82. # to the slaves.
    83. #
    84. # This is important since once the transfer starts, it is not possible to serve
    85. # new slaves arriving, that will be queued for the next RDB transfer, so the server
    86. # waits a delay in order to let more slaves arrive.
    87. #
    88. # The delay is specified in seconds, and by default is 5 seconds. To disable
    89. # it entirely just set it to 0 seconds and the transfer will start ASAP.
    90. repl-diskless-sync-delay 5
    91. # Slaves send PINGs to server in a predefined interval. It's possible to change
    92. # this interval with the repl_ping_slave_period option. The default value is 10
    93. # seconds.
    94. #
    95. # repl-ping-slave-period 10
    96. # The following option sets the replication timeout for:
    97. #
    98. # 1) Bulk transfer I/O during SYNC, from the point of view of slave.
    99. # 2) Master timeout from the point of view of slaves (data, pings).
    100. # 3) Slave timeout from the point of view of masters (REPLCONF ACK pings).
    101. #
    102. # It is important to make sure that this value is greater than the value
    103. # specified for repl-ping-slave-period otherwise a timeout will be detected
    104. # every time there is low traffic between the master and the slave.
    105. #
    106. # repl-timeout 60
    107. # Disable TCP_NODELAY on the slave socket after SYNC?
    108. #
    109. # If you select "yes" Redis will use a smaller number of TCP packets and
    110. # less bandwidth to send data to slaves. But this can add a delay for
    111. # the data to appear on the slave side, up to 40 milliseconds with
    112. # Linux kernels using a default configuration.
    113. #
    114. # If you select "no" the delay for data to appear on the slave side will
    115. # be reduced but more bandwidth will be used for replication.
    116. #
    117. # By default we optimize for low latency, but in very high traffic conditions
    118. # or when the master and slaves are many hops away, turning this to "yes" may
    119. # be a good idea.
    120. repl-disable-tcp-nodelay no
    121. # Set the replication backlog size. The backlog is a buffer that accumulates
    122. # slave data when slaves are disconnected for some time, so that when a slave
    123. # wants to reconnect again, often a full resync is not needed, but a partial
    124. # resync is enough, just passing the portion of data the slave missed while
    125. # disconnected.
    126. #
    127. # The bigger the replication backlog, the longer the time the slave can be
    128. # disconnected and later be able to perform a partial resynchronization.
    129. #
    130. # The backlog is only allocated once there is at least a slave connected.
    131. #
    132. # repl-backlog-size 1mb
    133. # After a master has no longer connected slaves for some time, the backlog
    134. # will be freed. The following option configures the amount of seconds that
    135. # need to elapse, starting from the time the last slave disconnected, for
    136. # the backlog buffer to be freed.
    137. #
    138. # Note that slaves never free the backlog for timeout, since they may be
    139. # promoted to masters later, and should be able to correctly "partially
    140. # resynchronize" with the slaves: hence they should always accumulate backlog.
    141. #
    142. # A value of 0 means to never release the backlog.
    143. #
    144. # repl-backlog-ttl 3600
    145. # The slave priority is an integer number published by Redis in the INFO output.
    146. # It is used by Redis Sentinel in order to select a slave to promote into a
    147. # master if the master is no longer working correctly.
    148. #
    149. # A slave with a low priority number is considered better for promotion, so
    150. # for instance if there are three slaves with priority 10, 100, 25 Sentinel will
    151. # pick the one with priority 10, that is the lowest.
    152. #
    153. # However a special priority of 0 marks the slave as not able to perform the
    154. # role of master, so a slave with priority of 0 will never be selected by
    155. # Redis Sentinel for promotion.
    156. #
    157. # By default the priority is 100.
    158. slave-priority 100
    159. # It is possible for a master to stop accepting writes if there are less than
    160. # N slaves connected, having a lag less or equal than M seconds.
    161. #
    162. # The N slaves need to be in "online" state.
    163. #
    164. # The lag in seconds, that must be <= the specified value, is calculated from
    165. # the last ping received from the slave, that is usually sent every second.
    166. #
    167. # This option does not GUARANTEE that N replicas will accept the write, but
    168. # will limit the window of exposure for lost writes in case not enough slaves
    169. # are available, to the specified number of seconds.
    170. #
    171. # For example to require at least 3 slaves with a lag <= 10 seconds use:
    172. #
    173. # min-slaves-to-write 3
    174. # min-slaves-max-lag 10
    175. #
    176. # Setting one or the other to 0 disables the feature.
    177. #
    178. # By default min-slaves-to-write is set to 0 (feature disabled) and
    179. # min-slaves-max-lag is set to 10.
    180. # A Redis master is able to list the address and port of the attached
    181. # slaves in different ways. For example the "INFO replication" section
    182. # offers this information, which is used, among other tools, by
    183. # Redis Sentinel in order to discover slave instances.
    184. # Another place where this info is available is in the output of the
    185. # "ROLE" command of a master.
    186. #
    187. # The listed IP and address normally reported by a slave is obtained
    188. # in the following way:
    189. #
    190. # IP: The address is auto detected by checking the peer address
    191. # of the socket used by the slave to connect with the master.
    192. #
    193. # Port: The port is communicated by the slave during the replication
    194. # handshake, and is normally the port that the slave is using to
    195. # list for connections.
    196. #
    197. # However when port forwarding or Network Address Translation (NAT) is
    198. # used, the slave may be actually reachable via different IP and port
    199. # pairs. The following two options can be used by a slave in order to
    200. # report to its master a specific set of IP and port, so that both INFO
    201. # and ROLE will report those values.
    202. #
    203. # There is no need to use both the options if you need to override just
    204. # the port or the IP address.
    205. #
    206. # slave-announce-ip 5.5.5.5
    207. # slave-announce-port 1234

    SECURITY

    1. ################################## SECURITY ###################################
    2. # Require clients to issue AUTH <PASSWORD> before processing any other
    3. # commands. This might be useful in environments in which you do not trust
    4. # others with access to the host running redis-server.
    5. #
    6. # This should stay commented out for backward compatibility and because most
    7. # people do not need auth (e.g. they run their own servers).
    8. #
    9. # Warning: since Redis is pretty fast an outside user can try up to
    10. # 150k passwords per second against a good box. This means that you should
    11. # use a very strong password otherwise it will be very easy to break.
    12. #
    13. # requirepass foobared
    14. # Command renaming.
    15. #
    16. # It is possible to change the name of dangerous commands in a shared
    17. # environment. For instance the CONFIG command may be renamed into something
    18. # hard to guess so that it will still be available for internal-use tools
    19. # but not available for general clients.
    20. #
    21. # Example:
    22. #
    23. # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
    24. #
    25. # It is also possible to completely kill a command by renaming it into
    26. # an empty string:
    27. #
    28. # rename-command CONFIG ""
    29. #
    30. # Please note that changing the name of commands that are logged into the
    31. # AOF file or transmitted to slaves may cause problems.

    CLIENTS

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

    MEMORY MANAGEMENT

    1. ############################## MEMORY MANAGEMENT ################################
    2. # Set a memory usage limit to the specified amount of bytes.
    3. # When the memory limit is reached Redis will try to remove keys
    4. # according to the eviction policy selected (see maxmemory-policy).
    5. #
    6. # If Redis can't remove keys according to the policy, or if the policy is
    7. # set to 'noeviction', Redis will start to reply with errors to commands
    8. # that would use more memory, like SET, LPUSH, and so on, and will continue
    9. # to reply to read-only commands like GET.
    10. #
    11. # This option is usually useful when using Redis as an LRU or LFU cache, or to
    12. # set a hard memory limit for an instance (using the 'noeviction' policy).
    13. #
    14. # WARNING: If you have slaves attached to an instance with maxmemory on,
    15. # the size of the output buffers needed to feed the slaves are subtracted
    16. # from the used memory count, so that network problems / resyncs will
    17. # not trigger a loop where keys are evicted, and in turn the output
    18. # buffer of slaves is full with DELs of keys evicted triggering the deletion
    19. # of more keys, and so forth until the database is completely emptied.
    20. #
    21. # In short... if you have slaves attached it is suggested that you set a lower
    22. # limit for maxmemory so that there is some free RAM on the system for slave
    23. # output buffers (but this is not needed if the policy is 'noeviction').
    24. #
    25. # maxmemory <bytes>
    26. # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
    27. # is reached. You can select among five behaviors:
    28. #
    29. # volatile-lru -> Evict using approximated LRU among the keys with an expire set.
    30. # allkeys-lru -> Evict any key using approximated LRU.
    31. # volatile-lfu -> Evict using approximated LFU among the keys with an expire set.
    32. # allkeys-lfu -> Evict any key using approximated LFU.
    33. # volatile-random -> Remove a random key among the ones with an expire set.
    34. # allkeys-random -> Remove a random key, any key.
    35. # volatile-ttl -> Remove the key with the nearest expire time (minor TTL)
    36. # noeviction -> Don't evict anything, just return an error on write operations.
    37. #
    38. # LRU means Least Recently Used
    39. # LFU means Least Frequently Used
    40. #
    41. # Both LRU, LFU and volatile-ttl are implemented using approximated
    42. # randomized algorithms.
    43. #
    44. # Note: with any of the above policies, Redis will return an error on write
    45. # operations, when there are no suitable keys for eviction.
    46. #
    47. # At the date of writing these commands are: set setnx setex append
    48. # incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
    49. # sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
    50. # zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
    51. # getset mset msetnx exec sort
    52. #
    53. # The default is:
    54. #
    55. # maxmemory-policy noeviction
    56. # LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated
    57. # algorithms (in order to save memory), so you can tune it for speed or
    58. # accuracy. For default Redis will check five keys and pick the one that was
    59. # used less recently, you can change the sample size using the following
    60. # configuration directive.
    61. #
    62. # The default of 5 produces good enough results. 10 Approximates very closely
    63. # true LRU but costs more CPU. 3 is faster but not very accurate.
    64. #
    65. # maxmemory-samples 5

    LAZY FREEING

    1. ############################# LAZY FREEING ####################################
    2. # Redis has two primitives to delete keys. One is called DEL and is a blocking
    3. # deletion of the object. It means that the server stops processing new commands
    4. # in order to reclaim all the memory associated with an object in a synchronous
    5. # way. If the key deleted is associated with a small object, the time needed
    6. # in order to execute the DEL command is very small and comparable to most other
    7. # O(1) or O(log_N) commands in Redis. However if the key is associated with an
    8. # aggregated value containing millions of elements, the server can block for
    9. # a long time (even seconds) in order to complete the operation.
    10. #
    11. # For the above reasons Redis also offers non blocking deletion primitives
    12. # such as UNLINK (non blocking DEL) and the ASYNC option of FLUSHALL and
    13. # FLUSHDB commands, in order to reclaim memory in background. Those commands
    14. # are executed in constant time. Another thread will incrementally free the
    15. # object in the background as fast as possible.
    16. #
    17. # DEL, UNLINK and ASYNC option of FLUSHALL and FLUSHDB are user-controlled.
    18. # It's up to the design of the application to understand when it is a good
    19. # idea to use one or the other. However the Redis server sometimes has to
    20. # delete keys or flush the whole database as a side effect of other operations.
    21. # Specifically Redis deletes objects independently of a user call in the
    22. # following scenarios:
    23. #
    24. # 1) On eviction, because of the maxmemory and maxmemory policy configurations,
    25. # in order to make room for new data, without going over the specified
    26. # memory limit.
    27. # 2) Because of expire: when a key with an associated time to live (see the
    28. # EXPIRE command) must be deleted from memory.
    29. # 3) Because of a side effect of a command that stores data on a key that may
    30. # already exist. For example the RENAME command may delete the old key
    31. # content when it is replaced with another one. Similarly SUNIONSTORE
    32. # or SORT with STORE option may delete existing keys. The SET command
    33. # itself removes any old content of the specified key in order to replace
    34. # it with the specified string.
    35. # 4) During replication, when a slave performs a full resynchronization with
    36. # its master, the content of the whole database is removed in order to
    37. # load the RDB file just transfered.
    38. #
    39. # In all the above cases the default is to delete objects in a blocking way,
    40. # like if DEL was called. However you can configure each case specifically
    41. # in order to instead release memory in a non-blocking way like if UNLINK
    42. # was called, using the following configuration directives:
    43. lazyfree-lazy-eviction no
    44. lazyfree-lazy-expire no
    45. lazyfree-lazy-server-del no
    46. slave-lazy-flush no

    APPEND ONLY MODE

    1. ############################## APPEND ONLY MODE ###############################
    2. # By default Redis asynchronously dumps the dataset on disk. This mode is
    3. # good enough in many applications, but an issue with the Redis process or
    4. # a power outage may result into a few minutes of writes lost (depending on
    5. # the configured save points).
    6. #
    7. # The Append Only File is an alternative persistence mode that provides
    8. # much better durability. For instance using the default data fsync policy
    9. # (see later in the config file) Redis can lose just one second of writes in a
    10. # dramatic event like a server power outage, or a single write if something
    11. # wrong with the Redis process itself happens, but the operating system is
    12. # still running correctly.
    13. #
    14. # AOF and RDB persistence can be enabled at the same time without problems.
    15. # If the AOF is enabled on startup Redis will load the AOF, that is the file
    16. # with the better durability guarantees.
    17. #
    18. # Please check http://redis.io/topics/persistence for more information.
    19. appendonly no
    20. # The name of the append only file (default: "appendonly.aof")
    21. appendfilename "appendonly.aof"
    22. # The fsync() call tells the Operating System to actually write data on disk
    23. # instead of waiting for more data in the output buffer. Some OS will really flush
    24. # data on disk, some other OS will just try to do it ASAP.
    25. #
    26. # Redis supports three different modes:
    27. #
    28. # no: don't fsync, just let the OS flush the data when it wants. Faster.
    29. # always: fsync after every write to the append only log. Slow, Safest.
    30. # everysec: fsync only one time every second. Compromise.
    31. #
    32. # The default is "everysec", as that's usually the right compromise between
    33. # speed and data safety. It's up to you to understand if you can relax this to
    34. # "no" that will let the operating system flush the output buffer when
    35. # it wants, for better performances (but if you can live with the idea of
    36. # some data loss consider the default persistence mode that's snapshotting),
    37. # or on the contrary, use "always" that's very slow but a bit safer than
    38. # everysec.
    39. #
    40. # More details please check the following article:
    41. # http://antirez.com/post/redis-persistence-demystified.html
    42. #
    43. # If unsure, use "everysec".
    44. # appendfsync always
    45. appendfsync everysec
    46. # appendfsync no
    47. # When the AOF fsync policy is set to always or everysec, and a background
    48. # saving process (a background save or AOF log background rewriting) is
    49. # performing a lot of I/O against the disk, in some Linux configurations
    50. # Redis may block too long on the fsync() call. Note that there is no fix for
    51. # this currently, as even performing fsync in a different thread will block
    52. # our synchronous write(2) call.
    53. #
    54. # In order to mitigate this problem it's possible to use the following option
    55. # that will prevent fsync() from being called in the main process while a
    56. # BGSAVE or BGREWRITEAOF is in progress.
    57. #
    58. # This means that while another child is saving, the durability of Redis is
    59. # the same as "appendfsync none". In practical terms, this means that it is
    60. # possible to lose up to 30 seconds of log in the worst scenario (with the
    61. # default Linux settings).
    62. #
    63. # If you have latency problems turn this to "yes". Otherwise leave it as
    64. # "no" that is the safest pick from the point of view of durability.
    65. no-appendfsync-on-rewrite no
    66. # Automatic rewrite of the append only file.
    67. # Redis is able to automatically rewrite the log file implicitly calling
    68. # BGREWRITEAOF when the AOF log size grows by the specified percentage.
    69. #
    70. # This is how it works: Redis remembers the size of the AOF file after the
    71. # latest rewrite (if no rewrite has happened since the restart, the size of
    72. # the AOF at startup is used).
    73. #
    74. # This base size is compared to the current size. If the current size is
    75. # bigger than the specified percentage, the rewrite is triggered. Also
    76. # you need to specify a minimal size for the AOF file to be rewritten, this
    77. # is useful to avoid rewriting the AOF file even if the percentage increase
    78. # is reached but it is still pretty small.
    79. #
    80. # Specify a percentage of zero in order to disable the automatic AOF
    81. # rewrite feature.
    82. auto-aof-rewrite-percentage 100
    83. auto-aof-rewrite-min-size 64mb
    84. # An AOF file may be found to be truncated at the end during the Redis
    85. # startup process, when the AOF data gets loaded back into memory.
    86. # This may happen when the system where Redis is running
    87. # crashes, especially when an ext4 filesystem is mounted without the
    88. # data=ordered option (however this can't happen when Redis itself
    89. # crashes or aborts but the operating system still works correctly).
    90. #
    91. # Redis can either exit with an error when this happens, or load as much
    92. # data as possible (the default now) and start if the AOF file is found
    93. # to be truncated at the end. The following option controls this behavior.
    94. #
    95. # If aof-load-truncated is set to yes, a truncated AOF file is loaded and
    96. # the Redis server starts emitting a log to inform the user of the event.
    97. # Otherwise if the option is set to no, the server aborts with an error
    98. # and refuses to start. When the option is set to no, the user requires
    99. # to fix the AOF file using the "redis-check-aof" utility before to restart
    100. # the server.
    101. #
    102. # Note that if the AOF file will be found to be corrupted in the middle
    103. # the server will still exit with an error. This option only applies when
    104. # Redis will try to read more data from the AOF file but not enough bytes
    105. # will be found.
    106. aof-load-truncated yes
    107. # When rewriting the AOF file, Redis is able to use an RDB preamble in the
    108. # AOF file for faster rewrites and recoveries. When this option is turned
    109. # on the rewritten AOF file is composed of two different stanzas:
    110. #
    111. # [RDB file][AOF tail]
    112. #
    113. # When loading Redis recognizes that the AOF file starts with the "REDIS"
    114. # string and loads the prefixed RDB file, and continues loading the AOF
    115. # tail.
    116. #
    117. # This is currently turned off by default in order to avoid the surprise
    118. # of a format change, but will at some point be used as the default.
    119. aof-use-rdb-preamble no

    LUA SCRIPTING

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

    REDIS CLUSTER

    1. ################################ REDIS CLUSTER ###############################
    2. #
    3. # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    4. # WARNING EXPERIMENTAL: Redis Cluster is considered to be stable code, however
    5. # in order to mark it as "mature" we need to wait for a non trivial percentage
    6. # of users to deploy it in production.
    7. # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    8. #
    9. # Normal Redis instances can't be part of a Redis Cluster; only nodes that are
    10. # started as cluster nodes can. In order to start a Redis instance as a
    11. # cluster node enable the cluster support uncommenting the following:
    12. #
    13. # cluster-enabled yes
    14. # Every cluster node has a cluster configuration file. This file is not
    15. # intended to be edited by hand. It is created and updated by Redis nodes.
    16. # Every Redis Cluster node requires a different cluster configuration file.
    17. # Make sure that instances running in the same system do not have
    18. # overlapping cluster configuration file names.
    19. #
    20. # cluster-config-file nodes-6379.conf
    21. # Cluster node timeout is the amount of milliseconds a node must be unreachable
    22. # for it to be considered in failure state.
    23. # Most other internal time limits are multiple of the node timeout.
    24. #
    25. # cluster-node-timeout 15000
    26. # A slave of a failing master will avoid to start a failover if its data
    27. # looks too old.
    28. #
    29. # There is no simple way for a slave to actually have an exact measure of
    30. # its "data age", so the following two checks are performed:
    31. #
    32. # 1) If there are multiple slaves able to failover, they exchange messages
    33. # in order to try to give an advantage to the slave with the best
    34. # replication offset (more data from the master processed).
    35. # Slaves will try to get their rank by offset, and apply to the start
    36. # of the failover a delay proportional to their rank.
    37. #
    38. # 2) Every single slave computes the time of the last interaction with
    39. # its master. This can be the last ping or command received (if the master
    40. # is still in the "connected" state), or the time that elapsed since the
    41. # disconnection with the master (if the replication link is currently down).
    42. # If the last interaction is too old, the slave will not try to failover
    43. # at all.
    44. #
    45. # The point "2" can be tuned by user. Specifically a slave will not perform
    46. # the failover if, since the last interaction with the master, the time
    47. # elapsed is greater than:
    48. #
    49. # (node-timeout * slave-validity-factor) + repl-ping-slave-period
    50. #
    51. # So for example if node-timeout is 30 seconds, and the slave-validity-factor
    52. # is 10, and assuming a default repl-ping-slave-period of 10 seconds, the
    53. # slave will not try to failover if it was not able to talk with the master
    54. # for longer than 310 seconds.
    55. #
    56. # A large slave-validity-factor may allow slaves with too old data to failover
    57. # a master, while a too small value may prevent the cluster from being able to
    58. # elect a slave at all.
    59. #
    60. # For maximum availability, it is possible to set the slave-validity-factor
    61. # to a value of 0, which means, that slaves will always try to failover the
    62. # master regardless of the last time they interacted with the master.
    63. # (However they'll always try to apply a delay proportional to their
    64. # offset rank).
    65. #
    66. # Zero is the only value able to guarantee that when all the partitions heal
    67. # the cluster will always be able to continue.
    68. #
    69. # cluster-slave-validity-factor 10
    70. # Cluster slaves are able to migrate to orphaned masters, that are masters
    71. # that are left without working slaves. This improves the cluster ability
    72. # to resist to failures as otherwise an orphaned master can't be failed over
    73. # in case of failure if it has no working slaves.
    74. #
    75. # Slaves migrate to orphaned masters only if there are still at least a
    76. # given number of other working slaves for their old master. This number
    77. # is the "migration barrier". A migration barrier of 1 means that a slave
    78. # will migrate only if there is at least 1 other working slave for its master
    79. # and so forth. It usually reflects the number of slaves you want for every
    80. # master in your cluster.
    81. #
    82. # Default is 1 (slaves migrate only if their masters remain with at least
    83. # one slave). To disable migration just set it to a very large value.
    84. # A value of 0 can be set but is useful only for debugging and dangerous
    85. # in production.
    86. #
    87. # cluster-migration-barrier 1
    88. # By default Redis Cluster nodes stop accepting queries if they detect there
    89. # is at least an hash slot uncovered (no available node is serving it).
    90. # This way if the cluster is partially down (for example a range of hash slots
    91. # are no longer covered) all the cluster becomes, eventually, unavailable.
    92. # It automatically returns available as soon as all the slots are covered again.
    93. #
    94. # However sometimes you want the subset of the cluster which is working,
    95. # to continue to accept queries for the part of the key space that is still
    96. # covered. In order to do so, just set the cluster-require-full-coverage
    97. # option to no.
    98. #
    99. # cluster-require-full-coverage yes
    100. # In order to setup your cluster make sure to read the documentation
    101. # available at http://redis.io web site.

    CLUSTER DOCKER/NAT support

    1. ########################## CLUSTER DOCKER/NAT support ########################
    2. # In certain deployments, Redis Cluster nodes address discovery fails, because
    3. # addresses are NAT-ted or because ports are forwarded (the typical case is
    4. # Docker and other containers).
    5. #
    6. # In order to make Redis Cluster working in such environments, a static
    7. # configuration where each node knows its public address is needed. The
    8. # following two options are used for this scope, and are:
    9. #
    10. # * cluster-announce-ip
    11. # * cluster-announce-port
    12. # * cluster-announce-bus-port
    13. #
    14. # Each instruct the node about its address, client port, and cluster message
    15. # bus port. The information is then published in the header of the bus packets
    16. # so that other nodes will be able to correctly map the address of the node
    17. # publishing the information.
    18. #
    19. # If the above options are not used, the normal Redis Cluster auto-detection
    20. # will be used instead.
    21. #
    22. # Note that when remapped, the bus port may not be at the fixed offset of
    23. # clients port + 10000, so you can specify any port and bus-port depending
    24. # on how they get remapped. If the bus-port is not set, a fixed offset of
    25. # 10000 will be used as usually.
    26. #
    27. # Example:
    28. #
    29. # cluster-announce-ip 10.1.1.5
    30. # cluster-announce-port 6379
    31. # cluster-announce-bus-port 6380

    SLOW LOG

    1. ################################## SLOW LOG ###################################
    2. # The Redis Slow Log is a system to log queries that exceeded a specified
    3. # execution time. The execution time does not include the I/O operations
    4. # like talking with the client, sending the reply and so forth,
    5. # but just the time needed to actually execute the command (this is the only
    6. # stage of command execution where the thread is blocked and can not serve
    7. # other requests in the meantime).
    8. #
    9. # You can configure the slow log with two parameters: one tells Redis
    10. # what is the execution time, in microseconds, to exceed in order for the
    11. # command to get logged, and the other parameter is the length of the
    12. # slow log. When a new command is logged the oldest one is removed from the
    13. # queue of logged commands.
    14. # The following time is expressed in microseconds, so 1000000 is equivalent
    15. # to one second. Note that a negative number disables the slow log, while
    16. # a value of zero forces the logging of every command.
    17. slowlog-log-slower-than 10000
    18. # There is no limit to this length. Just be aware that it will consume memory.
    19. # You can reclaim memory used by the slow log with SLOWLOG RESET.
    20. slowlog-max-len 128

    LATENCY MONITOR

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

    EVENT NOTIFICATION

    1. ############################# EVENT NOTIFICATION ##############################
    2. # Redis can notify Pub/Sub clients about events happening in the key space.
    3. # This feature is documented at http://redis.io/topics/notifications
    4. #
    5. # For instance if keyspace events notification is enabled, and a client
    6. # performs a DEL operation on key "foo" stored in the Database 0, two
    7. # messages will be published via Pub/Sub:
    8. #
    9. # PUBLISH __keyspace@0__:foo del
    10. # PUBLISH __keyevent@0__:del foo
    11. #
    12. # It is possible to select the events that Redis will notify among a set
    13. # of classes. Every class is identified by a single character:
    14. #
    15. # K Keyspace events, published with __keyspace@<db>__ prefix.
    16. # E Keyevent events, published with __keyevent@<db>__ prefix.
    17. # g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ...
    18. # $ String commands
    19. # l List commands
    20. # s Set commands
    21. # h Hash commands
    22. # z Sorted set commands
    23. # x Expired events (events generated every time a key expires)
    24. # e Evicted events (events generated when a key is evicted for maxmemory)
    25. # A Alias for g$lshzxe, so that the "AKE" string means all the events.
    26. #
    27. # The "notify-keyspace-events" takes as argument a string that is composed
    28. # of zero or multiple characters. The empty string means that notifications
    29. # are disabled.
    30. #
    31. # Example: to enable list and generic events, from the point of view of the
    32. # event name, use:
    33. #
    34. # notify-keyspace-events Elg
    35. #
    36. # Example 2: to get the stream of the expired keys subscribing to channel
    37. # name __keyevent@0__:expired use:
    38. #
    39. # notify-keyspace-events Ex
    40. #
    41. # By default all notifications are disabled because most users don't need
    42. # this feature and the feature has some overhead. Note that if you don't
    43. # specify at least one of K or E, no events will be delivered.
    44. notify-keyspace-events ""

    ADVANCED CONFIG

    1. ############################### ADVANCED CONFIG ###############################
    2. # Hashes are encoded using a memory efficient data structure when they have a
    3. # small number of entries, and the biggest entry does not exceed a given
    4. # threshold. These thresholds can be configured using the following directives.
    5. hash-max-ziplist-entries 512
    6. hash-max-ziplist-value 64
    7. # Lists are also encoded in a special way to save a lot of space.
    8. # The number of entries allowed per internal list node can be specified
    9. # as a fixed maximum size or a maximum number of elements.
    10. # For a fixed maximum size, use -5 through -1, meaning:
    11. # -5: max size: 64 Kb <-- not recommended for normal workloads
    12. # -4: max size: 32 Kb <-- not recommended
    13. # -3: max size: 16 Kb <-- probably not recommended
    14. # -2: max size: 8 Kb <-- good
    15. # -1: max size: 4 Kb <-- good
    16. # Positive numbers mean store up to _exactly_ that number of elements
    17. # per list node.
    18. # The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size),
    19. # but if your use case is unique, adjust the settings as necessary.
    20. list-max-ziplist-size -2
    21. # Lists may also be compressed.
    22. # Compress depth is the number of quicklist ziplist nodes from *each* side of
    23. # the list to *exclude* from compression. The head and tail of the list
    24. # are always uncompressed for fast push/pop operations. Settings are:
    25. # 0: disable all list compression
    26. # 1: depth 1 means "don't start compressing until after 1 node into the list,
    27. # going from either the head or tail"
    28. # So: [head]->node->node->...->node->[tail]
    29. # [head], [tail] will always be uncompressed; inner nodes will compress.
    30. # 2: [head]->[next]->node->node->...->node->[prev]->[tail]
    31. # 2 here means: don't compress head or head->next or tail->prev or tail,
    32. # but compress all nodes between them.
    33. # 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail]
    34. # etc.
    35. list-compress-depth 0
    36. # Sets have a special encoding in just one case: when a set is composed
    37. # of just strings that happen to be integers in radix 10 in the range
    38. # of 64 bit signed integers.
    39. # The following configuration setting sets the limit in the size of the
    40. # set in order to use this special memory saving encoding.
    41. set-max-intset-entries 512
    42. # Similarly to hashes and lists, sorted sets are also specially encoded in
    43. # order to save a lot of space. This encoding is only used when the length and
    44. # elements of a sorted set are below the following limits:
    45. zset-max-ziplist-entries 128
    46. zset-max-ziplist-value 64
    47. # HyperLogLog sparse representation bytes limit. The limit includes the
    48. # 16 bytes header. When an HyperLogLog using the sparse representation crosses
    49. # this limit, it is converted into the dense representation.
    50. #
    51. # A value greater than 16000 is totally useless, since at that point the
    52. # dense representation is more memory efficient.
    53. #
    54. # The suggested value is ~ 3000 in order to have the benefits of
    55. # the space efficient encoding without slowing down too much PFADD,
    56. # which is O(N) with the sparse encoding. The value can be raised to
    57. # ~ 10000 when CPU is not a concern, but space is, and the data set is
    58. # composed of many HyperLogLogs with cardinality in the 0 - 15000 range.
    59. hll-sparse-max-bytes 3000
    60. # Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
    61. # order to help rehashing the main Redis hash table (the one mapping top-level
    62. # keys to values). The hash table implementation Redis uses (see dict.c)
    63. # performs a lazy rehashing: the more operation you run into a hash table
    64. # that is rehashing, the more rehashing "steps" are performed, so if the
    65. # server is idle the rehashing is never complete and some more memory is used
    66. # by the hash table.
    67. #
    68. # The default is to use this millisecond 10 times every second in order to
    69. # actively rehash the main dictionaries, freeing memory when possible.
    70. #
    71. # If unsure:
    72. # use "activerehashing no" if you have hard latency requirements and it is
    73. # not a good thing in your environment that Redis can reply from time to time
    74. # to queries with 2 milliseconds delay.
    75. #
    76. # use "activerehashing yes" if you don't have such hard requirements but
    77. # want to free memory asap when possible.
    78. activerehashing yes
    79. # The client output buffer limits can be used to force disconnection of clients
    80. # that are not reading data from the server fast enough for some reason (a
    81. # common reason is that a Pub/Sub client can't consume messages as fast as the
    82. # publisher can produce them).
    83. #
    84. # The limit can be set differently for the three different classes of clients:
    85. #
    86. # normal -> normal clients including MONITOR clients
    87. # slave -> slave clients
    88. # pubsub -> clients subscribed to at least one pubsub channel or pattern
    89. #
    90. # The syntax of every client-output-buffer-limit directive is the following:
    91. #
    92. # client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
    93. #
    94. # A client is immediately disconnected once the hard limit is reached, or if
    95. # the soft limit is reached and remains reached for the specified number of
    96. # seconds (continuously).
    97. # So for instance if the hard limit is 32 megabytes and the soft limit is
    98. # 16 megabytes / 10 seconds, the client will get disconnected immediately
    99. # if the size of the output buffers reach 32 megabytes, but will also get
    100. # disconnected if the client reaches 16 megabytes and continuously overcomes
    101. # the limit for 10 seconds.
    102. #
    103. # By default normal clients are not limited because they don't receive data
    104. # without asking (in a push way), but just after a request, so only
    105. # asynchronous clients may create a scenario where data is requested faster
    106. # than it can read.
    107. #
    108. # Instead there is a default limit for pubsub and slave clients, since
    109. # subscribers and slaves receive data in a push fashion.
    110. #
    111. # Both the hard or the soft limit can be disabled by setting them to zero.
    112. client-output-buffer-limit normal 0 0 0
    113. client-output-buffer-limit slave 256mb 64mb 60
    114. client-output-buffer-limit pubsub 32mb 8mb 60
    115. # Client query buffers accumulate new commands. They are limited to a fixed
    116. # amount by default in order to avoid that a protocol desynchronization (for
    117. # instance due to a bug in the client) will lead to unbound memory usage in
    118. # the query buffer. However you can configure it here if you have very special
    119. # needs, such us huge multi/exec requests or alike.
    120. #
    121. # client-query-buffer-limit 1gb
    122. # In the Redis protocol, bulk requests, that are, elements representing single
    123. # strings, are normally limited ot 512 mb. However you can change this limit
    124. # here.
    125. #
    126. # proto-max-bulk-len 512mb
    127. # Redis calls an internal function to perform many background tasks, like
    128. # closing connections of clients in timeout, purging expired keys that are
    129. # never requested, and so forth.
    130. #
    131. # Not all tasks are performed with the same frequency, but Redis checks for
    132. # tasks to perform according to the specified "hz" value.
    133. #
    134. # By default "hz" is set to 10. Raising the value will use more CPU when
    135. # Redis is idle, but at the same time will make Redis more responsive when
    136. # there are many keys expiring at the same time, and timeouts may be
    137. # handled with more precision.
    138. #
    139. # The range is between 1 and 500, however a value over 100 is usually not
    140. # a good idea. Most users should use the default of 10 and raise this up to
    141. # 100 only in environments where very low latency is required.
    142. hz 10
    143. # When a child rewrites the AOF file, if the following option is enabled
    144. # the file will be fsync-ed every 32 MB of data generated. This is useful
    145. # in order to commit the file to the disk more incrementally and avoid
    146. # big latency spikes.
    147. aof-rewrite-incremental-fsync yes
    148. # Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good
    149. # idea to start with the default settings and only change them after investigating
    150. # how to improve the performances and how the keys LFU change over time, which
    151. # is possible to inspect via the OBJECT FREQ command.
    152. #
    153. # There are two tunable parameters in the Redis LFU implementation: the
    154. # counter logarithm factor and the counter decay time. It is important to
    155. # understand what the two parameters mean before changing them.
    156. #
    157. # The LFU counter is just 8 bits per key, it's maximum value is 255, so Redis
    158. # uses a probabilistic increment with logarithmic behavior. Given the value
    159. # of the old counter, when a key is accessed, the counter is incremented in
    160. # this way:
    161. #
    162. # 1. A random number R between 0 and 1 is extracted.
    163. # 2. A probability P is calculated as 1/(old_value*lfu_log_factor+1).
    164. # 3. The counter is incremented only if R < P.
    165. #
    166. # The default lfu-log-factor is 10. This is a table of how the frequency
    167. # counter changes with a different number of accesses with different
    168. # logarithmic factors:
    169. #
    170. # +--------+------------+------------+------------+------------+------------+
    171. # | factor | 100 hits | 1000 hits | 100K hits | 1M hits | 10M hits |
    172. # +--------+------------+------------+------------+------------+------------+
    173. # | 0 | 104 | 255 | 255 | 255 | 255 |
    174. # +--------+------------+------------+------------+------------+------------+
    175. # | 1 | 18 | 49 | 255 | 255 | 255 |
    176. # +--------+------------+------------+------------+------------+------------+
    177. # | 10 | 10 | 18 | 142 | 255 | 255 |
    178. # +--------+------------+------------+------------+------------+------------+
    179. # | 100 | 8 | 11 | 49 | 143 | 255 |
    180. # +--------+------------+------------+------------+------------+------------+
    181. #
    182. # NOTE: The above table was obtained by running the following commands:
    183. #
    184. # redis-benchmark -n 1000000 incr foo
    185. # redis-cli object freq foo
    186. #
    187. # NOTE 2: The counter initial value is 5 in order to give new objects a chance
    188. # to accumulate hits.
    189. #
    190. # The counter decay time is the time, in minutes, that must elapse in order
    191. # for the key counter to be divided by two (or decremented if it has a value
    192. # less <= 10).
    193. #
    194. # The default value for the lfu-decay-time is 1. A Special value of 0 means to
    195. # decay the counter every time it happens to be scanned.
    196. #
    197. # lfu-log-factor 10
    198. # lfu-decay-time 1

    ACTIVE DEFRAGMENTATION

    1. ########################### ACTIVE DEFRAGMENTATION #######################
    2. #
    3. # WARNING THIS FEATURE IS EXPERIMENTAL. However it was stress tested
    4. # even in production and manually tested by multiple engineers for some
    5. # time.
    6. #
    7. # What is active defragmentation?
    8. # -------------------------------
    9. #
    10. # Active (online) defragmentation allows a Redis server to compact the
    11. # spaces left between small allocations and deallocations of data in memory,
    12. # thus allowing to reclaim back memory.
    13. #
    14. # Fragmentation is a natural process that happens with every allocator (but
    15. # less so with Jemalloc, fortunately) and certain workloads. Normally a server
    16. # restart is needed in order to lower the fragmentation, or at least to flush
    17. # away all the data and create it again. However thanks to this feature
    18. # implemented by Oran Agra for Redis 4.0 this process can happen at runtime
    19. # in an "hot" way, while the server is running.
    20. #
    21. # Basically when the fragmentation is over a certain level (see the
    22. # configuration options below) Redis will start to create new copies of the
    23. # values in contiguous memory regions by exploiting certain specific Jemalloc
    24. # features (in order to understand if an allocation is causing fragmentation
    25. # and to allocate it in a better place), and at the same time, will release the
    26. # old copies of the data. This process, repeated incrementally for all the keys
    27. # will cause the fragmentation to drop back to normal values.
    28. #
    29. # Important things to understand:
    30. #
    31. # 1. This feature is disabled by default, and only works if you compiled Redis
    32. # to use the copy of Jemalloc we ship with the source code of Redis.
    33. # This is the default with Linux builds.
    34. #
    35. # 2. You never need to enable this feature if you don't have fragmentation
    36. # issues.
    37. #
    38. # 3. Once you experience fragmentation, you can enable this feature when
    39. # needed with the command "CONFIG SET activedefrag yes".
    40. #
    41. # The configuration parameters are able to fine tune the behavior of the
    42. # defragmentation process. If you are not sure about what they mean it is
    43. # a good idea to leave the defaults untouched.
    44. # Enabled active defragmentation
    45. # activedefrag yes
    46. # Minimum amount of fragmentation waste to start active defrag
    47. # active-defrag-ignore-bytes 100mb
    48. # Minimum percentage of fragmentation to start active defrag
    49. # active-defrag-threshold-lower 10
    50. # Maximum percentage of fragmentation at which we use maximum effort
    51. # active-defrag-threshold-upper 100
    52. # Minimal effort for defrag in CPU percentage
    53. # active-defrag-cycle-min 25
    54. # Maximal effort for defrag in CPU percentage
    55. # active-defrag-cycle-max 75