Setup Routing Policies for Different User Types To Direct them to Different ServersMar 18, 2024Knowledge
Article DetailsDetailsHelp Details Problem statement There is a Causal Cluster Setup with 3 Cores and 1 Read Replica. There are 2 user groups - OLTP users and OLAP users. OLTP user queries should only go to the 2 Followers and not to the Read Replica. OLAP user queries should only go to the Read Replica and not to any of the Followers. The reason being that OLTP users should not be impacted by the long running queries from OLAP users. How do we achieve this in a Causal Cluster setup? First, set up the multi-dc license. More information can be obtained from the Neo4j Operations Manual - https://neo4j.com/docs/operations-manual/4.4/clustering-advanced/multi-data-center/#multi-dc-licensing Configure the Causal Cluster(CC) with 3 Cores and 1 Read Replica as described in the Neo4j documentation. Then, make the corresponding changes in neo4j.conf file to configure which apps/users should access which instances of the cluster. The below configuration creates a server group with oltp_app and also enables multi-dc license, which is required for server groups. As cores are responsible for routing, it is essential to define all the server policies on the cores. Hence, we need to add. olap_app policies also on the cores. Core 1, Core 2, and Core 3 causal_clustering.server_groups=oltp_app causal_clustering.multi_dc_license=true causal_clustering.load_balancing.plugin=server_policies causal_clustering.load_balancing.config.server_policies.oltp=groups(oltp_app); halt(); causal_clustering.load_balancing.config.server_policies.olap=groups(olap_app); halt(); More documentation on the above config properties can be read here: https://neo4j.com/docs/operations-manual/4.4/clustering-advanced/multi-data-center/load-balancing/#_prerequisite_configuration Now, to service only the OLAP users on Read Replica, configure the read replica as follows: READ_REPLICA causal_clustering.server_groups=olap_app causal_clustering.multi_dc_license=true causal_clustering.load_balancing.plugin=server_policies causal_clustering.load_balancing.config.server_policies.olap=groups(olap_app); halt(); How to use the Driver from the application? The application used by OLTP users will have the driver configuration below: Client Application URL: Driver driver = GraphDatabase.driver( "neo4j://127.0.0.1:7687?policy=oltp" , AuthTokens.basic( "neo4j", "password"), Config.build().withMaxTransactionRetryTime( 15, TimeUnit.SECONDS ).toConfig() ); We specify the server_policy name in the URI - neo4j://127.0.0.1:7687?policy=oltp. When using the above URI, the READ ONLY queries will only be routed to the 2 Followers since the Core server_groups are set as oltp_app. The documentation link for Routing Context is present in the drivers section: https://neo4j.com/docs/java-manual/4.4/client-applications/#java-driver-routing-context Note The Multi-DC feature is only available in Neo4j version 3.2 and above. InformationTitleSetup Routing Policies for Different User Types To Direct them to Different ServersArticle Created Date3/15/2024, 10:55 PMURL Name360007151693-Setup-Routing-Policies-for-Different-User-Types-To-Direct-them-to-Different-ServersLast Modified Date6/25/2024, 4:10 AM