010 Redis Persistent RDB

Source: Internet
Author: User
Tags redis

One. Overview

The persistence feature of Redis is the decision that Redis can be the core of a certain functional database.

There are a total of two ways to persist in Redis, an RDB, and a aof approach.

Note: We do not need to use the persistence of Redis, without using the persistence feature,

Decide that we are using Redis as a cache, which is no different from memcache.

Two. The fundamentals of an RDB

Redis is a single process, and when we turn on RDB data persistence, Redis will fork a new process to help implement the functions of the RDB.

In fact, the function of the RDB is very simple, is to periodically snapshot the Redis memory. When the snapshot is complete, replace the original snapshot content.

This is done when Redis uses the next boot directly to read the snapshot files directly into Redis.

The related configuration of the snapshot is concentrated in the redis.conf file.

Three. View Redis.conf file

We found the snapshot portion of the Redis configuration file.

For example, this section is the configuration for the snapshot portion of Redis.

Note: The default for Redis is to use snapshots for persistence.

Save Policy:

  

The text above represents the save policy for Redis in RDB mode.

Explain the above text:

[1]save 900 1--a snapshot is taken once in 900 seconds.

[2]save---300 seconds 10 This write operation will take a snapshot once.

[3]save 60 10000:10000 for 60 seconds, a snapshot is taken.

The above snapshot policy we can fix, adjust to a better way.

When we do not set any save policy, the RDB does not take a snapshot.

When we appear RBD persistent error. Whether the write operation is forbidden.

This ensures the consistency of the Redis data, but when errors occur, it can affect the use of redis.

RDB Persistence is compressed: The RDB is compressed by default.

If you want to perform the highest performance, turn off the compression function directly, but the pressure on the storage will become larger.

Whether to turn on the RDB checksum.

If you want to get the highest performance, you can set it to No. Of course the correct data may be problematic.

The location where the Rdb file is saved and the name of the file saved.

When we query the redis.conf file, we can see that there is a Dump.rdb file underneath the file. This is the snapshot file for the RDB.

Four. The advantages and disadvantages of an RDB

Advantage: The RDB has a higher performance because the RDB holds the final result set.

Disadvantage: The RDB is not real-time and can result in loss of data.

The last data saved will be discarded when the data is lost.

Summary: If the integrity of the data requirements are not high, we can use the RDB approach, such performance will be higher.

Advanced:

[1] An RDB requires more memory overhead because it needs to turn on a fork process to monitor the RDB.

[2] When the amount of data is very large, the RDB performance is poor, because the snapshot of the IO operation at a high cost.

  

010 Redis Persistent RDB

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.