This is the 9th day of my participation in the November Gwen Challenge. See details: The Last Gwen Challenge 2021.
When I write on the master slave, cluster, sentinel, this who can not wait to see the time, a lot of partners can not wait to see the message of these modes, today we will from the configuration file, design principle, the interview question three aspects to talk about the master slave copy of Redis.
On the basis of Redis replication, it is very simple to use and configure master/slave replication, so that the slave Redis server (hereafter called Replica) can accurately copy the content of the master Redis server (hereafter called master). Each time the connection between replica and Master is disconnected, replica automatically reconnects to the master, and whatever happens to the master in the meantime, replica will try to make an exact copy of the master.
From 5.0.0, Redis officially changed the SLAVEOF command to REPLICAOF and gradually abandoned the SLAVEOF command
Redis uses the default asynchronous replication, which is characterized by low latency and high performance and is the natural replication mode for the vast majority of Redis use cases. However, replica asynchronously acknowledges the amount of data it receives from the master periodically.
Master/slave topology architecture
Master is used to write data, and Replicas is used to read data. In a scenario with high write concurrency, multiple secondary nodes will cause the primary node to send write commands multiple times, consuming network bandwidth excessively, increasing the load on the master node and affecting service stability.
Replica can accept connections from other replicas. In addition to the fact that multiple replicas can be connected to the same master, replicas can also be connected to other replicas in a cascading structure. Starting from Redis 4.0, all sub-replicas will receive exactly the same replica stream from the Master.
When the master needs multiple replicas, a tree-shaped master-slave structure can be adopted to reduce the pressure of the master node to avoid interference to the master’s performance.
To give you a clearer idea of the concept, we will take a detailed look at the parameters of master/slave replication in the configuration file. If you have different opinions or better idea, welcome to contact AH Q, add AH Q can join the technical exchange group to participate in the discussion!