Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Redis client connection


May 16, 2021 Redis


Table of contents


Redis client connection

Redis receives connections from clients by listening to a TCP port or Unix socket, and when a connection is established, Redis does the following inside:

  • First, the client socket is set to non-blocking mode because Redis uses a non-blocking multiple-use model for network event processing.
  • Then set the property for TCP_NODELAY socket and disable the Nagle algorithm
  • Then create a readable file event to listen for this client socket's data delivery

The maximum number of connections

In Redis 2.4, the maximum number of connections is hardcoded directly into the code, and in version 2.6 the value becomes configurable.

The default value for maxclients is 10000, which you can also modify in redis.conf.

config get maxclients

1) "maxclients"
2) "10000"

Instance

Here are some examples where we set the maximum number of connections to 100,000 when the service starts:

redis-server --maxclients 100000

The client command

S.N. Command Describe
1 CLIENT LIST Returns a list of clients connected to the redis service
2 CLIENT SETNAME Set the name of the current connection
3 CLIENT GETNAME Gets the name of the service set up by the CLIENT SETNAME command
4 CLIENT PAUSE Suspend the client connection, specifying the time to suspend in milliseconds
5 CLIENT KILL Close the client connection