
Wir haben ein Problem mit Redis auf unserem Server.
Zuerst haben wir im PHP-Skript über tcp:127.0.0.1:6379
den Port eine Verbindung zu Redis zum Zwischenspeichern hergestellt. In diesem Fall und mit netstat -anp |grep 6379 |wc -l
dem Befehl hatten wir ungefähr 57.000 Verbindungen und PHP konnte keine Verbindung zu Redis herstellen.
danach haben wir tcp
zur unixsocket
Verbindung gewechselt. Alles sah in Ordnung aus, bis wir feststellten, dass Redis über viele ideale Client-Verbindungen verfügt.
client list
Unten können Sie die Ausgabe des Befehls auf Redis sehen :
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
...
und die Ausgabe info clients
wäre:
# Clients
connected_clients:917
client_longest_output_list:2
client_biggest_input_buf:0
blocked_clients:0
Unsere Cup-Nutzung ist hoch und Redis ist langsam. Selbst nachdem wir das Caching deaktiviert haben, haben wir immer noch dieses Problem.
Danke
Antwort1
Redis hat ein Timeout in seiner Konfiguration. Stellen Sie das Timeout dynamisch ein mit
config set timeout <valid value in seconds>
Redis schließt die Verbindung, wenn sie für die konfigurierte Zeit inaktiv ist. Dieses Problem tritt auf, weil Ihr PHP-Skript am Ende der Anfrage keine Redis-Sockets schließt. Ich denke, Redis wird langsamer, wenn es das Limit für offene Dateideskriptoren erreicht.