Home > Database > Redis > A brief analysis of the principles and shortcomings of AOF in Redis

A brief analysis of the principles and shortcomings of AOF in Redis

青灯夜游
Release: 2021-11-16 11:35:03
forward
2654 people have browsed it

This article will take you to understand AOF in Redis persistence, introduce the principle of AOF, and the shortcomings of AOF. I hope it will be helpful to everyone!

A brief analysis of the principles and shortcomings of AOF in Redis

AOF

A brief analysis of the principles and shortcomings of AOF in Redis

  • We mentioned rRedis above One of the persistence methods in is RDB
    • In this article, we will talk about another implementation method, which is AOF

    • AOF is an appended log file that only records Redis write commands

    • ##AOF The log is stored in sequential instructions, so after Redis goes down, the purpose of data recovery can be achieved by "retracing the old path" internally

【Related recommendations:

Redis Video Tutorial

AOF Principle

## Every time we execute a write command,
    Redis
  • will append the command to the AOF file.
      actually writes the content to a cache in memory. Summary
    • So
    • Redis

      needs to call the fsync function provided by Linux in real time to transfer the specified file from the kernel every time The cache is written to disk

    • Because if it is very important to call the function in real time, we can also adjust the frequency of calling the
    • fsync

      function by changing the configuration parameters

Rewrite

If you keep appending
    AOF
  • files, the log will become larger and larger So
      Redis
    • implements "rewriting" internally to compress files First of all, because many
    • key-value
    • have long been state-owned enterprises, Or if many values ​​​​are constantly updated, then the log still stores these useless data, which can obviously be optimized So create a sub-process to traverse the memory
    • Traverse into a new file log, Therefore, only the latest value needs to be stored in the
    • AOF
    • log We can use the command below to enable rewriting, of course, it can also be set to automatically execute
    • AOF

A brief analysis of the principles and shortcomings of AOF in Redis

#AOF

Disadvantages ##Traversing the entire memory each time will bring a lot of additional performance overhead to the system

  • Each data recovery is a long process and each time it is written from the kernel to the disk It consumes IO performance

  • For more programming-related knowledge, please visit:

    Introduction to Programming
  • ! !

The above is the detailed content of A brief analysis of the principles and shortcomings of AOF in Redis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:juejin.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template