redis-faina 是由Instagram 开发并开源的一个Redis 查询分析小工具。Instagram团队曾经使用PGFouine 来作为其PostgreSQL的查询分析工具,他们觉得Redis也需要一个类似的工具来进行query分析工作,于是开发了redis-faina。
redis-faina 是通过Redis的MONITOR命令来实现的,通过对在Redis上执行的query进行监控,统计出一段时间的query特性。
redis-faina的安装:
# yum install git # git clone https://github.com/facebookarchive/redis-faina.git
redis-faina的使用帮助:
# cd redis-faina/ # ./redis-faina.py -h usage: redis-faina.py [-h] [--prefix-delimiter PREFIX_DELIMITER] [--redis-version REDIS_VERSION] [input] positional arguments: input File to parse; will read from stdin otherwise optional arguments: -h, --help show this help message and exit --prefix-delimiter PREFIX_DELIMITER String to split on for delimiting prefix and rest of key --redis-version REDIS_VERSION Version of the redis server being monitored
redis-faina的两种用法:
1,可以通过管道从stdin读取N条命令
redis-cli -p port MONITOR | head -n <NUMBER OF LINES TO ANALYZE> | ./redis-faina.py [options]
2,也可以从一个文件中读取N条命令
redis-cli -p port MONITOR | head -n <NUMBER OF LINES TO ANALYZE> > /tmp/outfile.txt ./redis-faina.py /tmp/outfile.txt
# redis-cli -p 6381 MONITOR | head -n 10000 | ./redis-faina.py Overall Stats ======================================== Lines Processed 10000 Commands/Sec 274.73 Top Prefixes #按照key的前缀统计 ======================================== testcache-rendsord-lang 1684(16.84%) testcache-inuanGoods-id 1090(10.90%) testcache-riceroup-cat_id 307 (3.07%) testcache-ategorynfo-id 190 (1.90%) testcache-ategoryey-lang 189 (1.89%) testcache-earchtrremplate-id 61 (0.61%) testcache-riceroup-id 15 (0.15%) testcache-otordata-lang 9 (0.09%) Top Keys #请求最频繁的key ======================================== testcache-acebookhareandsave 2373(23.73%) testcache-hippingFee 2198(21.98%) testcache-rendsord-lang:en 1464(14.64%) testcache-ountryurrency 1181(11.81%) testcache-inuanoods 442 (4.42%) testcache-ategoryey-lang: 183 (1.83%) testcache-rendsord-lang:es 124 (1.24%) testcache-inuanoods-id:68 114 (1.14%) Top Commands # 执行最频繁的命令 ======================================== GET 9957(99.57%) AUTH 13 (0.13%) COMMAND 13 (0.13%) SADD 10 (0.10%) info 5 (0.05%) SET 1 (0.01%) Command Time (microsecs) # 命令执行时长 ======================================== Median 2309.0 75% 4959.75 90% 8447.0 99% 18482.0 Heaviest Commands (microsecs) #耗时最多的命令 ======================================== GET 36281717.75 COMMAND 85269.25 SADD 17985.75 info 10698.5 SET 3228.0 AUTH 625.5 Slowest Calls #执行最慢的命令 ======================================== 179962.0 "GET" "testcache-hippingee" 62659.0 "GET" "testcache-romotionullateeduce" 44902.0 "GET" "testcache-hippingee" 40305.25 "GET" "testcache-hippingee" 39559.0 "GET" "testcache-hippingee" 36831.25 "GET" "testcache-hippingee" 33852.0 "GET" "testcache-hippingee" 33501.0 "GET" "testcache-hippingee"
转载于:https://blog.51cto.com/chenql/1958700