-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NEW] Support redis cluster mode #219
Labels
Comments
ShooterIT
added
release notes
major decision
Requires project management committee consensus
labels
Apr 13, 2021
Merged
Merged
ShooterIT
added a commit
that referenced
this issue
Jun 16, 2021
One cluster mode is similar with redis cluster, please see #219
ShooterIT
added a commit
that referenced
this issue
Jun 16, 2021
One cluster mode is similar with redis cluster, please see #219
Reopen for unfinished extra work |
ShooterIT
added a commit
to ShooterIT/kvrocks
that referenced
this issue
Jul 15, 2021
One cluster mode is similar with redis cluster, please see apache#219
ShooterIT
added a commit
that referenced
this issue
Jul 19, 2021
One cluster mode is similar with redis cluster, please see #219
This was referenced Dec 16, 2021
@ShooterIT can you list out the pending works to complete this issue? Or superseding this one with a new issue describing the status quo. |
Hi @tisonkun i think we can close it, kvrocks has supported slot-based data migration, and kvrocks controller already can be used. Thanks for your attention. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1 Background
Currently, we discard the support for
codis
mode, if we want to deploy kvrocks cluster, we need to pre-shard for cluster and deploy a proxy liketwemproxy
to route requests. This cluster solution also is adopted when redis doesn't support cluster mode, but it is not convenient for failover, linear scale, management, moreover, we must route requests by a proxy, that must cause performance loss because of extra network communication. So we hope there a way we can implement a feature that is similar with redis cluster mode.But if we totally support redis cluster mode in kvrocks, it doesn't seem a good idea, because it is hard to implement redis cluster management and gossip protocol without bugs. We must upgrade server if we find bugs, after all, it costs many years to make redis cluster work well. In order to get benefits from redis cluster mode, we can only support partial redis cluster commands that make a chance to let
redis cluster sdk(such as jedis)
orredis cluster proxy(such as redis-cluster-proxy, predixy)
work well.2 Implementation
2.1 Basic version
Firstly, every node needs to know the entire cluster topology, itself identifier. When clients(
redis-cli
, SDK or proxy) connect to arbitrary one node of kvrocks cluster, they could know slot distribution of cluster by sendingCLUSTER NODES
command, then route requests. And the kvrocks should replyMOVED
when clients send requests to wrong server. To do that, we should implementCLUSTER SETNODES
command to set the entire cluster topology for every nodes, and provideCLUSTER NODES
command to make kvrocks node similar with redis.CLUSTER NODES
The return of this command is the same format of redis cluster.
Example:
CLUSTER SETNODES
$ALL_NODES_INFO
$VERSION
FORCE
$ALL_NODES_INFO
format:$node_id
$ip $port
$role
$master_node_id
$slot_range
.$role
: master or slave,$master_node_id
: master_node_id if it is slave, otherwise, this value is-
. slave needn't set$slot_range
.Example:
$VERSION
means current cluster topology version that is stored or generated by management component such as config server or meta-server.Kvrocks can know itself node id by compared with itself ip and port in received
all nodes info
From now, it works well, we just tell every node of kvrocks cluster by
CLUSTER SETNODES
when scale(slot data migration) or failover. Clients(redis-cli, sdk, proxy) will reacquire cluster topology when they finds requests are rejected orMOVED
by using old topology to route requests. To avoid missing notify nodes new topology, we can set new cluster topology every longer interval.*Please notice that: the cluster solution for kvrocks doesn't handle scale or failover.
2.1 Advanced version
We find we always tell every node entire cluster topology even just changing one node info. If the cluster is very large, the message will be big, so we also fall into the damage of network communication, and cluster management component may can't support that. So we may need to support incremental changing notification. When changing topology, we only send one light command to change the topology in kvrocks server. To implement incremental changing notification, we must use
version
to identify current topology version, otherwise, kvrocks may keep a wrong cluster topology if missing one changing topology message. Kvrocks only supports to apply one command content when its version is valid by compared with the$version
in command, if not, kvrocks must return an error, and we will set new entire cluster topology byCLUSTER SETNODES
command.There are some commands we may need to support.
Get version of node, so that we can check its' version is right or not.
$NODE_ID
Explicitly tell the node its node id.
$NODE_ID
$NODE_INFO
$VERSION
Only update one node info
$NODE_ID
$VERSION
Delete one node of cluster
$NODE_ID
Just like
slaveof
, similar with redis command.$SLOT_ID
$NODE_ID
Migrate all keys belonging the slot to another node
$SLOT_ID
$NODE_ID
$VERSION
Only update one slot distribution, that is useful to avoid too many big messages when we scale cluster.
To make kvrocks cluster similar with redis cluster
3 Advantages and disadvantages
3.1 Advantages
3.2 Disadvantages
4 Extra works
The text was updated successfully, but these errors were encountered: