redis 请求慢
time redis-cli -h 127.0.0.1 -a 123456 ping
PONG
real 0m2.314s
user 0m0.000s
sys 0m0.002s
不是每次都慢,大概5、6次操作中会出现一次超过秒。以下是redis信息
used_memory:3646312
used_memory_human:3.48M
used_memory_rss:10051584
used_memory_peak:4901784
used_memory_peak_human:4.67M
used_memory_lua:31744
mem_fragmentation_ratio:2.76
mem_allocator:jemalloc-3.2.0
# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
开启redis的错误日志,但是没有发现有执行慢的命令。服务器信息
top - 12:28:07 up 18:18, 6 users, load average: 2.24, 2.17, 2.30
Tasks: 236 total, 1 running, 235 sleeping, 0 stopped, 0 zombie
Cpu(s): 1.0%us, 1.4%sy, 0.0%ni, 87.6%id, 10.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 8058088k total, 2601592k used, 5456496k free, 731772k buffers
Swap: 16777212k total, 0k used, 16777212k free, 621424k cached
这台服务器是测试机,公司人员也不多,请求量不会大。服务器tcp连接数维持在100以下。
I guess it’s the network transmission delay. The possibility of redis problems is very small.
Use latency to test network latency
redis-cli --latency -h
host
-pport
Open the monitor and check the entry and return time of each command. If everything is normal, you need to consider whether there is network transmission delay
Client sets timeout. If it is not set by default, the probability of occurrence is relatively high. If you use pool to set timeout=0, this kind of problem can be solved.