This paper mainly analyzes several common ways of using Redis and its advantages and disadvantages.

First, common use

Several common ways of using Redis include:











• Developed by Redis.

Two, the advantages and disadvantages of various ways of use

1. Redis single copy

Redis single copy: a single Redis node is deployed. No standby node synchronizes data in real time. Data persistence and backup policies are not provided.



Advantages:








Disadvantages:





• High performance is limited by the processing capacity of a single-core CPU (Redis is a single-thread mechanism). CPU is the main bottleneck, so it is suitable for scenarios with simple operation commands and less sorting and calculation. Consider Memcached instead.

2. Redis multiple copies (master/slave)

Redis multi-copy uses a master/slave deployment structure. Compared with single-copy, the most important feature of Redis is real-time data synchronization between master and slave instances, and data persistence and backup policies. The primary and secondary instances are deployed on different physical servers. Based on the enterprise environment, the primary and secondary instances can provide services externally and implement read/write separation policies.



Advantages:





Disadvantages:








• The disadvantages of native replication are also prominent in earlier versions. For example, after the Redis replication is interrupted, the Slave initiates psync. If the synchronization fails, the Slave performs full synchronization. Because of COW mechanism, in extreme cases, the main library memory overflow, program abnormal exit or downtime; Backup files generated by the primary library node consume server DISK I/O and CPU (compression) resources. The number of GB backup files to be sent increases the egress bandwidth of the server, blocking requests. You are advised to upgrade to the latest version.

3. Redis Sentinel

Redis Sentinel is a native high availability solution launched in the community edition. Its deployment architecture mainly consists of two parts: Redis Sentinel cluster and Redis data cluster.

Redis Sentinel cluster is a distributed cluster composed of several Sentinel nodes, which can realize fault discovery, automatic failover, configuration center and client notification. The number of nodes of Redis Sentinel should be an odd number of 2n+1 (n>=1).



Advantages:











Disadvantages:











Advice:





• Set parameters reasonably to prevent miscutting and control switching sensitivity control:

a. quorum

b. down-after-milliseconds 30000

c. failover-timeout 180000

d. maxclient

e. timeout





Redis Cluster is a community version of Redis distributed Cluster solution, mainly to solve the needs of Redis distributed, for example, when the single memory, concurrency and flow bottleneck, Redis Cluster can play a good load balancing purpose.

Redis Cluster A Cluster node must contain at least six nodes (three active and three slave nodes). The primary node provides read and write operations, and the secondary node serves as the standby node. The primary node does not provide requests, but only serves as failover.

Redis Cluster uses virtual slot partitioning. All keys are mapped to integer slots ranging from 0 to 16,383 based on hash functions. Each node is responsible for maintaining some slots and the mapped key data printed by slots.



Advantages:














Disadvantages:









































The high availability solution developed by Redis is mainly reflected in the configuration center, fault detection, and failover processing mechanism. It usually needs to be customized according to the actual online environment of enterprise services.



Advantages:








Disadvantages:





• High maintenance costs.



The original article was published on August 20, 2018

Author: Zhang Donghong

This article is from the cloud community partner “DBAplus community”. For relevant information, please follow the “DBAplus Community”.