
Temos um problema com Redis em nosso servidor.
primeiro no script PHP nos conectamos ao Redis via tcp:127.0.0.1:6379
porta para armazenamento em cache. neste caso e com netstat -anp |grep 6379 |wc -l
o comando tínhamos cerca de 57.000 conexões e o PHP não conseguiu se conectar ao Redis.
depois disso mudamos tcp
para unixsocket
conexão. tudo parecia bem até descobrirmos que o Redis tem muitas conexões de clientes ideais.
abaixo você pode ver a saída do client list
comando no redis:
id=4369214 addr=/tmp/redis.sock:0 fd=953 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369215 addr=/tmp/redis.sock:0 fd=955 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369216 addr=/tmp/redis.sock:0 fd=1045 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369217 addr=/tmp/redis.sock:0 fd=1056 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369218 addr=/tmp/redis.sock:0 fd=1108 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369219 addr=/tmp/redis.sock:0 fd=1109 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369220 addr=/tmp/redis.sock:0 fd=1110 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369221 addr=/tmp/redis.sock:0 fd=1112 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369222 addr=/tmp/redis.sock:0 fd=1113 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369223 addr=/tmp/redis.sock:0 fd=1114 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369224 addr=/tmp/redis.sock:0 fd=1115 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369225 addr=/tmp/redis.sock:0 fd=1116 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369226 addr=/tmp/redis.sock:0 fd=1117 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369227 addr=/tmp/redis.sock:0 fd=1118 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369228 addr=/tmp/redis.sock:0 fd=1119 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369229 addr=/tmp/redis.sock:0 fd=1120 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369230 addr=/tmp/redis.sock:0 fd=1121 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369231 addr=/tmp/redis.sock:0 fd=1122 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369232 addr=/tmp/redis.sock:0 fd=1123 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369233 addr=/tmp/redis.sock:0 fd=1124 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369234 addr=/tmp/redis.sock:0 fd=1125 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369235 addr=/tmp/redis.sock:0 fd=1126 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369236 addr=/tmp/redis.sock:0 fd=1127 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369237 addr=/tmp/redis.sock:0 fd=1128 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369238 addr=/tmp/redis.sock:0 fd=1129 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369239 addr=/tmp/redis.sock:0 fd=1130 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369240 addr=/tmp/redis.sock:0 fd=1131 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369241 addr=/tmp/redis.sock:0 fd=1132 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369242 addr=/tmp/redis.sock:0 fd=1133 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369243 addr=/tmp/redis.sock:0 fd=1134 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369244 addr=/tmp/redis.sock:0 fd=1135 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
id=4369245 addr=/tmp/redis.sock:0 fd=1136 name= age=0 idle=0 flags=U db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
...
e a saída de info clients
seria:
# Clients
connected_clients:917
client_longest_output_list:2
client_biggest_input_buf:0
blocked_clients:0
Nosso uso de cup é alto e o Redis é lento. mesmo depois de desabilitarmos o cache, ainda temos esse problema.
obrigado
Responder1
Redis tem tempo limite em sua configuração. Definir tempo limite dinamicamente usando
config set timeout <valid value in seconds>
O Redis fecha a conexão se estiver inativa pelo tempo configurado. Esse problema ocorre porque seu script PHP não está fechando os soquetes redis no final da solicitação. Acho que o redis fica mais lento porque atinge o limite do descritor de arquivo aberto