Apsaradb for Redis pipeline and Redispipeline
Redis is a typical TCP Service Based on the C/S model. During the communication between the client and the server, the client usually initiates a request first, and the server executes the corresponding task after receiving the request, finally, send the obtained data or processing results to the client in response. In this process, the client waits for the results returned by the server in blocking mode.
In each request and response process, we have to bear the extra overhead brought about by network transmission. This overhead is usually called the RTT (Round Trip Time ). Now we assume that the RTT for each request and response is 250 milliseconds, and the server can process KB of data in another second. The result is that the server can process up to four requests per second.
How can we optimize this performance problem?
The above Synchronous Response Method is transformed to an asynchronous response method based on the command pipeline. After sending the command, the client does not have to wait for the server to respond immediately, but continues to send the subsequent command. After the command is sent, read the responses of all previous commands at one time. In this way, the RTT overhead in the synchronization mode can be reduced.
If the Redis server finds that the client request is based on a pipeline, after receiving and processing the request, the server will store the response data of each command in the queue and then send it to the client.