In the recipe Understanding Redis protocol in Chapter 1, Getting Started with Redis we learned that Redis Clients and servers communicate via the RESP protocol. A typical communication process between the client and the server can be viewed as the following:
- The client sends a command to the server
- The server receives the command and puts it in the execution queue (as Redis is a single-threaded execution model)
- The command gets executed
- The server returns the execution result to the client
The entire time of this process is termed as round-trip time (RTT). As we can see, the time for step 2 and step 3 depends on the Redis Server, while the time for step 1 and step 4 totally depends on the network latency between the client and the server. If we need to execute multiple commands, network transmission might take a great amount of time, in comparison...