redis persistence mechanism and memory management

  redis persistence in two ways: RDB way and manner AOF

  1, RDB way: memory snapshots at specified time intervals a snapshot of the data stored in the client support directly BGSAVE or SAVE command to create a memory snapshot, BGSAVE will fork a child process snapshot is written to disk, the parent process can still be processing other commands, sAVE perform the procedure does not deal with other commands; you can adjust the save configuration option to set the persistence of triggering policy in redis.conf, when Redis occurred within the specified time the number of write operations trigger condition is met Persistence.

  2, AOF way: recording each write operation to the server when the server restart will re-execute the command to restore the data, open the AOF way through the configuration appendonly yes in redis.conf, a synchronized strategy to set the parameters by adjusting appendsync

  RDB way advantage: performance impact on small, fast data recovery disadvantage: loss of data, fork child process will affect the ability to provide services.

  AOF embodiment Advantages: safe, disaster readable disadvantages: large file size, performance loss, slow data recovery

  redis Memory Management

  In redis.conf to configure the maximum memory by maxmemory, policies can be configured threshold is reached by maxmemory-policy, alternative strategies are as follows

  Wherein LRU (least recently used) to access historical data out of the recording data, the LFU (history visits), the access frequency to phase out history data specific reference redis official website.

  reids memory compression can also be configured to compress the data by arranging the maximum value of the respective data structure, save space.

  redis data expiration policies

  1, active treatment is performed 10 times per second, the key is provided with an expiration time of 20 randomly find, delete has expired, if there are more than 25% of expired, re-executed once.

  2, passive processing each check for expired access expired is deleted, the data recovery time.

  Past data processing Data Recovery

  1, RDB way overdue key is not persistent, loading period, expired key will be deleted by active or passive out

  2, AOF way every time appends a del command encountered an expired key, execute the command when order is restored will delete expired key

  

Guess you like

Origin www.cnblogs.com/hhhshct/p/11568285.html