push-ioredis v1.0.20
push-ioredis
The push-ioredis aims to use redis sentinel(Redis officially) and ioredis to replace redis-failover, which would make our redis cluster high-available and easy to operate.
NOTE THAT THE LIBRARY IS NOT INDEPENDENT, which is a component of push-server. The push-ioredis library relys on:
- redis master-salves
- sentinels that watch on these master-salves
- encapsulated sharding object
Example
node test/t
node test/caller
index.js
Entrance of this library.
lib/redis-failover.js
Implements the redisNodeName-ioredisClient-Dictionary, e.g. "node_x":"related ioredis instance". Create the failover redis obj, which receives the sharding objects as params. Acts as an API.
lib/redisClusterMap.js
Get the node name by the hash value. e.g. return node_1 when receives hash value 4~7.
lib/clientProxy
Implements the sharding logic.
- Generate the hash value of a key
- Find the real redis node according to the hash value
- Use the redis node to do specific operations
config/redisConfig.json
The configuration file for the name of redis nodes and sentinel. The ioredis client get a master node from the sentinel by the name of master-slave pair, the sentinel would guarantee the node that ioredis client gets is a master node.
more redis configuration could be described in redis sentinel.conf, e.g. sentinel_8000.conf
config/redisSharing.json
The configuration file for the cluster sharding. "num" is the number of hash buckets, related to redis-crc, currently is 256(64 nodes, every node has 4 buckets, e.g. if a new inserting key's hashing value is 0~3, it would be inserted in node_0);
test/t.js:
Mainly for testing redis-failover, which is acquiring redis client(master) from sentinel configuration.
test/caller.js:
Exemplify how to use push-ioredis, to testify the failover of redis nodes(sentinel+ioredis) and the logic of sharding(mainly inherits form redis-failover).
test/largeRandomSetGetTest.js:
Test the correctness when high QPS at the same time master-redis down. Currently several master-redis need to be killed manually when this runs.
test/testIndex.js:
Test the redisClient.js
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago