关于redis状态监控和性能调优详解
前言
对于任何应用服务和组件,都需要一套完善可靠谱监控方案。
尤其redis这类敏感的纯内存、高并发和低延时的服务,一套完善的监控告警方案,是精细化运营的前提。
本文主要给大家介绍了关于redis状态监控和性能调优的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。
1、redis-benchmark
redis基准信息,redis服务器性能检测
例如:
检测redis服务器性能,本机6379端口的实例,100个并发连接,100000个请求
redis-benchmark-hlocalhost-p6379-c100-n100000
[root@redis-server~]#redis-benchmark-hlocalhost-p6379-c100-n100000 ======PING_INLINE====== requestscompletedin1.29seconds parallelclients bytespayload keepalive:1 81.97%<=1milliseconds 97.69%<=2milliseconds 99.79%<=3milliseconds 99.94%<=4milliseconds 99.97%<=5milliseconds 100.00%<=5milliseconds 77639.75requestspersecond ======PING_BULK====== requestscompletedin1.49seconds parallelclients bytespayload keepalive:1 73.04%<=1milliseconds 97.46%<=2milliseconds 99.62%<=3milliseconds 99.97%<=4milliseconds 100.00%<=5milliseconds 100.00%<=5milliseconds 67204.30requestspersecond ======SET====== requestscompletedin1.30seconds parallelclients bytespayload keepalive:1 81.09%<=1milliseconds 97.16%<=2milliseconds 99.43%<=3milliseconds 99.75%<=4milliseconds 99.80%<=5milliseconds 99.82%<=7milliseconds 99.83%<=8milliseconds 99.85%<=9milliseconds 99.87%<=10milliseconds 99.89%<=11milliseconds 99.89%<=12milliseconds 99.90%<=13milliseconds 99.90%<=14milliseconds 99.90%<=15milliseconds 99.91%<=16milliseconds 99.93%<=17milliseconds 99.94%<=18milliseconds 99.95%<=19milliseconds 99.96%<=20milliseconds 99.98%<=21milliseconds 99.99%<=22milliseconds 100.00%<=23milliseconds 100.00%<=23milliseconds 76687.12requestspersecond ======GET====== requestscompletedin1.91seconds parallelclients bytespayload keepalive:1 49.74%<=1milliseconds 93.92%<=2milliseconds 99.37%<=3milliseconds 99.95%<=4milliseconds 99.97%<=5milliseconds 99.98%<=6milliseconds 100.00%<=6milliseconds 52273.91requestspersecond ======INCR====== requestscompletedin1.60seconds parallelclients bytespayload keepalive:1 66.32%<=1milliseconds 96.55%<=2milliseconds 99.61%<=3milliseconds 99.96%<=4milliseconds 100.00%<=5milliseconds 62344.14requestspersecond ======LPUSH====== requestscompletedin1.27seconds parallelclients bytespayload keepalive:1 73.84%<=1milliseconds 95.61%<=2milliseconds 99.36%<=3milliseconds 99.96%<=4milliseconds 99.99%<=5milliseconds 100.00%<=5milliseconds 78492.93requestspersecond ======RPUSH====== requestscompletedin1.31seconds parallelclients bytespayload keepalive:1 80.47%<=1milliseconds 96.93%<=2milliseconds 99.56%<=3milliseconds 99.98%<=4milliseconds 100.00%<=5milliseconds 100.00%<=5milliseconds 76103.50requestspersecond ======LPOP====== requestscompletedin1.30seconds parallelclients bytespayload keepalive:1 74.91%<=1milliseconds 95.50%<=2milliseconds 99.29%<=3milliseconds 99.95%<=4milliseconds 100.00%<=5milliseconds 100.00%<=5milliseconds 77101.00requestspersecond ======RPOP====== requestscompletedin1.40seconds parallelclients bytespayload keepalive:1 77.99%<=1milliseconds 97.07%<=2milliseconds 99.61%<=3milliseconds 99.97%<=4milliseconds 99.98%<=5milliseconds 100.00%<=6milliseconds 100.00%<=6milliseconds 71377.59requestspersecond ======SADD====== requestscompletedin1.32seconds parallelclients bytespayload keepalive:1 80.83%<=1milliseconds 97.14%<=2milliseconds 99.57%<=3milliseconds 99.95%<=4milliseconds 100.00%<=5milliseconds 100.00%<=5milliseconds 75757.57requestspersecond ======HSET====== requestscompletedin1.30seconds parallelclients bytespayload keepalive:1 80.25%<=1milliseconds 96.83%<=2milliseconds 99.49%<=3milliseconds 99.97%<=4milliseconds 100.00%<=4milliseconds 76923.08requestspersecond ======SPOP====== requestscompletedin1.48seconds parallelclients bytespayload keepalive:1 73.97%<=1milliseconds 96.91%<=2milliseconds 99.55%<=3milliseconds 99.96%<=4milliseconds 100.00%<=5milliseconds 100.00%<=5milliseconds 67567.57requestspersecond ======LPUSH(neededtobenchmarkLRANGE)====== requestscompletedin1.35seconds parallelclients bytespayload keepalive:1 71.03%<=1milliseconds 95.36%<=2milliseconds 99.29%<=3milliseconds 99.97%<=4milliseconds 100.00%<=5milliseconds 100.00%<=5milliseconds 73909.83requestspersecond ======LRANGE_100(first100elements)====== requestscompletedin2.91seconds parallelclients bytespayload keepalive:1 14.30%<=1milliseconds 80.30%<=2milliseconds 94.42%<=3milliseconds 96.88%<=4milliseconds 98.34%<=5milliseconds 99.39%<=6milliseconds 99.78%<=7milliseconds 99.93%<=8milliseconds 99.97%<=9milliseconds 99.98%<=10milliseconds 100.00%<=11milliseconds 100.00%<=11milliseconds 34317.09requestspersecond ======LRANGE_300(first300elements)====== requestscompletedin5.88seconds parallelclients bytespayload keepalive:1 0.00%<=2milliseconds 85.83%<=3milliseconds 94.17%<=4milliseconds 96.10%<=5milliseconds 97.90%<=6milliseconds 98.68%<=7milliseconds 98.70%<=8milliseconds 99.30%<=9milliseconds 99.49%<=10milliseconds 99.76%<=11milliseconds 99.79%<=12milliseconds 99.83%<=13milliseconds 99.85%<=14milliseconds 99.87%<=15milliseconds 99.89%<=16milliseconds 99.91%<=17milliseconds 99.92%<=19milliseconds 99.93%<=20milliseconds 99.94%<=21milliseconds 99.95%<=22milliseconds 99.96%<=23milliseconds 99.97%<=24milliseconds 99.99%<=25milliseconds 99.99%<=26milliseconds 100.00%<=27milliseconds 17006.80requestspersecond ======LRANGE_500(first450elements)====== requestscompletedin8.16seconds parallelclients bytespayload keepalive:1 0.00%<=2milliseconds 0.01%<=3milliseconds 80.98%<=4milliseconds 90.89%<=5milliseconds 95.60%<=6milliseconds 97.20%<=7milliseconds 98.23%<=8milliseconds 98.53%<=9milliseconds 99.06%<=10milliseconds 99.09%<=11milliseconds 99.46%<=12milliseconds 99.53%<=13milliseconds 99.65%<=14milliseconds 99.75%<=15milliseconds 99.79%<=16milliseconds 99.81%<=17milliseconds 99.82%<=18milliseconds 99.84%<=19milliseconds 99.85%<=20milliseconds 99.86%<=21milliseconds 99.87%<=22milliseconds 99.88%<=23milliseconds 99.89%<=24milliseconds 99.90%<=25milliseconds 99.91%<=26milliseconds 99.93%<=27milliseconds 99.93%<=28milliseconds 99.94%<=29milliseconds 99.95%<=30milliseconds 99.96%<=31milliseconds 99.98%<=32milliseconds 99.98%<=33milliseconds 99.99%<=34milliseconds 99.99%<=35milliseconds 100.00%<=36milliseconds 100.00%<=36milliseconds 12260.91requestspersecond ======LRANGE_600(first600elements)====== requestscompletedin10.15seconds parallelclients bytespayload keepalive:1 0.00%<=3milliseconds 0.01%<=4milliseconds 84.84%<=5milliseconds 93.41%<=6milliseconds 96.43%<=7milliseconds 97.71%<=8milliseconds 97.75%<=9milliseconds 98.32%<=10milliseconds 98.79%<=11milliseconds 99.19%<=12milliseconds 99.22%<=13milliseconds 99.25%<=14milliseconds 99.48%<=15milliseconds 99.56%<=16milliseconds 99.60%<=17milliseconds 99.68%<=18milliseconds 99.74%<=19milliseconds 99.77%<=20milliseconds 99.79%<=21milliseconds 99.82%<=22milliseconds 99.83%<=23milliseconds 99.85%<=24milliseconds 99.86%<=25milliseconds 99.86%<=26milliseconds 99.87%<=27milliseconds 99.88%<=28milliseconds 99.89%<=29milliseconds 99.90%<=30milliseconds 99.90%<=31milliseconds 99.91%<=32milliseconds 99.91%<=33milliseconds 99.92%<=34milliseconds 99.94%<=35milliseconds 99.95%<=36milliseconds 99.95%<=37milliseconds 99.96%<=38milliseconds 99.96%<=39milliseconds 99.96%<=40milliseconds 99.97%<=41milliseconds 99.98%<=42milliseconds 99.98%<=43milliseconds 99.99%<=44milliseconds 99.99%<=45milliseconds 99.99%<=46milliseconds 100.00%<=47milliseconds 100.00%<=47milliseconds 9851.25requestspersecond ======MSET(10keys)====== requestscompletedin1.89seconds parallelclients bytespayload keepalive:1 0.00%<=1milliseconds 75.00%<=2milliseconds 89.85%<=3milliseconds 95.38%<=4milliseconds 98.52%<=5milliseconds 99.34%<=6milliseconds 99.60%<=7milliseconds 99.83%<=8milliseconds 99.98%<=9milliseconds 100.00%<=9milliseconds 52994.17requestspersecond [root@redis-server~]#
2、redis-cli
例1:监控本机6379端口的实例的数据操作,redis的连接及读写操作
redis-cli-hlocalhost-p6379monitor
先开启一个终端1,用于redis监控
[root@redis-server~]#redis-cli-hlocalhost-p6379monitor OK 1504689350.635365[0127.0.0.1:57996]"COMMAND" 1504689361.944610[0127.0.0.1:57996]"set""a""1" 1504689369.782029[0127.0.0.1:57996]"get""a"
然后在开启一个redis终端2进行操作
[root@redis-server~]#redis-cli-p6379 127.0.0.1:6380>seta1 OK 127.0.0.1:6380>geta "1" 127.0.0.1:6380>
可以看到终端2上面进行的数据操作会在终端1上面被记录下来
例2:查询本机redis实例的信息,端口6379
redis-cli-hlocalhost-p6379info
备注:该命令也可以在redis终端里面进行查询
[root@redis-server~]#redis-cli-hlocalhost-p6379info #Server redis_version:3.2.10 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:eae5a0b8746eb6ce redis_mode:standalone os:Linux2.6.32-431.el6.x86_64x86_64 arch_bits:64 multiplexing_api:epoll gcc_version:4.4.7 process_id:6003 run_id:0057d03b2e908ee036c2aa1c3531e8aa051d7468 tcp_port:6379 uptime_in_seconds:159221 uptime_in_days:1 hz:10 lru_clock:11517636 executable:/usr/local/redis/bin/redis-server config_file:/usr/local/redis/conf/redis.conf #Clients connected_clients:1 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 #Memory used_memory:1828104 used_memory_human:1.74M used_memory_rss:4050944 used_memory_rss_human:3.86M used_memory_peak:8439360 used_memory_peak_human:8.05M total_system_memory:1960443904 total_system_memory_human:1.83G used_memory_lua:37888 used_memory_lua_human:37.00K maxmemory:0 maxmemory_human:0B maxmemory_policy:noeviction mem_fragmentation_ratio:2.22 mem_allocator:jemalloc-4.0.3 #Persistence loading:0 rdb_changes_since_last_save:0 rdb_bgsave_in_progress:0 rdb_last_save_time:1504689256 rdb_last_bgsave_status:ok rdb_last_bgsave_time_sec:0 rdb_current_bgsave_time_sec:-1 aof_enabled:0 aof_rewrite_in_progress:0 aof_rewrite_scheduled:0 aof_last_rewrite_time_sec:-1 aof_current_rewrite_time_sec:-1 aof_last_bgrewrite_status:ok aof_last_write_status:ok #Stats total_connections_received:3603 total_commands_processed:3600007 instantaneous_ops_per_sec:0 total_net_input_bytes:192800186 total_net_output_bytes:2634476722 instantaneous_input_kbps:0.00 instantaneous_output_kbps:0.00 rejected_connections:0 sync_full:0 sync_partial_ok:0 sync_partial_err:0 expired_keys:0 evicted_keys:0 keyspace_hits:1000003 keyspace_misses:0 pubsub_channels:0 pubsub_patterns:0 latest_fork_usec:408 migrate_cached_sockets:0 #Replication role:master connected_slaves:0 master_repl_offset:0 repl_backlog_active:0 repl_backlog_size:1048576 repl_backlog_first_byte_offset:0 repl_backlog_histlen:0 #CPU used_cpu_sys:99.45 used_cpu_user:108.88 used_cpu_sys_children:0.01 used_cpu_user_children:0.01 #Cluster cluster_enabled:0 #Keyspace db0:keys=7,expires=0,avg_ttl=0 [root@redis-server~]#
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对毛票票的支持。