Redis receives a connection from a client by listening to a TCP port or a Unix socket, and when a connection is established, the following actions are performed within Redis:
- First, the client socket is set to non-blocking mode because Redis uses a non-blocking multiplexing model for network event processing.
- Then set the Tcp_nodelay property for this socket, disable the Nagle algorithm
- Then create a readable file event to listen to the data sent by this client socket
Maximum number of connections
In Redis2.4, the maximum number of connections is directly hardcoded in the code, and in version 2.6 this value becomes configurable.
The default value for MaxClients is 10000, and you can modify the value in redis.conf.
- Config get maxclients
- 1) "maxclients"
- 2) "10000"
Instance
The following example sets the maximum number of connections to 100000 when the service starts:
- Redis-Server --maxclients 100000
Client commands
S.N. |
Command |
Description |
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 service name set by the CLIENT SETNAME command |
4 |
CLIENT PAUSE |
Suspends the client connection, specifying the pending time in milliseconds |
5 |
CLIENT KILL |
Close client connections |
Redis Client Connections