Causal-cluster-friendly implementation

517 Views Asked by At

I am building an application that uses the native neo4j JavaScript driver. I want to make sure that my code will work if we migrate to a causal cluster.

The online documentation doesn't seem to be clear about how to do this: I notice sparse references to things like "bookmarks" and "reading what you have written", etc. But how it all fits together is unclear.

Can someone please provide a synopsis?

1

There are 1 best solutions below

3
On BEST ANSWER

To use causal cluster you will need to change :

1) the url connection : replace bolt://localhost:7687 by bolt+routing://localhost:7687

This will allow your application to make some LB query to the cluster, and be fault tolerant without doing anything else

2) When you open a new session, you should specified what you will do into this session, ie. READ or WRITE. This will help the driver to choose the good server (ie a core or a replica server). Otherwise it assumes you will do some WRITE operations, and the driver will always choose a core server ...

3) because you will be on a cluster env., there is some lag (some secondes) for the propagation of an update inside the cluster. Or sometimes, you need to read your own writes within two sessions. It's where you will need the bookmark functionality.

Documentation is here : https://neo4j.com/docs/developer-manual/current/drivers/

Cheers.