【Azure Redis 快取 Azure Cache For Redis】使用Redis自帶redis-benchmark.exe命令測試Azure Redis的效能

路邊兩盞燈發表於2020-11-24

問題描述

關於Azure Redis的效能問題,在官方文件中,可以檢視到不同層級Redis的最大連線數,每秒處理請求的效能。

基本快取和標準快取
  • C0 (250 MB) 快取 - 最多支援 256 個連線
  • C1 (1 GB) 快取 - 最多支援 1,000 個連線
  • C2 (2.5 GB) 快取 - 最多支援 2,000 個連線
  • C3 (6 GB) 快取 - 最多支援 5,000 個連線
  • C4 (13 GB) 快取 - 最多支援 10,000 個連線
  • C5 (26 GB) 快取 - 最多支援 15,000 個連線
  • C6 (53 GB) 快取 - 最多支援 20,000 個連線
高階快取
  • P1 (6 GB - 60 GB) - 最多支援 7,500 個連線
  • P2 (13 GB - 130 GB) - 最多支援 15,000 個連線
  • P3 (26 GB - 260 GB) - 最多支援 30,000 個連線
  • P4 (53 GB - 530 GB) - 最多支援 40,000 個連線
標準快取大小     兆位/秒(Mb/秒)/兆位元組/秒(MB/秒) 非 SSL 請求數/秒 (RPS) SSL 請求數/秒 (RPS)
C0 250 MB 共享 100/12.5 15,000 7,500
C1 1 GB 1 500/62.5 38,000 20,720
C2 2.5 GB 2 500/62.5 41,000 37,000
C3 6 GB 4 1000/125 100,000 90,000
C4 13 GB 2 500/62.5 60,000 55,000
C5 26 GB 4 1,000 / 125 102,000 93,000
C6 53 GB 8 2,000 / 250 126,000 120,000
定價層大小CPU 核心數可用頻寬1 KB 值大小1 KB 值大小
高階快取大小   每個分片的 CPU 核心數 兆位/秒(Mb/秒)/兆位元組/秒(MB/秒) 每分片非 SSL 請求數/秒 (RPS) 每分片 SSL 請求數/秒 (RPS)
P1 6 GB 2 1,500 / 187.5 180,000 172,000
P2 13 GB 4 3,000 / 375 350,000 341,000
P3 26 GB 4 3,000 / 375 350,000 341,000
P4 53 GB 8 6,000 / 750 400,000 373,000
P5 120 GB 20 6,000 / 750 400,000 373,000

 

但以上的資料只是官方釋出的資料,如果在排除業務的情況下,如何單獨對Redis伺服器進行測試呢?如果需要驗證Redis的效能,如何來做呢?

答案就是使用redis-benchmark.exe,在Azure Redis的常規問答中,有簡單的提到如何來做效能測試,但只是一句話,一個命令一晃而過。

如何進行基準檢驗和測試快取的效能?

    • 啟用快取診斷,以便可以監視快取的執行狀況。 可以在 Azure 門戶中檢視指標,也可以使用所選的工具下載和檢視這些指標。
    • 可以使用 redis-benchmark.exe 對 Redis 伺服器進行負載測試。
    • 確保負載測試客戶端和 Azure Redis 快取位於同一區域。
    • 使用 redis-cli.exe,並使用 INFO 命令監視快取。
    • 如果負載導致出現大量記憶體碎片,則你應該擴充套件為更大的快取大小。
    • 有關下載 Redis 工具的說明,請參閱如何執行 Redis 命令?部分。

 

 

本章的內容就是從下載Redis-benchmark.exe開始,到使用命令完成測試。

一:下載Redis-benchmark.exe

在Github中找到Redis:https://github.com/microsoftarchive/redis/releases,下載最新的ZIP包並解壓( 如:Redis-x64-3.2.100.zip)

【Azure Redis 快取 Azure Cache For Redis】使用Redis自帶redis-benchmark.exe命令測試Azure Redis的效能

二:使用Azure Reids的訪問金鑰開啟測試

