Is there a way to check how many current connections there are to the Redis database?
const redis = require('redis');
var client = redis.createClient(port, host);
client.on('connect', () => {
//Display how many current connections are to Redis
console.log( numberOfRedisClients );
});
2
Answers
according to redis documentation try this :
the output :
CLIENT LIST returns information and statistics about the client connections server in a mostly human readable format as @babak stated in the answer.
If you just need to get
total number of connections
you may use INFO command.INFO clients
will print something like this andconnected_clients
would be what you are looking for.The following code do the work;