redis - 服务器单核100%问题的排查

现象

今天查看服务器时,mongo内存吃了5G,redis单核也100%了..真是..

排查

引起redis CPU100%的原因有几个

  1. reids连接数过高
  2. 数据持久化引起的阻塞
  3. 主从频繁全量同步
  4. value值过大
  5. redis慢查询

服务器没开持久化,单机运行
排除2 3的可能

我们进redis-cli 看一下info 里面内容很多可以看这里

127.0.0.1:6379> info clients
# Clients
connected_clients:13
client_recent_max_input_buffer:4
client_recent_max_output_buffer:48
blocked_clients:0
tracking_clients:0
clients_in_timeout_table:0
(0.90s)

连接数不高,排除连接数太高的可能

[root@mail ~]# redis-cli -p 6379 --bigkeys -i 0.1

# Scanning the entire keyspace to find biggest keys as well as
# average sizes per key type.  You can use -i 0.1 to sleep 0.1 sec
# per 100 SCAN commands (not usually needed).

[00.00%] Biggest string found so far '"mahua_row_scale37411"' with 6 bytes
[00.00%] Biggest string found so far '"mahua_row_scale34693"' with 7 bytes
[00.00%] Biggest string found so far '"seo_ua_pc_14444"' with 151 bytes
[00.00%] Biggest string found so far '"seo_ua_m_26483"' with 163 bytes
[00.00%] Biggest list   found so far '"td_ip_life_port_118.81.119.196"' with 100 items
[00.01%] Biggest string found so far '"seo_cooike_clean_6721"' with 192 bytes
[00.04%] Biggest string found so far '"mahua_row_jsone6599c6e2c2e96bfd19c7969ec35625b"' with 215 bytes

没有大的value值, 也排除

[root@mail ~]# redis-cli
127.0.0.1:6379> slowlog get 3
1) 1) (integer) 166990785
   2) (integer) 1641266385
   3) (integer) 386244
   4) 1) "keys"
      2) "tdp_*_n_*"
   5) "127.0.0.1:52804"
   6) ""
2) 1) (integer) 166990784
   2) (integer) 1641266385
   3) (integer) 263181
   4) 1) "keys"
      2) "td_user_dot_wait_long_time_*"
   5) "127.0.0.1:52820"
   6) ""
3) 1) (integer) 166990783
   2) (integer) 1641266384
   3) (integer) 301927
   4) 1) "keys"
      2) "tdp3_qiyun_ip_*"
   5) "127.0.0.1:52808"
   6) ""
(0.77s)

看到了慢查询,一个查询居然能达到300ms所以这里的问题是慢查询导致的..优化方向也就有了

上一篇:Android动画效果之Property Animation进阶(属性动画)


下一篇:O . Biggest Number