So far, we have learned how to set up and connect to a single Redis Server. In a production environment, a single database instance is often subject to failures, such as system crashes, network partitions, or power outages. Like most other database systems, Redis also provides a replication mechanism, which enables data to be copied from one Redis Server (master) to one or more other Redis Servers (slaves).
Replication not only makes the entire system fault-tolerant, but can also be used to scale the system horizontally. In a read-heavy application, we can add multiple Redis read-only slaves to mitigate the pressure on the master server.
Redis replication is fundamental to the Redis Cluster, which provides high availability. In this chapter, we will first introduce how Redis replication works and how to set up a Redis master-slave replication environment. After that...