Redis learning (four) --- the choice and choice of Redis persistence

1. Endurance effect

Persistence means that because all redis data is kept in memory, updates to the data will be saved to disk asynchronously.

Persistence

  1. Snapshot-Redis RDB, Mysql dump
  2. Write log—MySql's Binlog, Hbase's Hlog, Redis' AOF

Two, one of the redis persistence methods RDB (snapshot)

Insert picture description here
Trigger mechanism-three main methods: save (synchronous), bgsave (asynchronous), automatic.
Insert picture description here
Trigger mechanism-methods not to be ignored: full copy (master-slave), debug reload, shutdown.

RDB problem

  1. Time-consuming and performance-consuming
  2. Uncontrollable, easy to lose data

Two, redis persistence method two AOF (write log)

Insert picture description here
After rebooting, load data from AOF file

Strategy

  1. alway: Each command will be written from the buffer to the AOF file
  2. everysec: Get commands from the buffer to write AOF files every second (it is possible to lose one second of data)
  3. no: The operating system decides when to perform AOF write
    Insert picture description here
    Redis to optimize the AOF write command. Function: 1. Reduce disk usage 2. Accelerate recovery speed

AOF rewrite

Implementation method: 1.bgrewriteaof 2. Automatic rewrite configuration
Insert picture description here

The choice between RDB and AOF

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_38941937/article/details/105204189