twemproxy-163 supports redis-server failover by communicating with redis-sentinel
twemproxy (pronounced "two-em-proxy"), aka nutcracker is a fast and lightweight proxy for memcached and redis protocol. It was built primarily to reduce the number of connections to the caching servers on the backend. This, together with protocol pipelining and sharding enables you to horizontally scale your distributed caching architecture. http://www.bitstech.net/2016/04/05/supportredishatwemproxy/
We modified the twemproxy to supports redis-server failover by communicating with redis-sentinel^_^
To build twemproxy from source with debug logs enabled and assertions enabled:
$ apt-get install automake
$ apt-get install libtool
$ git clone https://github.com/helifu/twemproxy-163.git
$ cd twemproxy
$ autoreconf -fvi
$ ./configure --enable-debug=full
$ make
$ src/nutcracker -h
Usage: nutcracker [-?hVdDt] [-v verbosity level] [-o output file]
[-c conf file] [-s stats port] [-a stats addr]
[-i stats interval] [-p pid file] [-m mbuf size]
Options:
-h, --help : this help
-V, --version : show version and exit
-t, --test-conf : test configuration for syntax errors and exit
-d, --daemonize : run as a daemon
-D, --describe-stats : print stats description and exit
-v, --verbose=N : set logging level (default: 5, min: 0, max: 11)
-o, --output=S : set logging file (default: stderr)
-c, --conf-file=S : set configuration file (default: conf/nutcracker.yml)
-s, --stats-port=N : set stats monitoring port (default: 22222)
-a, --stats-addr=S : set stats monitoring ip (default: 0.0.0.0)
-i, --stats-interval=N : set stats aggregation interval in msec (default: 30000 msec)
-p, --pid-file=S : set pid file (default: off)
-m, --mbuf-size=N : set size of mbuf chunk in bytes (default: 16384 bytes)
For example:
nutcracker -d -v 5 -o nutcracker.log -c nutcracker.yml -i 10000 -p nutcracker.pid
Twemproxy can be configured through a YAML file specified by the -c or --conf-file command-line argument on process start. The configuration file is used to specify the server pools and the servers within each pool that twemproxy manages. The configuration files parses and understands the following keys:
For example
alpha:
listen: 0.0.0.0:6379
hash: murmur
hash_tag: "{}"
distribution: ketama
timeout: 400
redis_auth: 123456
groups:
- groups_helf_0
- groups_helf_1
- groups_helf_2
- groups_helf_3
sentinel_heartbeat: 2000
sentinels:
- 10.164.97.188:26379 sentinel0
- 10.164.97.189:26379 sentinel1
- 10.164.97.190:26379 sentinel2