Apsaradb for Redis AOF

Source: Internet
Author: User
Tags redis server

Introduction: Redis is a memory-based database. It also provides several persistent solutions that allow users to write data in the memory to the local file system for use after the next restart or after the host. This article describes how to set the AOF Function Based on Redis.


What is Redis AOF?

AOF is the abbreviation of AppendOnly File. It is a Persistence Solution for Redis operations. In the files generated by AOF, the loyal records are recorded in Redis operations, this allows you to resume the data status after the Redis server is restarted or when the server is running.


Here we will briefly look at how to use AOF in Redis and verify the entire process:

A. Major AOF settings in Redis

Appendonly yes ---- enable the aof setting and place the snapshot function at a lower priority

Appendfsync no
When appendfsync is set to no, Redis does not actively call fsync to synchronize the AOF log content to the disk, so all of this depends on the operating system debugging. For most Linux operating systems, fsync is performed every 30 seconds to write data in the buffer zone to the disk.
Appendfsync everysec
When appendfsync is set to everysec, Redis performs an fsync call every second by default to write data in the buffer zone to the disk. However, when the fsync call lasts for more than 1 second. Redis will adopt the fsync delay policy and wait a second. That is to say, if you perform fsync two seconds later, this fsync will be executed no matter how long it will take. At this time, because the file descriptor will be blocked during fsync, the current write operation will be blocked.
The conclusion is that in most cases, Redis performs fsync every second. In the worst case, an fsync operation is performed in two seconds. This operation is called group commit in most database systems. It combines the data of multiple write operations and writes logs to the disk at one time.
Appendfsync always
When appendfsync is set to always, fsync is called for every write operation, which is the safest data. Of course, because fsync is executed every time,
Therefore, its performance will also be affected.

B. Start redis-server

C. Open redis-cli and operate data

D. view the aof File

From the figure above, we can find that in the AOF file, it faithfully records the operations on Redis, thus achieving the purpose of restoring data. Of course, this method is not very efficient. The main problem is that a large amount of operations may be performed on some data. In this case, a large number of redundant operation records must be generated. I will discuss the solution to this problem in the subsequent blog.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.