RedisLabs / redis-cluster-proxy

A proxy for Redis clusters.
GNU Affero General Public License v3.0
990 stars 129 forks source link

A discussion about optimizing the logic of handling request #92

Open xiaobin07 opened 3 years ago

xiaobin07 commented 3 years ago

Now, when a request involved with multi-slot received by proxy, the request would be divided into two types: parent request and child request.

The logic of handling parent request and child request is kind of complex: the child request is inserted after the parent request in the client's request list(client->requests). Then, they're all sended to the backend redis server(redisClusterConnection->requests_to_send, redisClusterConnection->requests_pending). Finally, if everything is ok, the result is collected by the parent request and the final response is returned to client. However, parent request and child request are all stored in the same place, so there're many codes are designed to deal with many special cases, like parent request failed, child request returned and so on.

We plan to optimize the logic. In client's request list(client->requests), we only store the origin request. For multi-slot request, like 'mget a, b, c', we do not store the splited requests. Instead, we split the request into multi child requests and insert these requests into connection's request list. In orgin request, we store the relation between origin request(in client's request list) and child requests(in connection's request list).

Any other idea is welcome to discuss here.