Skip to content

When I use NewFailoverClusterClient and configure the setting to RouteByLatency=true, the latency increases significantly #2694

Open
@fang2329

Description

@fang2329

Issue tracker is used for reporting bugs and discussing new features. Please use
stackoverflow for supporting issues.

go-redis:v8
redis_server:3.2.9(M-S-S deployed in Wuxi)
redis_client:deployed in shenzhen(The dedicated network connection between Shenzhen and Wuxi has an approximate latency of 20ms)
When I use NewFailoverClusterClient to initialize the redisClient and call get command, it takes approximately 100ms.
However, when I use NewFailoverClient to initialize the redisClient, it takes around 20ms.
I would like to know why there is such a significant difference。In theory, NewFailoverClusterClient should be faster or at least equal to NewFailoverClient.

TestNewFailoverClusterClient: The latency is approximately 100ms

client := redis.NewFailoverClusterClient(&redis.FailoverOptions{ MasterName: "xxx", SentinelAddrs: []string{"xxx1","xxx2","xxx3"}, Password: "", DB: 0, RouteByLatency: true, SlaveOnly: true, }) for { beginTime := time.Now().UnixNano() reply, err := client.Get(context.TODO(), "1131343589").Uint64() cost := (time.Now().UnixNano() - beginTime) / 1e6 fmt.Printf("reply=%v err=%v cost:%v[ms]\n", reply, err, cost) time.Sleep(1 * time.Second) }

TestNewFailoverClient:The latency is approximately 20ms

client := redis.NewFailoverClient(&redis.FailoverOptions{ MasterName: "xxx", SentinelAddrs: []string{"xxx1","xxx2","xxx3"}, Password: "", DB: 0, }) for { beginTime := time.Now().UnixNano() reply, err := client.Get(context.TODO(), "1131343589").Uint64() cost := (time.Now().UnixNano() - beginTime) / 1e6 fmt.Printf("reply=%v err=%v cost:%v[ms]\n", reply, err, cost) time.Sleep(1 * time.Second) }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions