go-redis icon indicating copy to clipboard operation
go-redis copied to clipboard

Improve connection speed by running fewer commands

Open chayim opened this issue 1 year ago • 8 comments

Today, connecting to a Redis instance, involves running multiple commands, and parsing the response repeatedly, this includes usage such as setinfo, which itself is run twice. The example below illustrates, that it's possible to pass all connection configuration information within a pipeline. In turn, the HELLO call returns the version of Redis, which could perhaps be used later for other things.

This is marked as good-first-issue not because it's necessarily easy to implement, inasmuch as it's a good entrypoint, to learning how connections to redis occur.

127.0.0.1:6379> multi
OK
127.0.0.1:6379(TX)> auth bob smurf
QUEUED
127.0.0.1:6379(TX)> select 5
QUEUED
127.0.0.1:6379[5](TX)> hello 3
QUEUED
127.0.0.1:6379[5](TX)> client setinfo lib-name predis
QUEUED
127.0.0.1:6379[5](TX)>  client setinfo lib-ver 55.5.0
QUEUED
127.0.0.1:6379[5](TX)> client tracking on optin
QUEUED
127.0.0.1:6379[5](TX)> CLIENT caching yes
QUEUED
127.0.0.1:6379[5](TX)> exec
1) OK
2) OK
3) 1# "server" => "redis"
   2# "version" => "7.2.3"
   3# "proto" => (integer) 3
   4# "id" => (integer) 26
   5# "mode" => "standalone"
   6# "role" => "master"
   7# "modules" => (empty array)
4) OK
5) OK
6) OK
7) OK
127.0.0.1:6379[5]> 

chayim avatar Dec 25 '23 09:12 chayim

Hey @chayim, total newbie here, I would love to take this up, but I would require assistance. If you can help me with stating the point and blueprint of how this can be implemented, that would be great.

prabhjotsingh18 avatar Dec 28 '23 09:12 prabhjotsingh18

@prabhjotsingh18 want to give it a go and ping here @ofekshenawa can possibly assist.

chayim avatar Jan 30 '24 13:01 chayim

Sure @chayim, @ofekshenawa if you can guide me where to begin and what concepts I need to familiarise myself with.

prabhjotsingh18 avatar Mar 10 '24 19:03 prabhjotsingh18

@prabhjotsingh18 are you still working on this?

pglushko avatar Apr 04 '24 17:04 pglushko

hey @pglushko , i have no idea how to proceed with the issue, was waiting on @ofekshenawa for direction, if you want you can take up the bug.

prabhjotsingh18 avatar Apr 21 '24 15:04 prabhjotsingh18

@pglushko are you actively working on this task? If not, please let me know. I would love to work on this issue. I would like to know how connections are working in Redis.

subhakundu avatar Jun 09 '24 18:06 subhakundu

@chayim and @ofekshenawa, I am not sure if anyone is working on this issue or not. If not, I would like to work on it to learn. I would like your guidance on where to start.

subhakundu avatar Jun 10 '24 19:06 subhakundu

It seems like this has already been the case since #326 or am I missing something? https://github.com/redis/go-redis/pull/326/files#diff-190fc9ceda3bbdbe723d493b8b99e2b9a0100c7d635bfe9b04246280bef6f67e

KyleKincer avatar Jul 13 '24 23:07 KyleKincer