Master-slave:
Through the persistence function, Redis ensures that no data will be lost (or a small amount is lost) even when the server is restarted, because persistence will remove the memory The data is saved to the hard disk, and restarting will load the data from the hard disk. . However, since the data is stored on a server, if the server has problems such as hard disk failure, data loss will also occur.
In order to avoid single points of failure, a common practice is to copy multiple copies of the database and deploy them on different servers, so that even if one server fails, the other servers will still Services can continue to be provided. To this end, Redis provides a replication function, which can automatically synchronize the updated data to other databases when the data in one database is updated. (Recommended learning:Redis video tutorial)
In the concept of replication, databases are divided into two categories, one is the master database (master), and the other is the slave database (slave) . The master database can perform read and write operations. When the write operation causes data changes, the data will be automatically synchronized to the slave database. The slave database is generally read-only and accepts data synchronized from the master database. A master database can have multiple slave databases, and a slave database can only have one master database.
Cluster:
A cluster is a group of independent computers interconnected through a high-speed network. They form a group and are managed in a single system mode. When a client interacts with the cluster, the cluster behaves like a standalone server. Cluster configuration is used to improve availability and scalability. When a request arrives, it is first processed by the load balancing server and forwards the request to another server.
Difference
The master-slave server has a clear division of labor. The master server is used for writing and the slave server is used for reading. One master server and multiple slave servers; cluster Just like, multiple master-slave servers, for example: there are multiple master-slave servers across the country, processing information in their respective regions, which can reduce the pressure on the master server in a single master-slave server.
For more Redis-related technical articles, please visit theIntroduction to Using Redis Database Tutorialcolumn to learn!
The above is the detailed content of The difference between redis master-slave and cluster. For more information, please follow other related articles on the PHP Chinese website!