Description
The current default of "open session in view" for Spring Data Neo4j hurts performance in cluster scenarios.
By opening the session on the request, the session will be a general purpose session ("read write") and always go to the leader of a cluster, leaving all followers and read replicas unused. I have written down an analysis of the problem here Spring Data Neo4j, Neo4j-OGM and OSIV.
Neo4j-OGM doesn't have the issue of lazy loading and keeping the session up and running through the request only helps caching inside OGM.
If such a change is unappropriated for 2.3, I would like to see a better warning, for example
logger.warn("spring.data.neo4j.open-in-view is enabled by default."
+ "Therefore, database queries may be performed during view "
+ "rendering. It also prevent's chosing anything else than the leader in a cluster scenario. Explicitly configure "
+ "spring.data.neo4j.open-in-view to disable this warning");
Or, the best might even check if one or more bolt+routing
respectively neo4j://
Uris have been configured and than according to that, choose a sane default.
So, I basically see three options:
- Change the warning to be more drastic or
- Change the default or
- Change the default conditionally when there's one or more
bolt+routing://
orneo4j://
uris or more than onebolt://
URI.
I could implement each one of them, but wanted to hear your opinion on that.