# 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. # redis does not run in daemon mode by default. You can modify this configuration item and use yes to enable daemon) it refers to computer programs executed in the background in Unix or other multi-task operating systems and won't be directly controlled by computer users .) Daemonize no # When running daemonized, redis writes a PID file in/var/run/redis. PID by # default. you can specify a custom PID file location here. # When redis runs as a daemon, redis places the PID file in/var/run/redis by default. PID, you can configure it to another address. When running multiple redis services, you must specify different PID files and ports pidfile/var/run/redis. pid # accept connections on the specified port, default is 6379. # If Port 0 is specified redis will not listen on a TCP socket. # port 6379 # If you want you can bind a single interface, if the BIND option is not # specified all the interfaces will listen for incoming connections. # specify the IP address that redis can receive requests. If this parameter is not set, all requests are processed. We recommend that you set # bind 127.0.0.1 # Clos in the production environment. E The connection after a client is idle for n seconds (0 to disable) # timeout time for client connection, in seconds, connection timeout 0 # specify the log file name will be closed after timeout. also 'stdout' 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 # configure the log file address, by default, logfile stdout # set the number of databases is printed in the command line terminal window. 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 # set the number of databases, you can use the select <dbid> command to switch databases. The default database is 0 databases 16 # 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 # Not E: You can disable saving at all commenting all the "save" lines. # set the frequency of redis database mirroring. # When one keys change within 900 seconds # When 10 keys change within 30 seconds # If 10000 keys change within 60 seconds, save 900 1 save 300 10 save 60 10000 # 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. # Whether to compress rdbcompression yes # the filename where to dump the DB # Name of the backup file dbfilename dump. RDB # The working directory. # The dB will be written inside this directory, with the filename spec Ified # above using the 'dbfilename' configuration direve ve. # also the append only file will be created inside this directory. # note that you must specify a directory here, not a file name. # path of the database image backup file. The path and file name must be configured separately because redis first writes the status of the current database to a temporary file during Backup. When the backup is complete, replace the temporary file with the file specified above. # The temporary file and the backup file configured above will be placed in the specified path dir. /# Master-slave replication. use slaveof to make a redis instance a copy of # Another redis server. note that the configuration is local to the slave # So for example it is possible to configure the slave to save the DB with a # different interval, or to listen to another port, and so On. # Set the database to another slave database # slaveof <masterip> <masterport> # If the master is password protected (using the "requirepass" configuration # directive below) it is possible to tell the slave to authenticate before # Starting the replication synchronization process, otherwise the master will # refuse the slave request. # password verification required for connection to the primary database # masterauth <master-Password> # require clients to issue auth <password> B Efore 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 shoshould 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 #150 K passwords per second against a go Od box. This means that you should # use a very strong password otherwise it will be very easy to break. # Set the password required before any other specified client connection. Warning redis is quite fast. An external user can perform K password attempts in one second. You need to specify a very powerful password to prevent brute force cracking. # Requirepass foobared # Set the Max number of connected clients at the same time. by default there # is no limit, and it's up to the number of file descriptors The redis process # is able to open. the special value '0' means no limits. # Once the limit is reached redis will close all the new connections sending # An error 'max number of clients reached '. # limit the number of customers connected at the same time. When the number of connections exceeds this value, redis will no longer receive other connection requests. When the client attempts to connect, it will receive the error message # maxclients 128 # Don't use more memory than the specified amount of bytes. # When the memory limit is reached redis will try to remove keys # accordingly to the eviction policy selected (see maxmemmory-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 comma NDS # That wocould 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 cache, or to set # An hard memory limit for an instance (using the 'noeviction 'policy ). # warning: If you have slaves attached to an instance with maxmemory on, # the size of the output buffers needed to feed the slaves Re 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 slaves 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 slaves attached it is suggested that you set a lower # limit for maxmemory so that there is some free RAM on the system for slave # output buffers (but this is not needed if policy is 'noeviction '). # Set the maximum memory available for redis. When the memory is full, if you still receive the SET command, redis will first try to remove the key with expire information, regardless of whether the key expires. # When deleting a key, it will be deleted according to the expiration time. The key to be expired will be deleted first. If all keys with expire information are deleted, an error is returned. # In this way, redis will not receive write requests, but only get requests. Maxmemory settings are suitable for using redis as a cache similar to memcached # maxmemory <bytes> # By default redis asynchronously dumps the dataset on disk. if you can live # with the idea that the latest records will be lost if something like a crash # happens this is the preferred way to run redis. if instead you care a lot # About your data and don't want to that a single record can get lost you shoshould # enable the append only mode: When this mode is enabled redis will append # Every write operation completed ed in the file appendonly. aof. this file will # be read on startup in order to rebuild the full dataset in memory. # note that you can have both the async dumps and the append only file if you # Like (You have to comment the "save" statements above to disable the dumps ). # Still if append only mode is enabled redis will load t He data from the # log file at startup ignoring the dump. RDB file. # Important: Check the bgrewriteaof to check how to rewrite the append # log file in background when it gets too big. # By default, redis asynchronously backs up database images to disks in the background, but this backup is time-consuming and cannot be performed frequently, if a fault occurs, such as power limit or power limit, it may cause a wide range of data loss. # Redis provides another more efficient database backup and disaster recovery method. # After the append only mode is enabled, redis will append each write operation request received to appendonly. in the aof file, when redis is restarted, the previous state will be restored from the file. # However, this will cause appendonly. the aof file is too large, so redis also supports the bgrewriteaof command to appendonly. aof refresh the appendonly no # The fsync () call tells the operating system to actually write data on disk # instead to wait 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 I T wants. faster. # Always: fsync after every write to the append only log. slow, safest. # everysec: fsync only if one second passed since the last fsync. compromise. # The default is "everysec" 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 snapshoces), # or on the contrary, use "always" that's very slow but a bit safer than # everysec. # If unsure, use "everysec ". # Set appendonly. aof file synchronization frequency. Always indicates that the write operation is synchronized every time, while everysec indicates that the write operation is accumulated and synchronized every second. # Appendfsync alwaysappendfsync everysec # appendfsync no # virtual memory allows redis to work with datasets bigger than the actual # amount of Ram needed to hold the whole dataset in memory. # In order to do so very used keys are taken in memory while the other keys # Are swapped into a swap file, similarly to what operating systems do # With memory pages. # To enable VM just set 'vm-enabled' to yes, Nd set the following three # VM parameters accordingly to your needs. # Whether to enable virtual memory support. Because redis is a memory database and cannot receive new write requests when the memory is full, it provides support for Virtual Memory in redis2.0. # However, in redis, all keys are stored in the memory. When the memory is insufficient, only the value is placed in the SWAp zone. # This ensures that although the virtual memory is used, the performance is basically not affected. At the same time, note that you need to set VM-max-memory enough to put down all your keyvm-enabled no # VM-enabled yes # This is the path of the redis swap file. as you can guess, swap files # Can't be shared by different redis instances, so make sure to use a swap # file for every redis process you are running. redis will complain if the # swap file is already in use. # The best kind of storage for the redis swap file (tha T's accessed at random) # is a solid state disk (SSD ). # *** warning *** if you are using a shared hosting the default of putting # The swap file under/tmp is not secure. create a dir with access granted # Only to redis user and configure redis to create the swap file there. # Set the virtual memory swap file path VM-Swap-file/tmp/redis. swap # VM-max-memory configures the VM to use at Max the specified amount of # Ram. everyt Hing that deos not fit will be swapped on disk * If * possible, that # is, if there is still enough contiguous space in the swap file. # with VM-max-memory 0 the system will swap everything it can. not a good # default, just specify the max amount of ram you can in bytes, But it's # better to leave some margin. for instance specify an amount of Ram # That's more or less between 60 and 80% of your free r Am. # set the maximum physical memory size that redis will use after enabling virtual memory. The default value is 0. redis will put all of its swap files into swap files to use as little physical memory as possible. # In the production environment, you need to set this value according to the actual situation. It is best not to use the default 0vm-max-memory 0 # redis swap files is split into pages. an object can be saved using multiple # contiguous pages, but pages can't be shared between different objects. # So if your page is too big, small objects swapped out on disk will waste # a lot of space. if you page is too small, there is less space in the SWAp # file (assuming you configured the same number of total Swap file pages ). # if you use a lot of small objects, use a page size of 64 or 32 bytes. # If you use a lot of big objects, use a bigger page size. # If unsure, use the default # Set the page size of the virtual memory. If your value is large, for example, you need to place all the articles such as blogs and news in the value, make it bigger. If you want to store small content, set smaller VM-page-size 32 # Number of total memory pages in the swap file. # given that the page table (a bitmap of free/used pages) is taken in Memor Y, # Every 8 pages on disk will consume 1 byte of RAM. # The total swap size is VM-page-size * VM-pages # With the default of 32-bytes memory pages and 134217728 pages redis will # Use A 4 GB swap file, that will use 16 MB of RAM for the page table. # it's better to use the smallest acceptable value for your application, # But the default is large in order to work in most conditions. # Set the total number of pages for the swap file Page table information is stored in the physical memory, and each 8 pages occupies one byte in Ram. # Total virtual memory size = VM-page-size * VM-pagesvm-pages 134217728 # Max number of vm I/O threads running at the same time. # This threads are used to read/write data from/to swap file, since they # also encode and decode objects from disk to memory or the reverse, A bigger # Number of threads can help with big objects even if they can't help with # I/O itself as the physical device may not be able to couple with Ma NY # reads/writes operations at the same time. # the special value of 0 turn off threaded I/O and enables the blocking # virtual memory implementation. # Set the number of threads simultaneously used by VM Io. VM-max-threads 4 # hashes are encoded in a special way (much more memory efficient) when they # Have at Max a given numer of elements, and the biggest element does not # exceed a given threshold. you can configure this limits with the following # configuration ctives ves. # The hash data structure is introduced in redis 2.0. # When the hash contains more than the specified number of elements and the maximum number of elements does not exceed the critical value, hash will be stored with zipmap (also known as small hash, which greatly reduces memory usage, here we can set the two critical values hash-max-zipmap-entries 512hash-max-zipmap-value 64 # active rehashing uses 1 millisecond every 100 milliseconds of CPU time in # order to help rehashing the main redis hash table (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 an hash table # That is rhashing, the more rehashing "Steps" are saved med, 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 # active rehashing the main dictionaries, freeing memory when possible. # If unsure: # Use "activerehashing no" if you ha Ve hard latency requirements and it is # Not a good thing in your environment that redis can reply form 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. # After it is enabled, redis uses a CPU time of 1 ms every 100 milliseconds to re-hash the redis hash table, which can reduce the memory usage. # When your application scenario requires strict real-time performance and redis cannot accept a latency of 2 milliseconds from time to time for requests, set this parameter to No. # If you do not have such strict real-time requirements, you can set it to yes to release the memory activerehashing yes as quickly as possible.
Redis configuration details