【Azure Redis 缓存 Azure Cache For Redis】使用Redis自带redis-benchmark.exe命令测试Azure Redis的性能
问题描述
关于Azure Redis的性能问题,在官方文档中,可以查看到不同层级Redis的最大连接数,每秒处理请求的性能。
基本缓存和标准缓存
|
|||||
高级缓存
|
|||||
[tr] 标准缓存大小 | 兆位/秒(Mb/秒)/兆字节/秒(MB/秒) | 非 SSL 请求数/秒 (RPS) | SSL 请求数/秒 (RPS) | C0 | 250 MB | 共享 | 100/12.5 | 15,000 | 7,500 | [/tr]
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 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个请求。
在本机中运行redis-benchmark命令测试:
同时,我们也可以使用-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客户端信息
- 下载stunnel.exe
- 启动并配置redis-cli连接 (https://docs.azure.cn/zh-cn/azure-cache-for-redis/cache-how-to-redis-cli-tool#enable-access-for-redis-cliexe)
- 使用redis-cli确认是否已经连接
- 如能成功访问到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 10.00% <= 198 milliseconds ====== PING_BULK ====== 10.00% <= 198 milliseconds ====== SET ====== 10.00% <= 198 milliseconds ====== GET ====== 10.00% <= 205 milliseconds ====== INCR ====== 10.00% <= 197 milliseconds ====== LPUSH ====== 10.00% <= 199 milliseconds ====== RPUSH ====== 10.00% <= 197 milliseconds ====== LPOP ====== 10.00% <= 198 milliseconds ====== RPOP ====== 10.00% <= 200 milliseconds ====== SADD ====== 10.00% <= 196 milliseconds ====== SPOP ====== 10.00% <= 203 milliseconds ====== LPUSH (needed to benchmark LRANGE) ====== 10.00% <= 203 milliseconds ====== LRANGE_100 (first 100 elements) ====== 10.00% <= 198 milliseconds ====== LRANGE_300 (first 300 elements) ====== 10.00% <= 196 milliseconds ====== LRANGE_500 (first 450 elements) ====== 10.00% <= 196 milliseconds ====== LRANGE_600 (first 600 elements) ====== 10.00% <= 199 milliseconds ====== MSET (10 keys) ====== 10.00% <= 202 milliseconds |
C:\redis>redis-benchmark.exe -a **youraccesskey** -c 10 -n 10 -p 6380 10.00% <= 597 milliseconds ====== PING_BULK ====== 10.00% <= 646 milliseconds ====== SET ====== 10.00% <= 628 milliseconds ====== GET ====== 10.00% <= 618 milliseconds ====== INCR ====== 10.00% <= 612 milliseconds ====== LPUSH ====== 10.00% <= 616 milliseconds ====== RPUSH ====== 10.00% <= 587 milliseconds ====== LPOP ====== 10.00% <= 644 milliseconds ====== RPOP ====== 10.00% <= 687 milliseconds ====== SADD ====== 10.00% <= 636 milliseconds ====== SPOP ====== 10.00% <= 607 milliseconds ====== LPUSH (needed to benchmark LRANGE) ====== 10.00% <= 614 milliseconds ====== LRANGE_100 (first 100 elements) ====== 10.00% <= 573 milliseconds ====== LRANGE_300 (first 300 elements) ====== 10.00% <= 630 milliseconds ====== LRANGE_500 (first 450 elements) ====== 10.00% <= 572 milliseconds ====== LRANGE_600 (first 600 elements) ====== 10.00% <= 566 milliseconds ====== MSET (10 keys) ====== 10.00% <= 606 milliseconds |
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.[/code]
参考资料:
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
- apache 自带 ab.exe 性能测试工具使用
- 使用Redis-benchmark为Redis性能测试
- Redis性能测试——redis-benchmark使用教程
- Redis-benchmark命令测试Redis性能
- Redis性能测试:redis-benchmark的使用
- redis-benchmark-Redis性能测试工具(自带)
- 使用Apache自带的ab命令测试网站性能(小强性能测试培训班学员作品)
- 使用Apache自带的ab命令测试网站性能(小强性能测试培训班学员作品)
- Windows 下使用 KCachegrind/WinCachegrind 和 XDebug 测试php程序性能。
- Azure多磁盘构建RAID-0后,Host-Cache相关性能测试
- 网站压力测试方法- Apache自带的性能测试工具ab的使用
- 使用ab命令测试网站性能
- Redis性能测试工具benchmark简介
- 【Redis】redis-benchmark性能测试
- Apache自带的性能测试工具ab的使用
- redis性能测试(redis-benchmark)
- Azure Redis Cache (3) 在Windows 环境下使用Redis Benchmark
- Redis-benchmark测试Redis性能
- SpringBoot使用Redis做缓存,@Cacheable、@CachePut、@CacheEvict等注解的使用
- 详解Mysql5.7自带的压力测试命令mysqlslap及使用语法