Redis learning clusters articles ----- Codis

CODIS Redis in
CODIS formula redis clustering program, a middleware agent, and also used as redis Redis protocols to provide services, the client receives the instruction and then forwarded to redis, an intermediate agent between a client and redis
Schematic
CODIS is no service state, each peer node is
1, Codis slice principle
by default all of the key slot is divided into 1024 (SOLT) in CODIS, the specific operation performed in the CODIS client will pass over the key find the key slots, each slot will be uniquely mapped to a plurality of the following instances redis
formula:
the hash = CRC32 (command.key)
slot_index the hash% = 1024
redis = slots [slot_index] .redis
redis.do (Command)
the default is 1024 slots can be provided according to circumstances cluster
2, the different instances Codis synchronization slot
provided in each slot information if Dashboard Codis node only stored in memory, using zookeeper for persistence slot, and to observe and modify the relationship between the slots
Slot synchronization diagram
3, expansion
when codis slot corresponds to a Redis example only, if you want to add redis example, slots need to be adjusted It needs to be half of the slots correspond to the new Redis, choose yo right key migration
how to find the slot corresponding key, Codis SLOTSSCAN provides instructions for scanning all the key slot to be migrated and then migrate
If there is a need to migrate the access time slot will immediately migrate, and then let the client to access the new redis instance, a single key will be migrated after the first completely removed from the old instance
4, automatic equalization
Codis would be more in the system observed when the idle slot corresponding to the number of instances of each Redis, if the unbalance is automatically migrate
5, Codis cost
due Redis Key scattered in different instances, and therefore does not support transactions, the rename operation key are no longer two a Redis example can not be completed
due to the presence of the cluster will migrate, and therefore should not be too large value (not more than 1MB), Caton prevent migration occurs
increases proxy as an intermediate layer, than a single Redis large overhead on the network
6, mget instruction operation of the process
acquiring a plurality of bulk mget key (redis may be distributed in multiple instances), CODIS key strategy is to break up according to example allocated packet, then turn call mget

Guess you like

Origin blog.csdn.net/alvin_666/article/details/89737671