Our redis configuration has 1 master and 1 slave node with min-slaves-to-write as 0 in both nodes. But the number of TCP connections is around 20000. Is this normal ?
Asked
Active
Viewed 629 times
0
-
min-slaves-to-write won't change the number of TCP connections. It just stops master from accepting commands that change the dataset if it has less than N slaves that are OK. Could you check where did these connections come from? Are they client - server connections or master - slave communication? Also tell us which version of Redis you're running. It could be client that opens a new connection when it sends a command, but doesn't close it once it's done (or when it throws an exception (I'm looking at you Jedis)). Our production server has, on average, 21 TCP connections (with 5 slaves) – Grabusz Dec 09 '19 at 13:58
-
If you think the problem is with clients (redis has a default value of 10000 max clients, so 2 redises can open exactly 20000 connections), you could set maxclients to a lower value and check how it behaves. You can do it via CONFIG SET maxclients N if you don't want to restart the server (although this change will be lost after a restart), or by changing it in the config file – Grabusz Dec 09 '19 at 14:03
-
@Grabusz - We are using redis 4.0.9. The maxclients is set as 4096. One observation is say we have 2 nodes A(master) and B(Slave). The number of connections is around 300 , but if a faliover happens B(Master) and A(slave) then suddenly the TCP connections are increasing to more than 20000 around 28000 seen sometimes. – Cyriac Joseph Dec 10 '19 at 04:40
-
Can you run `ss -pat` and check where these connections come from (if they are from replication or if they come from sentinel)? Also if you could tell me if you're using aof or rdb to save the db, if you're using replication over socket (`repl-diskless-sync` set to `yes`) and how are your running it (are you using Kubernetes or something similar?) – Grabusz Dec 11 '19 at 14:57
-
@Grabusz - We are not using repl-diskless-sync nor kubernetes. The connections are as follows TIME-WAIT 0 0 10.193.158.185:59310 10.193.158.185:5230 TIME-WAIT 0 0 10.193.158.185:53320 10.193.158.185:5230 TIME-WAIT 0 0 10.193.158.185:59842 10.193.158.185:5230 TIME-WAIT 0 0 10.193.158.185:55397 10.193.158.185:5230 5230 is our redis master port and a sentinel running in the same node with port 5220 – Cyriac Joseph Dec 26 '19 at 05:57