從Azure的Redis門戶中複製出連線字串,把redis name和access key填充到如下命令

redis-benchmark.exe -h **yourcache**.redis.cache.chinacloudapi.cn -a **yourAccesskey** -c 10 -n 10

以上命令只是簡單的發起一輪預設命令的測試(如ping,set,get,pop,push等),-c表示10個併發,-n表示10個請求。

【Azure Redis 快取 Azure Cache For Redis】使用Redis自帶redis-benchmark.exe命令測試Azure Redis的效能

在本機中執行redis-benchmark命令測試:

【Azure Redis 快取 Azure Cache For Redis】使用Redis自帶redis-benchmark.exe命令測試Azure Redis的效能

同時,我們也可以使用-t來指定用於測試的操作,如set,get。參考命令如下:

redis-benchmark.exe -h **yourcache**.redis.cache.chinacloudapi.cn -a **yourAccesskey** -t SET -n 1000000 -d 1024 -P 50

redis-benchmark.exe -h **yourcache**.redis.cache.chinacloudapi.cn -a **yourAccesskey** -t GET -n 1000000 -d 1024 -P 50

如需要使用SSL對Azure Redis進行6380埠的效能測試,則需要先確保本地安裝了stunnel.exe並配置好redis-cli客戶端資訊

【Azure Redis 快取 Azure Cache For Redis】使用Redis自帶redis-benchmark.exe命令測試Azure Redis的效能

  • 使用redis-cli確認是否已經連線

【Azure Redis 快取 Azure Cache For Redis】使用Redis自帶redis-benchmark.exe命令測試Azure Redis的效能

  • 如能成功訪問到6380埠,則可以使用如下命令開始測試

redis-benchmark.exe -a **your access key** -c 10 -n 10 -p 6380

測試的效果對比如下

6379 非SSL測試 6380 SSL測試

C:\redis>redis-benchmark.exe -h yourredisname.redis.cache.chinacloudapi.cn -a **youraccesskey** -c 10 -n 10
====== PING_INLINE ======
10 requests completed in 0.47 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 198 milliseconds
50.00% <= 219 milliseconds
60.00% <= 238 milliseconds
100.00% <= 261 milliseconds
21.46 requests per second

====== PING_BULK ======
10 requests completed in 0.49 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 198 milliseconds
20.00% <= 200 milliseconds
30.00% <= 205 milliseconds
40.00% <= 228 milliseconds
50.00% <= 230 milliseconds
60.00% <= 235 milliseconds
100.00% <= 236 milliseconds
20.62 requests per second

====== SET ======
10 requests completed in 0.46 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 198 milliseconds
20.00% <= 201 milliseconds
30.00% <= 203 milliseconds
40.00% <= 204 milliseconds
50.00% <= 206 milliseconds
80.00% <= 210 milliseconds
90.00% <= 212 milliseconds
100.00% <= 215 milliseconds
21.79 requests per second

====== GET ======
10 requests completed in 0.44 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 205 milliseconds
50.00% <= 218 milliseconds
60.00% <= 222 milliseconds
80.00% <= 223 milliseconds
90.00% <= 224 milliseconds
100.00% <= 228 milliseconds
22.68 requests per second

====== INCR ======
10 requests completed in 0.44 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 197 milliseconds
20.00% <= 203 milliseconds
30.00% <= 205 milliseconds
40.00% <= 216 milliseconds
70.00% <= 218 milliseconds
90.00% <= 227 milliseconds
100.00% <= 233 milliseconds
22.99 requests per second

====== LPUSH ======
10 requests completed in 0.44 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 199 milliseconds
30.00% <= 204 milliseconds
60.00% <= 209 milliseconds
90.00% <= 227 milliseconds
100.00% <= 227 milliseconds
22.68 requests per second

====== RPUSH ======
10 requests completed in 0.43 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 197 milliseconds
40.00% <= 207 milliseconds
50.00% <= 208 milliseconds
60.00% <= 209 milliseconds
90.00% <= 211 milliseconds
100.00% <= 218 milliseconds
23.47 requests per second

