以前,也和你們介紹過一些 redis 性能監控指標:Redis性能指標監控!,那麼性能測試也是針對這些指標進行的。html
Redis 包含一個名爲 redis-benchmark 的性能測試工具,它能夠模擬 N 個客戶端同時向 Redis 發送 M 條查詢命令的應用場景(相似於 Apache 的 ab 工具)。redis
Redis 性能測試的基本命令以下工具
# 工具使用格式 $ redis-benchmark [option] [option value]
Redis 性能測試工具可選參數以下所示post
實例演示性能
如下實例來測試 Redis 性能測試
#同時執行 10000 個請求來檢測性能 $ redis-benchmark -n 10000 -q PING_INLINE: 141043.72 requests per second PING_BULK: 142857.14 requests per second SET: 141442.72 requests per second GET: 145348.83 requests per second INCR: 137362.64 requests per second LPUSH: 145348.83 requests per second LPOP: 146198.83 requests per second SADD: 146198.83 requests per second SPOP: 149253.73 requests per second LPUSH (needed to benchmark LRANGE): 148588.42 requests per second LRANGE_100 (first 100 elements): 58411.21 requests per second LRANGE_300 (first 300 elements): 21195.42 requests per second LRANGE_500 (first 450 elements): 14539.11 requests per second LRANGE_600 (first 600 elements): 10504.20 requests per second MSET (10 keys): 93283.58 requests per second
#使用了多個參數來測試 Redis 性能 # 主機爲127.0.0.1;端口號爲6379;執行的命令爲set/lpush # 請求數爲10000,經過 -q 參數讓結果只顯示每秒執行的請求數 $ redis-benchmark -h 127.0.0.1 -p 6379 -t set,lpush -n 10000 -q SET: 146198.83 requests per second LPUSH: 145560.41 requests per second
做者: Escape 連接: https://www.escapelife.site/p...spa