...
Authors: Jens Deppe
Status: Draft Draft | Discussion | Active | Dropped | Superseded
...
We will not provide the ability to operate in either a pure cluster mode or hybrid mode. Cluster mode will be the only mode. (This would not preclude non-cluster clients capable of interpreting MOVED
responses from working).
Solution
Redis enables data sharding by partitioning data into 16384 slots. Keys are hashed using a well defined hashing algorithm (CRC16/XMODEM) the result of which is then modded with 16384 to determine the slot. Each primary server is responsible for hosting a non-overlapping set of slots. Various cluster commands provide information on slot-to-server allocation. Thus, given a key, a client is able to determine which server is hosting that data and direct the command to the correct server. See also Redis Cluster Specification.
...
In addition, at least the following cluster-specifc commands will be implemented in order to enable clients to take advantage of clustering.
CLUSTER NODES
- this command produces a list identifying each member of the cluster, indicating whether it is a primary or secondary replica and listing the slots which it hosts - https://redis.io/commands/cluster-nodes. Since Geode members host both primary and replica buckets, each member can only be designated as a primary. Below is an example of the proposed output using the literals required by the Redis API.No Format 07c37dfeb235213a872192d90877d0cd55635b91 127.0.0.1:30004@31004 slavemaster e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca- 0 1426238317239 4 connected 7500-10922 67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1 127.0.0.1:30002@31002 master - 0 1426238316232 2 connected 5461-109227499 292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f 127.0.0.1:30003@31003 master - 0 1426238318243 3 connected 10923-1638312999 6ec23923021cf3ffec47632106199cb7f496ce01 127.0.0.1:30005@31005 slavemaster 67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1- 0 1426238316232 5 connected 13000-16383 824fe116063bc5fcf9f4ffd895bc17aee7731ac3 127.0.0.1:30006@31006 slavemaster 292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f- 0 1426238317741 6 connected 2500-5460 e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca 127.0.0.1:30001@31001 myself,master - 0 0 1 connected 0-5460
Since Geode members host both primary and secondary buckets, each member can be designated as a primary, (specifically as 'master' in terms of the above output), and no members will be designated as 'slave'.
2499
CLUSTER SLOTS
- this command produces structured array output with slot information similar to CLUSTER NODES:, including only the primary nodes.No Format 1) 1) (integer) 0 2) (integer) 54602499 3) 1) "127.0.0.1" 2) (integer) 30001 2) 1) (integer) 2500 42) (integer) 5460 3) 1) "127.0.0.1" 2) (integer) 30006 23) 1) (integer) 5461 2) (integer) 109227499 3) 1) "127.0.0.1" 2) (integer) 30002 4) 1) (integer) 7500 2) (integer) 10922 43) 1) "127.0.0.1" 2) (integer) 30004 35) 1) (integer) 10923 2) (integer) 1638312999 3) 1) "127.0.0.1" 2) (integer) 30003 6) 1) (integer) 13000 2) (integer) 16383 43) 1) "127.0.0.1" 2) (integer) 30005
-MOVED
- If a client makes a request to a server that is not hosting the given key, the server will need to respond with a-MOVED
error indicating which server is hosting the key. The current implementation avoids this by using a function call to route the request to the member hosting the key. With this proposal, the need for this layer of indirection will be removed and will improve performance.
Although not currently implemented, this change will greatly ease the ability to develop transactional support using Redis' MULTI/EXEC
commands. Redis transactions require all keys, participating in a transaction, to be colocated in the same slot. The current implementation would require a much more complicated locking scheme allowing multiple keys to be locked across multiple members.
Additional CLUSTER
commands may also be implemented in the future - for example CLUSTER REPLICAS
and CLUSTER INFO
.
Changes and Additions to Public Interfaces
...