====== LPOP ======
10 requests completed in 0.43 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 198 milliseconds
20.00% <= 199 milliseconds
80.00% <= 207 milliseconds
90.00% <= 208 milliseconds
100.00% <= 208 milliseconds
23.42 requests per second

====== RPOP ======
10 requests completed in 0.42 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 200 milliseconds
30.00% <= 201 milliseconds
60.00% <= 202 milliseconds
70.00% <= 207 milliseconds
80.00% <= 209 milliseconds
90.00% <= 211 milliseconds
100.00% <= 211 milliseconds
24.04 requests per second

====== SADD ======
10 requests completed in 0.43 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 196 milliseconds
20.00% <= 197 milliseconds
40.00% <= 199 milliseconds
50.00% <= 200 milliseconds
60.00% <= 203 milliseconds
70.00% <= 204 milliseconds
90.00% <= 210 milliseconds
100.00% <= 218 milliseconds
23.26 requests per second

====== SPOP ======
10 requests completed in 0.41 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 203 milliseconds
20.00% <= 204 milliseconds
50.00% <= 205 milliseconds
60.00% <= 206 milliseconds
90.00% <= 209 milliseconds
100.00% <= 210 milliseconds
24.15 requests per second

====== LPUSH (needed to benchmark LRANGE) ======
10 requests completed in 0.41 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 203 milliseconds
20.00% <= 204 milliseconds
30.00% <= 208 milliseconds
40.00% <= 209 milliseconds
50.00% <= 213 milliseconds
70.00% <= 214 milliseconds
80.00% <= 215 milliseconds
100.00% <= 215 milliseconds
24.15 requests per second

====== LRANGE_100 (first 100 elements) ======
10 requests completed in 0.44 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 198 milliseconds
30.00% <= 199 milliseconds
40.00% <= 200 milliseconds
50.00% <= 201 milliseconds
60.00% <= 210 milliseconds
80.00% <= 211 milliseconds
90.00% <= 212 milliseconds
100.00% <= 212 milliseconds
22.88 requests per second

====== LRANGE_300 (first 300 elements) ======
10 requests completed in 0.45 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 196 milliseconds
20.00% <= 197 milliseconds
40.00% <= 202 milliseconds
50.00% <= 203 milliseconds
60.00% <= 207 milliseconds
80.00% <= 208 milliseconds
90.00% <= 209 milliseconds
100.00% <= 210 milliseconds
22.27 requests per second

====== LRANGE_500 (first 450 elements) ======
10 requests completed in 0.43 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 196 milliseconds
20.00% <= 197 milliseconds
30.00% <= 198 milliseconds
40.00% <= 212 milliseconds
80.00% <= 226 milliseconds
100.00% <= 227 milliseconds
23.15 requests per second

====== LRANGE_600 (first 600 elements) ======
10 requests completed in 0.46 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 199 milliseconds
30.00% <= 223 milliseconds
50.00% <= 225 milliseconds
70.00% <= 229 milliseconds
90.00% <= 232 milliseconds
100.00% <= 242 milliseconds
21.88 requests per second

====== MSET (10 keys) ======
10 requests completed in 0.43 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 202 milliseconds
50.00% <= 217 milliseconds
70.00% <= 219 milliseconds
80.00% <= 228 milliseconds
90.00% <= 233 milliseconds
100.00% <= 234 milliseconds
23.20 requests per second

C:\redis>redis-benchmark.exe -a **youraccesskey** -c 10 -n 10 -p 6380
====== PING_INLINE ======
10 requests completed in 0.88 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 597 milliseconds
20.00% <= 615 milliseconds
30.00% <= 827 milliseconds
40.00% <= 841 milliseconds
50.00% <= 842 milliseconds
80.00% <= 868 milliseconds
90.00% <= 869 milliseconds
100.00% <= 869 milliseconds
11.30 requests per second

