beansdb的性能测试

最近对beansdb做了一次性能测试,结果性能一般,下面是我的测试过程。

 

1. 启动beansdb server

/duitang/dist/sys/beansdb/bin/beansdb -d -H /duitang/data/test-beansdb

 

2. 往beansdb set 30000条数据

from beansdb.dbclient import Beansdb
import time;
BEANSDB_CONF = ({"127.0.0.1:7900": range(16)}, 16)


fs = Beansdb(*BEANSDB_CONF)
starttime = time.time()

def build():
    f = open('/tmp/test')
    data = f.read()
    for x in xrange(30000):
        key = "HDFS%s"%(x)
        fs.set(key,data)

测试的数据实际是一张大小712k的图片。

 

3. 开始对beansdb随机读测试。

from beansdb.dbclient import Beansdb
import time
import random

BEANSDB_CONF = ({"127.0.0.1:7900": range(16)}, 16)

def test():
    starttime = time.time()
    for x in xrange(100):
        i =random.randint(1, 30000)
        key = "HDFS%s"%(i)
        value = fs.get(key)
        
    endtime = time.time()
    exe_time = (endtime - starttime)*1000
    print '%s ms'%exe_time

if __name__ == "__main__":    
    for x in xrange(20):
        test()  

 

4.测试结果:

服务器普通磁盘:100次读取500ms,平均一次5ms,对于一张700k的图片这个性能算不上好吧。

[admin@server2 libs]$ python testdb.py 
575.555086136 ms
555.697917938 ms
625.766038895 ms
620.676994324 ms
498.275995255 ms
490.942955017 ms
590.165138245 ms
730.442047119 ms
546.756029129 ms
723.293066025 ms
551.966905594 ms
556.042909622 ms
522.061109543 ms
501.409053802 ms
555.064201355 ms
544.654130936 ms
488.253831863 ms
540.575027466 ms
554.152965546 ms
532.576084137 ms

 笔记本SSD:

yunpeng@yunpeng-taobao:/duitang/dist/sys$ python /duitang/dist/app/trunk/java/japa/src/main/webapp/libs/testdb.py
393.790006638 ms
359.507083893 ms
320.909976959 ms
372.398138046 ms
371.335983276 ms
385.787963867 ms
361.010074615 ms
338.36388588 ms
341.284990311 ms
321.836948395 ms
353.931903839 ms
338.07516098 ms
299.274206161 ms
353.310108185 ms
346.406936646 ms
336.650133133 ms
314.879894257 ms
350.219011307 ms
328.777074814 ms
336.888074875 ms

 

 附 beansdb stats

TAT total_items 10001
STAT bytes_read 7175626210
STAT bytes_written 9276565564
STAT threads 16
END
stats 
STAT pid 8335
STAT uptime 979
STAT time 1395413333
STAT version 0.5.3
STAT pointer_size 64
STAT rusage_user 74.416686
STAT rusage_system 30.456369
STAT rusage_minflt 1748290
STAT rusage_majflt 0
STAT rusage_nswap 0
STAT rusage_inblock 0
STAT rusage_oublock 0
STAT rusage_nvcsw 62693
STAT rusage_nivcsw 2516
STAT item_buf_size 4096
STAT curr_connections 1
STAT total_connections 9
STAT connection_structures 3
STAT cmd_get 12930
STAT cmd_set 10001
STAT cmd_delete 0
STAT slow_cmd 2
STAT get_hits 12930
STAT get_misses 0
STAT curr_items 10001
STAT total_items 10001
STAT bytes_read 7175626217
STAT bytes_written 9276566235

 

 

你可能感兴趣的:(BeansDB)