Redis master-slave synchronous architecture can ensure the high availability of data, which is a kind of asynchronous replication. However, sometimes due to network or machine reasons, the data of the slave database lags behind that of the master database, which leads to the inconsistency between the master and slave data.
Redis provides the WAIT command to avoid this problem as much as possible, so that users can perceive the difference between master and slave. But the wait command doesn't seem to be that client-friendly.
Can we provide a simple configuration item like MySQL's semi-synchronization to provide functionality similar to WAIT command, where write commands are synchronized to a specified number of slave and return timeout if a timeout occurs, reverting to normal master-slave replication semantics?
Comment From: 1000happiness
If a redis client conbines the data command and WAIT command in a pipeline, it will be blocked until the given slaves accept the write command. The messages sended by client, master and slave are as follows.
- client -- WRITE, WAIT --> master;
- master -- WRITE, REPL_ACK --> slave;
- slave -- OK, REPL_OFF --> master;
- master --> OK, NUM_SLAVES --> client;
The above process is the same with semi-synchronization you want.
Comment From: caipengbo
Yes, this is possible with WAIT command.
But can we support it directly on Redis so that users don't have to wait every time? It is also available for some Redis with Proxy (which does not support WAIT command).