Your cart is currently empty!
Author: alien
-
Khóa học miễn phí Redis – Pipelining nhận dự án làm có lương
Redis – Pipelining
Redis is a TCP server and supports request/response protocol. In Redis, a request is accomplished with the following steps −
-
The client sends a query to the server, and reads from the socket, usually in a blocking way, for the server response.
-
The server processes the command and sends the response back to the client.
Meaning of Pipelining
The basic meaning of pipelining is, the client can send multiple requests to the server without waiting for the replies at all, and finally reads the replies in a single step.
Example
To check the Redis pipelining, just start the Redis instance and type the following command in the terminal.
$(echo -en "PINGrn SET tutorial redisrnGET tutorialrnINCR visitorrnINCR visitorrnINCR visitorrn"; sleep 10) | nc localhost 6379 +PONG +OK redis :1 :2 :3
In the above example, we will check Redis connection by using PING command. We have set a string named tutorial with value redis. Later, we get that keys value and increment the visitor number three times. In the result, we can see that all commands are submitted to Redis once, and Redis provides the output of all commands in a single step.
Benefits of Pipelining
The benefit of this technique is a drastically improved protocol performance. The speedup gained by pipelining ranges from a factor of five for connections to localhost up to a factor of at least one hundred over slower internet connections.
Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc
-
Khóa học miễn phí Redis – Client Connection nhận dự án làm có lương
Redis – Client Connection
Redis accepts clients’ connections on the configured listening TCP port and on the Unix socket, if enabled. When a new client connection is accepted, the following operations are performed −
-
The client socket is put in non-blocking state since Redis uses multiplexing and non-blocking I/O.
-
The TCP_NODELAY option is set in order to ensure that we don”t have delays in our connection.
-
A readable file event is created so that Redis is able to collect the client queries as soon as new data is available to be read on the socket.
Maximum Number of Clients
In Redis config (redis.conf), there is a property called maxclients, which describes the maximum number of clients that can connect to Redis.
Following is the basic syntax of command.
config get maxclients 1) "maxclients" 2) "10000"
By default, this property is set to 10000 (depending upon the maximum number of file descriptors limit of OS), although you can change this property.
Example
In the following example, we have set the maximum number of clients to 100000, while starting the server.
redis-server --maxclients 100000
Client Commands
Sr.No | Command | Description |
---|---|---|
1 | CLIENT LIST | Returns the list of clients connected to Redis server |
2 | CLIENT SETNAME | Assigns a name to the current connection |
3 | CLIENT GETNAME | Returns the name of the current connection as set by CLIENT SETNAME |
4 | CLIENT PAUSE | This is a connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds) |
5 | CLIENT KILL | This command closes a given client connection. |
Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc