Redis Full Memory operation

Source: Internet
Author: User

In some usage scenarios, we do not need to use redis persistence, instead we need to play Redis's in-memory database features for full memory operation to achieve the required high performance.

The Redis itself supports persistence by synchronizing the in-memory data to disk for a certain interval or triggering operation to guarantee the persistence of the certificate. Redis supports two persistence modes, one is snapshotting (snapshot), saved as Dump.rdb file, is the default, and the other is append-only file (abbreviated AOF), saved as. aof files.

Snapshot Snapshot use the Save or Bgsave command to notify Redis of a snapshot persistence. The Save action is to save the snapshot in the main thread, which will block all client requests because Redis uses a main thread to handle requests from all clients . So it is not recommended. It is also important to note that each snapshot persistence is a full write of memory to disk once, not incremental synchronous incremental data only. If the volume of data is large, the write operation will be more, will inevitably cause a large number of disk IO operations, may seriously affect performance.

In the default snapshot Rdb save mode, the configuration in redis.conf is as follows

Save 1 #900秒内如果超过1 Key is modified, the snapshot is saved #300秒内容如超过10个key modified, the snapshot is saved save 60 10000

If we need to close the snapshot, just comment the lines and restart Redis.

If you are running an instance, you can use the REDIS-CLI command

# View current configuration config Get save# off snapshot config set save ""

To update the configuration online, the output OK indicates a successful setup.


AOF is more durable than snapshot mode, because Redis will write each of the received writes when using the AOF persistence mode.

Commands are appended to the file via the Write function (default is appendonly.aof). When a Redis reboot is performed by re-executing the file

Save the Write command to rebuild the contents of the entire database in memory

The default configuration is as follows:

AppendOnly Yes//enable log append persistence #appendfsync always//write command is forced to write to disk immediately, slowest, but guaranteed full persistence, not recommended for Appendfsync Everysec//sec Force Write Into the disk once, in the performance and durability of a good compromise, recommended #appendfsync no//fully dependent on the operating system, the best performance, persistent no guarantee

We need to update the configuration file to:

Appendfsync No

Online Update configuration using

# View current configuration config Get appendfsync# off snapshot config set Appendfsync no

With these two configurations, Redis can run completely in memory.

If you want to persist manually, you can use Redis's bgsave and bgrewriteaof to manually persist.


Redis Full Memory operation

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.