====== PING_BULK ======
10 requests completed in 0.96 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 646 milliseconds
20.00% <= 651 milliseconds
30.00% <= 671 milliseconds
40.00% <= 678 milliseconds
50.00% <= 679 milliseconds
60.00% <= 712 milliseconds
70.00% <= 868 milliseconds
80.00% <= 869 milliseconds
90.00% <= 948 milliseconds
100.00% <= 963 milliseconds
10.37 requests per second

====== SET ======
10 requests completed in 0.89 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 628 milliseconds
20.00% <= 629 milliseconds
50.00% <= 632 milliseconds
70.00% <= 633 milliseconds
80.00% <= 851 milliseconds
90.00% <= 865 milliseconds
100.00% <= 887 milliseconds
11.25 requests per second

====== GET ======
10 requests completed in 0.88 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 618 milliseconds
30.00% <= 643 milliseconds
50.00% <= 847 milliseconds
70.00% <= 848 milliseconds
80.00% <= 852 milliseconds
90.00% <= 882 milliseconds
100.00% <= 882 milliseconds
11.33 requests per second

====== INCR ======
10 requests completed in 0.89 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 612 milliseconds
30.00% <= 620 milliseconds
40.00% <= 645 milliseconds
50.00% <= 663 milliseconds
60.00% <= 672 milliseconds
70.00% <= 866 milliseconds
90.00% <= 872 milliseconds
100.00% <= 894 milliseconds
11.17 requests per second

====== LPUSH ======
10 requests completed in 0.93 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 616 milliseconds
20.00% <= 638 milliseconds
30.00% <= 666 milliseconds
40.00% <= 810 milliseconds
50.00% <= 848 milliseconds
60.00% <= 864 milliseconds
70.00% <= 885 milliseconds
90.00% <= 919 milliseconds
100.00% <= 920 milliseconds
10.73 requests per second

====== RPUSH ======
10 requests completed in 0.99 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 587 milliseconds
20.00% <= 611 milliseconds
30.00% <= 623 milliseconds
40.00% <= 627 milliseconds
50.00% <= 676 milliseconds
60.00% <= 806 milliseconds
70.00% <= 807 milliseconds
80.00% <= 827 milliseconds
90.00% <= 913 milliseconds
100.00% <= 971 milliseconds
10.15 requests per second

====== LPOP ======
10 requests completed in 0.88 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 644 milliseconds
30.00% <= 651 milliseconds
60.00% <= 655 milliseconds
70.00% <= 847 milliseconds
90.00% <= 865 milliseconds
100.00% <= 874 milliseconds
11.43 requests per second

====== RPOP ======
10 requests completed in 2.65 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 687 milliseconds
20.00% <= 688 milliseconds
30.00% <= 766 milliseconds
50.00% <= 775 milliseconds
60.00% <= 916 milliseconds
70.00% <= 917 milliseconds
80.00% <= 923 milliseconds
90.00% <= 1576 milliseconds
100.00% <= 2647 milliseconds
3.78 requests per second

====== SADD ======
10 requests completed in 0.98 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 636 milliseconds
20.00% <= 637 milliseconds
40.00% <= 653 milliseconds
50.00% <= 708 milliseconds
70.00% <= 897 milliseconds
80.00% <= 945 milliseconds
90.00% <= 946 milliseconds
100.00% <= 946 milliseconds
10.26 requests per second

====== SPOP ======
10 requests completed in 0.95 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 607 milliseconds
20.00% <= 634 milliseconds
30.00% <= 661 milliseconds
40.00% <= 669 milliseconds
50.00% <= 671 milliseconds
60.00% <= 681 milliseconds
70.00% <= 843 milliseconds
80.00% <= 927 milliseconds
100.00% <= 946 milliseconds
10.55 requests per second

====== LPUSH (needed to benchmark LRANGE) ======
10 requests completed in 0.90 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 614 milliseconds
20.00% <= 630 milliseconds
30.00% <= 641 milliseconds
40.00% <= 642 milliseconds
60.00% <= 646 milliseconds
70.00% <= 857 milliseconds
80.00% <= 893 milliseconds
90.00% <= 896 milliseconds
100.00% <= 896 milliseconds
11.05 requests per second

