Skip to content

RedisCluster initialization is too slow, can we skip it or optimize it? #3148

Closed
@willianmrs

Description

@willianmrs

Version: 5.0.1

Platform: Python 3.8, Ubuntu 22.04

Description:

Hello guys, I'm upgrading the library from a very old version, from redis-py-cluster. I notice that when creating the client, for instance:

RedisCluster(
        host=host_configuration["host"],
        port=int(host_configuration["port"]),
        decode_responses=True,
        skip_full_coverage_check=True,
        socket_timeout=timeout,
        socket_connect_timeout=timeout,
        username=host_configuration.get("user"),
        password=host_configuration.get("pass")
    )

the initialization is taking too long because it sends a command INFO to check if the cluster is enabled, references:

  # Make sure cluster mode is enabled on this node
  if bool(r.info().get("cluster_enabled")) is False:
      raise RedisClusterException(
          "Cluster mode is not enabled on this node"
      )
  cluster_slots = str_if_bytes(r.execute_command("CLUSTER SLOTS"))
  startup_nodes_reachable = True

Since my cluster is big, this command is taking too long, that is not a big issue, because it runs only in the initialization, but the problem is that my requests are very fast, we use a pipeline and get so the majority of requests are below 5ms and I wanna configure a timeout for something like 100ms or even 50ms, but since the timeout parameter is configured only in the initialization of the cluster and it is taking a few seconds to initialize, I need to inform a bigger timeout on the constructor.

Saying all that, I have two questions, (1) is it possible to change the timeout after creating the client? If not, we can change the way it validates if the cluster is enabled to a faster command or even skip this validation?

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