+--------+ +---------+
| master | <-----+ | replica |
+--------+ +---------+
I'm thinking about how to achieve seamless high-availability switching on Redis's master-replica structure. The following is a design step, but the fourth step is currently not supported by Redis, and it is also the focus of this issue discussion.
- The master node execute
client pause write.
- Confirm that the master and replica are consistent.
- Execute
replicaof no one on the replica node.
- The master node sets up the redirection request. (Maybe something like
client force redirect host port, need discuss).
- The master node execute
client unpause and will return MOVED or REDIRECT to the client, then automatically redirect to the new master node.
In this way, the client can realize seamless HA switching without disconnecting the connection, and most requests can be executed successfully, greatly reducing the business impact of switching on users.
Detail:
Add a configuration item. Once enabled, the replica in master-replica mode will also redirect all commands(read + write), and the client will only be allowed to execute read commands after executing readonly.
I'm thinking about how to achieve seamless high-availability switching on Redis's master-replica structure. The following is a design step, but the fourth step is currently not supported by Redis, and it is also the focus of this issue discussion.
client pause write.replicaof no oneon the replica node.client force redirect host port, need discuss).client unpauseand will returnMOVEDorREDIRECTto the client, then automatically redirect to the new master node.In this way, the client can realize seamless HA switching without disconnecting the connection, and most requests can be executed successfully, greatly reducing the business impact of switching on users.
Detail:
Add a configuration item. Once enabled, the replica in master-replica mode will also redirect all commands(read + write), and the client will only be allowed to execute read commands after executing
readonly.