====== LRANGE_100 (first 100 elements) ======
10 requests completed in 0.92 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 573 milliseconds
20.00% <= 605 milliseconds
30.00% <= 606 milliseconds
40.00% <= 624 milliseconds
50.00% <= 634 milliseconds
60.00% <= 671 milliseconds
70.00% <= 800 milliseconds
80.00% <= 804 milliseconds
90.00% <= 805 milliseconds
100.00% <= 897 milliseconds
10.89 requests per second

====== LRANGE_300 (first 300 elements) ======
10 requests completed in 1.00 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 630 milliseconds
20.00% <= 671 milliseconds
40.00% <= 888 milliseconds
70.00% <= 954 milliseconds
80.00% <= 984 milliseconds
90.00% <= 995 milliseconds
100.00% <= 995 milliseconds
10.03 requests per second

====== LRANGE_500 (first 450 elements) ======
10 requests completed in 0.85 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 572 milliseconds
20.00% <= 573 milliseconds
30.00% <= 579 milliseconds
40.00% <= 594 milliseconds
60.00% <= 604 milliseconds
70.00% <= 780 milliseconds
80.00% <= 802 milliseconds
100.00% <= 819 milliseconds
11.72 requests per second

====== LRANGE_600 (first 600 elements) ======
10 requests completed in 0.91 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 566 milliseconds
30.00% <= 629 milliseconds
40.00% <= 634 milliseconds
50.00% <= 812 milliseconds
60.00% <= 836 milliseconds
70.00% <= 851 milliseconds
80.00% <= 867 milliseconds
90.00% <= 873 milliseconds
100.00% <= 880 milliseconds
10.96 requests per second

====== MSET (10 keys) ======
10 requests completed in 0.89 seconds
10 parallel clients
3 bytes payload
keep alive: 1

10.00% <= 606 milliseconds
20.00% <= 619 milliseconds
30.00% <= 625 milliseconds
40.00% <= 667 milliseconds
60.00% <= 851 milliseconds
70.00% <= 875 milliseconds
80.00% <= 878 milliseconds
90.00% <= 886 milliseconds
100.00% <= 888 milliseconds
11.24 requests per second

PS: 在SSL的情況下,每秒處理請求的能下有明顯的下降。

 

三:對Redis Benchmark命令中攜帶引數的介紹

 Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>]


 -h <hostname>      Server hostname (default 127.0.0.1)
 -p <port>          Server port (default 6379)//預設情況下,都使用6379埠,因Azure Redis預設只開通了6380埠,進行SSL通訊。所以需要在Azure Redis門戶中允許6379埠的非SSL訪問。
 -s <socket>        Server socket (overrides host and port)
 -a <password>      Password for Redis Auth
 -c <clients>       Number of parallel connections (default 50)
 -n <requests>      Total number of requests (default 100000)
 -d <size>          Data size of SET/GET value in bytes (default 2)
 --dbnum <db>       SELECT the specified db number (default 0)
 -k <boolean>       1=keep alive 0=reconnect (default 1)
 -r <keyspacelen>   Use random keys for SET/GET/INCR, random values for SADD
  Using this option the benchmark will expand the string __rand_int__
  inside an argument with a 12 digits number in the specified range
  from 0 to keyspacelen-1. The substitution changes every time a command
  is executed. Default tests use this to hit random keys in the
  specified range.
 -P <numreq>        Pipeline <numreq> requests. Default 1 (no pipeline).
 -q                 Quiet. Just show query/sec values
 --csv              Output in CSV format
 -l                 Loop. Run the tests forever
 -t <tests>         Only run the comma separated list of tests. The test
                    names are the same as the ones produced as output.
 -I                 Idle mode. Just open N idle connections and wait.

 

 

參考資料:

Redis Release: https://github.com/microsoftarchive/redis/releases

如何進行基準檢驗和測試快取的效能: https://docs.azure.cn/zh-cn/azure-cache-for-redis/cache-management-faq#how-can-i-benchmark-and-test-the-performance-of-my-cache

How fast is Redis: https://redis.io/topics/benchmarks

相關文章