Latest web development tutorials

Redis client connections

Redis to receive connections from clients by listening on a TCP port or Unix socket manner, when a connection is established, Redis some operations internally following:

  • First, the client socket is set to non-blocking mode, because Redis on the network uses a non-blocking event processing multiplex model.
  • Then set the TCP_NODELAY property for the socket, disabling the Nagle algorithm
  • Then create a readable file for monitoring the event the client socket data transmission

Maximum number of connections

In Redis2.4, the maximum number of connections are hard-coded in the code directly inside, and in the 2.6 version of this value becomes configurable.

The default value is maxclients 10000 redis.conf You can also modify the value in this.

config get maxclients

1) "maxclients"
2) "10000"

Examples

The following example we set when the service starts 100000 Maximum number of connections:

redis-server --maxclients 100000

Client commands

SN command description
1 CLIENT LIST Returns a list of clients to connect to the service redis
2 CLIENT SETNAME Sets the name of the current connection
3 CLIENT GETNAME Get the name of the service set by the CLIENT SETNAME command
4 CLIENT PAUSE Pending client connections, specifies the time in milliseconds pending
5 CLIENT KILL Close the client connection