Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Overview of Redis High availability and persistence

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "Overview of High availability and persistence of Redis". In daily operation, I believe many people have doubts about the overview of high availability and persistence of Redis. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "Overview of High availability and persistence of Redis". Next, please follow the editor to study!

Overview of Redis High availability

Persistence:

Persistence is the simplest method of high availability (sometimes not even classified as high availability). Its main function is to back up the data, that is, to store the data on the hard disk to ensure that the data will not be lost due to the exit of the process.

Copy:

Replication is the basis of highly available Redis, and both Sentinels and clusters achieve high availability on the basis of replication. Replication mainly realizes the multi-machine backup of data, as well as load balancing and simple fault recovery for read operations.

Defects: failure recovery can not be automated, write operations can not be load balanced, and storage capacity is limited by a single machine.

Sentinel:

On the basis of replication, the Sentinel realized automatic fault recovery.

Defect: the write operation cannot be load balanced; the storage capacity is limited by a single machine.

Cluster:

Through clustering, Redis solves the problem that the operation is unable to load balance and the storage capacity is limited by a single machine, and achieves a relatively perfect high availability solution.

Overview of Redis persistence

Persistence function: Redis is an in-memory database, and the data is stored in memory.

Redis persistence is divided into RDB and AOF persistence:

The former is saving the data to the hard disk.

The latter is to save each write command to the hard disk.

RDB persistence

RDB persistence is to generate a snapshot of the data in the current process and save it to the hard disk (so it is also called snapshot persistence). The saved file is suffixed with RDB.

When Redis restarts, the snapshot file recovery data can be read.

Redis trigger condition:

Manually triggered:

Both the save command and the bgsave command can generate RDB files.

The save command blocks the Redis service process until the RDB file is created, and the server cannot execute any command requests during the Redis server blocking.

The bgsave command creates a child process, which creates the RDB file, and the parent process (that is, the Redis main process) continues to process the request. During the execution of the bgsave command, only the fork (ork the process, the redis connection in the child process is not available, reconnect) the child process will block the server, while for the save command, the whole process will block the server.

When RDB persistence is triggered automatically, Redis also uses bgsave instead of save for persistence; the condition for automatically triggering RDB persistence is described below.

Automatically trigger:

The most common situation is through savemn in the configuration file, specifying that bgsave is triggered when n changes occur in m seconds.

At this point, the study on "Overview of High availability and persistence of Redis" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report