Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
willianmrs opened this issue Feb 15, 2024 · 0 comments
Closed
Labels

Comments

@willianmrs
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants