Redis 性能測試工具介紹

以前,也和你們介紹過一些 redis 性能監控指標:Redis性能指標監控!,那麼性能測試也是針對這些指標進行的。html

Redis 包含一個名爲 redis-benchmark 的性能測試工具,它能夠模擬 N 個客戶端同時向 Redis 發送 M 條查詢命令的應用場景(相似於 Apache 的 ab 工具)。redis

圖片

語法格式

Redis 性能測試的基本命令以下工具

  • 注意:該命令是在 redis 的目錄下執行的,而不是 redis 客戶端的內部指令。
  • 注意:redis-benchmark 的測試結果和硬件關聯比較大,尤爲是 CPU 主頻的頻率。
# 工具使用格式
$ 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

image

相關文章
相關標籤/搜索