Showing results for 
Search instead for 
Did you mean: 

Neo4j parallel connection using py2neo



I am connecting to NEO4J servers using py2neo by spawning parallel threads from my python client.

Approach 1 : Creating 1 connection per each thread. Works fine but it creates multiple parallel connection to server thereby increasing the total number of open connections.
Approach 2. : Create one connection only and then using the same in all thread while querying the server.

Wanted to understand which of the above approach is more efficient and would have lesser time complexity?
Initial thoughts : Approach 1 will take additional time of creating one connection for each thread and will also leave many open connections leading to load on server whereas approach 2 can solve this but will it then cause sync issues? Like since we have only one connection then multiple calls from multiple threads wont go in parallel. Is that the cases with py2neo connections?

py2neo version - 5.0b1
neo4j server : 4.x

Let me know if any additional details is required from my side.
Thanks for any help in advance.


Graph Voyager

Hi, once I tried this but got an error. I was searching so I discovered that that's impossible because the driver doesn't support it.

That was my experience, I don't know with py2neo.


Node Clone

Hi Modsub,

In my personal experience, I have found that utilizing Approach 1 has worked best for me. I'm unsure if this is the most efficient approach, however I find that creating "1 connection per thread" refreshes the connection most consistently.

Hope this helps!