A Golang implemented Redis Server and Cluster. Go 语言实现的 Redis 服务器和分布式集群
Godisis a golang implementation of Redis Server, which intents to provide an example of writing a high concurrent middleware using golang.
DELcommand is supported and atomically executed in cluster mode
RenameNXcommand is supported within slot in cluster mode
If you could read Chinese, you can find more details in My Blog.
You can get runnable program in the releases of this repository, which supports Linux and Darwin system.
You could use redis-cli or other redis client to connect godis server, which listens on 0.0.0.0:6399 on default mode.
The program will try to read config file path from environment variable
If environment variable is not set, then the program try to read
redis.confin the working directory.
If there is no such file, then the program will run with default config.
Godis can work in cluster mode, please append following lines to redis.conf file
peers localhost:7379,localhost:7389 // other node in cluster self localhost:6399 // self address
We provide node1.conf and node2.conf for demonstration. use following command line to start a two-node-cluster:
CONFIG=node1.conf ./godis-darwin & CONFIG=node2.conf ./godis-darwin &
Connect to a node in the cluster to access all data in the cluster:
redis-cli -p 6399
System: macOS Catalina 10.15.7
CPU: 2.6GHz 6-Core Intel Core i7
Memory: 16 GB 2667 MHz DDR4
Performance report by redis-benchmark:
PING_INLINE: 87260.03 requests per second PING_BULK: 89206.06 requests per second SET: 85034.02 requests per second GET: 87565.68 requests per second INCR: 91157.70 requests per second LPUSH: 90334.23 requests per second RPUSH: 90334.23 requests per second LPOP: 90334.23 requests per second RPOP: 90415.91 requests per second SADD: 90909.09 requests per second HSET: 84104.29 requests per second SPOP: 82918.74 requests per second LPUSH (needed to benchmark LRANGE): 78247.26 requests per second LRANGE_100 (first 100 elements): 26406.13 requests per second LRANGE_300 (first 300 elements): 11307.10 requests per second LRANGE_500 (first 450 elements): 7968.13 requests per second LRANGE_600 (first 600 elements): 6092.73 requests per second MSET (10 keys): 65487.89 requests per second
WatchCommand and CAS support
If you want to read my code in this repository, here is a simple guidance.
I suggest focusing on the following directories:
This project is licensed under the GPL license.