redis自己設計爲單線程服務器,性能自己並不隨着多核而提升,可是會隨着cpu自己而改變,AMD的可能只有Intel一半的性能,Intel是最好的選擇。node
性能會隨着鏈接數的增多而降低,30000大概只有100的一半的性能。redis
https://redis.io/topics/benchmarks
redis官網測試2.6時使用的命令:
該測試由50個同時進行200萬次請求的客戶端完成。
Redis 2.6.14用於全部測試。
使用環回接口執行測試。
使用100萬個密鑰的密鑰空間執行測試。
使用和不使用流水線執行測試(16條命令管道)。
./redis-benchmark -r 1000000 -n 2000000 -t get,set,lpush,lpop -P 16 -q服務器
Intel(R) Xeon(R) CPU E5520 @ 2.27GHz (with pipelining)
$ ./redis-benchmark -r 1000000 -n 2000000 -t get,set,lpush,lpop -P 16 -q
SET: 552028.75 requests per second
GET: 707463.75 requests per second
LPUSH: 767459.75 requests per second
LPOP: 770119.38 requests per second網絡
Intel(R) Xeon(R) CPU E5520 @ 2.27GHz (without pipelining)
$ ./redis-benchmark -r 1000000 -n 2000000 -t get,set,lpush,lpop -q
SET: 122556.53 requests per second
GET: 123601.76 requests per second
LPUSH: 136752.14 requests per second
LPOP: 132424.03 requests per second性能
Linode 2048 instance (with pipelining)
$ ./redis-benchmark -r 1000000 -n 2000000 -t get,set,lpush,lpop -q -P 16
SET: 195503.42 requests per second
GET: 250187.64 requests per second
LPUSH: 230547.55 requests per second
LPOP: 250815.16 requests per second測試
Linode 2048 instance (without pipelining)
$ ./redis-benchmark -r 1000000 -n 2000000 -t get,set,lpush,lpop -q
SET: 35001.75 requests per second
GET: 37481.26 requests per second
LPUSH: 36968.58 requests per second
LPOP: 35186.49 requests per second阿里雲
以上的測試方法來自於redis的官方文檔。可是這種測試方法實際上測試出來的結果並未考慮到生產環境的網絡條件。當咱們使用兩個機器,一個做爲壓力源,另外一個做爲被測試機的時候,性能會出現較大的損失。同時,列出阿里雲提供的redis實例測試方法供參考。線程
建立三臺壓力源服務器(對應阿里的ECS服務器),建立被測試的redis實例。設計
在三臺機器上同時執行如下命令:接口
root@redis-test:/# redis-benchmark -h 192.168.111.106 -p 6379 -t set -c 50 -d 128 -n 25000000 -r 5000000
最終將三臺機器的結果相加,就是總的QPS。
一些結論性的東西:
1.使用三臺服務器做爲壓力源應該是爲了獲得最大的性能數據,當咱們只使用1個壓力源的時候,咱們獲得的結果是遠遠小於三臺壓力源的結果的。
2.此測試方法適用於真實的生產環境,由於會考慮到網絡對性能的影響。