Redis和Memcached在Ruby上的性能评测(1)——写入性能
因为memcached只支持String数据类型,所以本文只比较String,redis支持的其他数据类型不做评测,另外关闭了redis持久化特性!因为redis的持久化是另起后台任务进行,所以数据量小的时候不会对测试结果有明显影响。
测试环境:
realusersysmemcached1x SET pipeline10000 times0.937s0.305s0.376sredis1x SET pipeline10000 times1.218s0.517s0.318smemcached10x SET pipeline10000 times1.954s3.311s1.794sredis10x SET pipeline10000 times3.578s5.610s2.229smemcached20x SET pipeline10000 times3.724s6.789s3.547sredis20x SET pipeline10000 times7.024s11.409s4.259smemcached1x SET pipeline100000 times8.434s2.849s3.165sredis1x SET pipeline100000 times10.088s3.315s2.979smemcached10x SET pipeline100000 times15.823s21.094s14.900sredis10x SET pipeline100000 times26.971s20.364s14.673smemcached20x SET pipeline100000 times28.992s42.706s29.173sredis20x SET pipeline100000 times50.189s40.969s27.939smemcached1x SET pipeline1000000 times1m16.988s26.652s27.189sredis1x SET pipeline1000000 times1m39.096s25.127s28.373smemcached10x SET pipeline1000000 times2m30.850s3m22.393s2m26.716sredis10x SET pipeline1000000 times4m19.509s2m46.179s2m18.871smemcached20x SET pipeline1000000 times6m22.883s9m2.995s6m5.845sredis20x SET pipeline1000000 times12m55.556s9m6.064s6m56.633s
结论:
1、memcached的写入性能还是明显要高于redis,特别是多并发的时候,优势更明显!
2、redis server的占用一般在50%左右,memcached server的CPU占用150%左右
3、从总体CPU占用率上来说,redis的优势很明显,4核CPU的使用率没有超过20%,而memcached的CPU一直在50%左右。