neo4j/neo4j-java-driver

[Feature Request] Allow READ operations to hit WRITE members based on configuration on Causal Cluster configuration

Dionakra opened this issue · 2 comments

Information

  • Neo4j version: Community/Enterprise 4.1.1
  • Neo4j Mode: Casual cluster with 1 core 2 read-replica
  • Driver version: Java driver 4.2
  • Operating system: Irrelevant

Actual Behavior

When operating a Neo4J Cluster, the Neo4J Java Driver provides the option to use several methods to send READ Cypher Queries to Neo4J as provided by the Session object, but for READ queries it is recommended to use the session.readTransaction method instead of the session.run method as this one will send the query always to a WRITE member, which are usually fewer in a cluster, and session.readTransaction method will send the Cypher Query to a READ member.

This means that, when using a READ Cypher Query on a 3 member Causal Cluster with 1 core and 2 read replicas, when using session.run the client will always send the query to the WRITE member, leaving the other two idle, while the session.readTransaction will send the query to any of the two replica members, leaving the WRITE member idle. This wouldn't be a problem for a system that can have READs and WRITEs at the same time, but for systems that have way more READ than WRITEs, the driver is forcing the clients to underuse the cluster by 33%.

Because of this, it should be configurable by a setting in the TransactionConfig when running the session.readTransaction method to allow the clients to use the WRITE nodes as READ to ensure the full utilisation of the cluster.

Expected behavior

Neo4J Java Driver should allow to use WRITE members in READ operations as configured by the user, something like this:

TransactionConfig config = TransactionConfig.builder()
                 .withTimeout(Duration.ofSeconds(4))
                 .withMetadata(metadata)
                 .withWritersAsReaders(true)
                 .build();

Hi @Dionakra. Thanks for raising this - we already have this feature on our backlog and expect to introduce this capability at some point. As yet, I can't give you an estimate as to when it will be introduced, though.

Hi @Dionakra.
The server now has the following setting: causal_clustering.cluster_allow_reads_on_leader, which should be compatible with all official drivers.
See the Configuration settings reference in the Operations Manual.