tokyo cabinet : 下载 wget http://1978th.net/tokyocabinet/tokyocabinet-1.4.36.tar.gz
依靠 包:
zlib: sudo apt-get install zlib1g-dev
bzip2: sudo apt-get install libbz2-dev
安装:
tar zxvf tokyocabinet-1.4.36.tar.gz
cd tokyocabinet-1.4.36
./configure
make
sudo make install
tokyo tyrant : 下载 wget http://1978th.net/tokyotyrant/tokyotyrant-1.1.37.tar.gz
安装:
tar zxvf tokyotyrant-1.1.37.tar.gz
cd tokyotyrant-1.1.37
./configure
make
sudo make install
ttserver -dmn -pid /home/mk2/ttserver/tt.pid -log /home/mk2/ttserver/tt.log -le -ulog /home/mk2/ttserver/ -ulim 128m /home/mk2/ttserver/data.tcb#bnum=100000
这里需要改为:
完成后可在usr/local/bin里启动 ttservctl start启动默认安装的服务,本机端口1978。
可以马上用ps -ef | grep ttserver 语句看一下启动服务的情况。
# tcb: b+ tree格式, 在内存中缓存最热门的10w条查询
运行pytyrant.py , 代码在: http://code.google.com/p/pytyrant/source/browse/trunk/pytyrant.py
没有任 何异常输出? 那就成功了!!!
benchmark.py:
!/usr/bin/envpython
测试输 出:
one threads
set_benchmark
memcache 100000 set: 10.5929949284
tokyo tyrant 100000 set: 9.69395589828
--------------------------------------------------------------------------------
get_benchmark
memcache 100000 get: 10.9661550522
tokyo tyrant 100000 get: 11.5382130146
--------------------------------------------------------------------------------
get_miss_benchmark
memcache 100000 get miss: 9.16992592812
tokyo tyrant 100000 get miss: 10.9790480137
--------------------------------------------------------------------------------
set_benchmark: 20 threads, 100000 times
thread 5 memcache 5000 set: 9.16596198082
thread 1 memcache 5000 set: 9.2044479847
thread 2 memcache 5000 set: 9.5196750164
thread 10 memcache 5000 set: 9.78295493126
thread 9 memcache 5000 set: 10.1644408703
thread 8 memcache 5000 set: 10.2827599049
thread 3 memcache 5000 set: 10.3494279385
thread 18 memcache 5000 set: 10.5312678814
thread 14 memcache 5000 set: 10.5295097828
thread 13 memcache 5000 set: 10.5583910942
thread 6 memcache 5000 set: 10.64412117
thread 11 memcache 5000 set: 10.7909929752
thread 7 memcache 5000 set: 10.8441131115
thread 12 memcache 5000 set: 10.9090180397
thread 16 memcache 5000 set: 10.9221849442
thread 4 memcache 5000 set: 10.9808840752
thread 17 memcache 5000 set: 11.0821311474
thread 0 memcache 5000 set: 11.135324955
thread 15 memcache 5000 set: 11.2227208614
thread 19 memcache 5000 set: 11.4754559994
thread 2 tokyo tyrant 5000 set: 7.76640605927
thread 5 tokyo tyrant 5000 set: 8.22156119347
thread 1 tokyo tyrant 5000 set: 8.40494203568
thread 10 tokyo tyrant 5000 set: 7.92209196091
thread 9 tokyo tyrant 5000 set: 7.55454802513
thread 18 tokyo tyrant 5000 set: 7.27255797386
thread 8 tokyo tyrant 5000 set: 7.63895893097
thread 11 tokyo tyrant 5000 set: 7.13767504692
thread 13 tokyo tyrant 5000 set: 7.42961502075
thread 14 tokyo tyrant 5000 set: 7.43208909035
thread 6 tokyo tyrant 5000 set: 7.3564889431
thread 15 tokyo tyrant 5000 set: 6.79607892036
thread 17 tokyo tyrant 5000 set: 6.93887209892
thread 3 tokyo tyrant 5000 set: 7.68552422523
thread 12 tokyo tyrant 5000 set: 7.12319302559
thread 16 tokyo tyrant 5000 set: 7.10764598846
thread 0 tokyo tyrant 5000 set: 6.90239214897
thread 7 tokyo tyrant 5000 set: 7.22372317314
thread 4 tokyo tyrant 5000 set: 7.10077404976
thread 19 tokyo tyrant 5000 set: 6.64217996597
--------------------------------------------------------------------------------
get_benchmark: 20 threads, 100000 times
thread 6 memcache 5000 get: 8.76900911331
thread 18 memcache 5000 get: 8.84009003639
thread 17 memcache 5000 get: 8.86155486107
thread 5 memcache 5000 get: 8.91267108917
thread 13 memcache 5000 get: 8.92148303986
thread 0 memcache 5000 get: 8.98046302795
thread 19 memcache 5000 get: 8.98061203957
thread 16 memcache 5000 get: 8.99304008484
thread 11 memcache 5000 get: 9.07233214378
thread 1 memcache 5000 get: 9.09262895584
thread 14 memcache 5000 get: 9.11016702652
thread 4 memcache 5000 get: 9.11597895622
thread 3 memcache 5000 get: 9.1481218338
thread 12 memcache 5000 get: 9.20062994957
thread 10 memcache 5000 get: 9.2384750843
thread 2 memcache 5000 get: 9.27785277367
thread 8 memcache 5000 get: 9.27573204041
thread 9 memcache 5000 get: 9.32341504097
thread 7 memcache 5000 get: 9.40595293045
thread 15 memcache 5000 get: 9.44804811478
thread 6 tokyo tyrant 5000 get: 6.73215508461
thread 0 tokyo tyrant 5000 get: 6.55519604683
thread 17 tokyo tyrant 5000 get: 6.68555307388
thread 5 tokyo tyrant 5000 get: 6.64170980453
thread 11 tokyo tyrant 5000 get: 6.53203821182
thread 12 tokyo tyrant 5000 get: 6.41466784477
thread 4 tokyo tyrant 5000 get: 6.51224589348
thread 2 tokyo tyrant 5000 get: 6.35708498955
thread 14 tokyo tyrant 5000 get: 6.54695796967
thread 19 tokyo tyrant 5000 get: 6.67935991287
thread 16 tokyo tyrant 5000 get: 6.67978215218
thread 18 tokyo tyrant 5000 get: 6.83982586861
thread 13 tokyo tyrant 5000 get: 6.78410601616
thread 3 tokyo tyrant 5000 get: 6.55975389481
thread 9 tokyo tyrant 5000 get: 6.38529014587
thread 8 tokyo tyrant 5000 get: 6.4428050518
thread 7 tokyo tyrant 5000 get: 6.31911993027
thread 10 tokyo tyrant 5000 get: 6.496737957
thread 15 tokyo tyrant 5000 get: 6.28649902344
thread 1 tokyo tyrant 5000 get: 6.65115785599
--------------------------------------------------------------------------------
get_miss_benchmark: 20 threads, 100000 times
thread 10 memcache 5000 get miss: 7.05730509758
thread 9 memcache 5000 get miss: 7.05415606499
thread 3 memcache 5000 get miss: 7.1769759655
thread 16 memcache 5000 get miss: 7.19843101501
thread 13 memcache 5000 get miss: 7.26215600967
thread 7 memcache 5000 get miss: 7.26590704918
thread 19 memcache 5000 get miss: 7.27665185928
thread 12 memcache 5000 get miss: 7.35561084747
thread 17 memcache 5000 get miss: 7.46251511574
thread 18 memcache 5000 get miss: 7.48763084412
thread 14 memcache 5000 get miss: 7.50556397438
thread 5 memcache 5000 get miss: 7.57047796249
thread 4 memcache 5000 get miss: 7.56979203224
thread 1 memcache 5000 get miss: 7.61345601082
thread 11 memcache 5000 get miss: 7.60594892502
thread 6 memcache 5000 get miss: 7.63839101791
thread 2 memcache 5000 get miss: 7.65122389793
thread 0 memcache 5000 get miss: 7.70662999153
thread 8 memcache 5000 get miss: 7.72461605072
thread 15 memcache 5000 get miss: 7.73385190964
thread 9 tokyo tyrant 5000 get miss: 6.74626517296
thread 3 tokyo tyrant 5000 get miss: 6.66942286491
thread 10 tokyo tyrant 5000 get miss: 6.8257830143
thread 16 tokyo tyrant 5000 get miss: 6.69402313232
thread 13 tokyo tyrant 5000 get miss: 6.63183093071
thread 12 tokyo tyrant 5000 get miss: 6.5411028862
thread 7 tokyo tyrant 5000 get miss: 6.66564011574
thread 19 tokyo tyrant 5000 get miss: 6.70229697227
thread 17 tokyo tyrant 5000 get miss: 6.54302000999
thread 4 tokyo tyrant 5000 get miss: 6.44842004776
thread 1 tokyo tyrant 5000 get miss: 6.44668984413
thread 14 tokyo tyrant 5000 get miss: 6.57335805893
thread 18 tokyo tyrant 5000 get miss: 6.58749604225
thread 5 tokyo tyrant 5000 get miss: 6.51425504684
thread 15 tokyo tyrant 5000 get miss: 6.35351395607
thread 11 tokyo tyrant 5000 get miss: 6.48207402229
thread 8 tokyo tyrant 5000 get miss: 6.37408590317
thread 0 tokyo tyrant 5000 get miss: 6.39541912079
thread 6 tokyo tyrant 5000 get miss: 6.46143507957
thread 2 tokyo tyrant 5000 get miss: 6.46356105804
由上面 输出可以看到,tokyo tyrant并不比memcache性能差太多(可能是memcache.py有性能问题)。
在多线 (进)程环境下,memcache表现并不好,而tokyo tyrant有明显的性能提高。