Redis cluster
Twemproxy
1
, Environment
Deployment:
Operating system |
CentOS 6.4 |
Redis version |
redis-3.0.7 |
Redis master server |
192.168.1.111 |
Redis Slave server 1 |
192.168.1.112 |
Redis Slave server 2 |
192.168.1.113 |
There are three servers, one COS1 to install Twemproxy, and two other cos2,cos3 to install Redis.
2.
Cos
1.
Cos2 and cos3 installation redi
s
See http://youngcheung.blog.51cto.com/10809015/1773154
3. COS1 installation twemproxy:
3 . 1 Download the installation package for twemproxy (Nutcracker)
[Email protected] ~]# cd/usr/src/[[Email protected]]# wget http://twemproxy.googlecode.com/files/nutcracker-0.2.4.t Ar.gz
3 . 2 Unzip the installation
[[Email protected] ~]# tar XF nutcracker-0.2.4.tar.gz[[email protected] ~]# CD Nutcracker-0.2.4[[email protected] Nutcrac ker-0.2.4]#./configure--prefix=/opt/phpdba/nutcracker-0.2.4[[email protected] nutcracker-0.2.4]# make && Make Install[[email protected] nutcracker-0.2.4]# cp-r conf scripts/opt/phpdba/nutcracker-0.2.4
3 . 3 Configuring environment variables
[Email protected] ~]# cd/etc/profile.d/[[email protected] profile.d]# vim twemproxy.sh #!/bin/sh#set rutcracker environ Mentexport rutcracker_home=/opt/phpdba/nutcracker-0.2.4export path= $RUTCRACKER _home/bin: $PATHsource twemporxy.sh
3 . 4 Modifying the configuration file
[Email protected] ~]# vim/opt/phpdba/nutcracker-0.2.4/conf/nutcracker.yml alpha:listen:127.0.0.1:22121 Hash:fnv1a_ Distribution:ketama auto_eject_hosts:true redis:true server_retry_timeout:2000 server_failure_limit:1 Server S:-192.168.1.112:6379:1 server1-192.168.1.113:6379:1 Server2
3 . 5 Check Syntax
[Email protected] ~]# nutcracker-c/opt/phpdba/nutcracker-0.2.4/conf/nutcracker.yml-tnutcracker:configuration file '/opt/phpdba/nutcracker-0.2.4/conf/nutcracker.yml ' syntax is ok[[email protected] ~]# nutcracker-d-c/opt/phpdba/ Nutcracker-0.2.4/conf/nutcracker.yml
Performance Testing
Here is a simple performance test using Redis 's redis-benchmark , and the test results are as follows :
1. Test:
A. through the twemproxy test:
[[EMAIL PROTECTED] ~]# REDIS-BENCHMARK -H 127.0.0.1 -Q -T SET,GET,INCR ,lpush,lpop,sadd,spop,lpush,lrange -c 100 -p 22121set: 62972.29 requests Per secondget: 87336.24 requests per secondincr: 85034.02 requests per secondlpush: 81699.35 requests per secondlpop: 82987.55 requests per secondsadd: 85034.02 requests per secondspop: 87412.59 requests per secondLPUSH (Needed to benchmark lrange): 80840.74 requests per secondlrange_100 (first 100 elements): 28384.90 requests per secondlrange_ 300 (first 300 elements): 9022.01 requests per secondlrange_500 (first 450 elements): 4810.00 requests per secondlrange_600 (first 600 elements): 3363.04 requests per second
B. through to the back-end redis view :
[Email protected] ~]# redis-cli 127.0.0.1:6379> KEYS) "counter:__rand_int__" 127.0.0.1:6379> [[email protected ] ~]# redis-cli 127.0.0.1:6379> KEYS *) "MyList" 2) "key:__rand_int__"
Discover that our test data is fragmented into two Redis instances.
2 . View key value distributions
[Email protected] ~]# redis-cli info|grep db0db0:keys=1,expires=0,avg_ttl=0[[email protected] ~]# redis-cli Info|grep Db0db0:keys=1,expires=0,avg_ttl=0[[email protected] ~]# [[email protected] ~]# redis-cli info|grep db0db0:keys=2, Expires=0,avg_ttl=0
Test result : twemproxy performance decreased with basic command ; through Twemproxy distribution basic average. The test data is subject to business testing.
Redis Cluster Twemproxy