Redis persistence-RDB working principle and problems, redis-rdb
Working principle of Redis persistent RDB mode:
Redis persistent RDB mode. Redis uses the copy on write mechanism of the fork command. When a snapshot is generated, the current process is completely copied, fork generates a sub-process, and then all the data is recycled in the sub-process to write the data into an RDB file.
Problems caused by Redis persistent RDB:
In RDB mode, the memory occupied by the Redis service is doubled.
For example, if a machine has 16 GB of memory and uses 10 Gb of memory for Redis service, if the 10 Gb memory is full
Run the save command. Then, the 10G process will be copied again and changed to 20G. If the process exceeds 16G, an exchange will be generated,
If the virtual memory is set to 4 GB, the save operation can also be completed, resulting in a large number of exchanges, which will be very slow;
If the virtual memory is set to less than 4 GB, Redis will crash and the data will not be completely saved to the snapshot file,
After restarting, you will find that the data has been lost.