Issues with edge creation performance, possibly due to write locks?


(Josh Southerland) #1

Hi Neo4j Community,

We are seeing performance issues with concurrent profile updates from multiple users.. In this scenario we are connecting a user node to other nodes such as skills,interests, disciplines, etc.

I have re-created this scenario in a more minimal way, where I am connecting a user to a random subset (size 10) of possible "skill" nodes (variable number of options) for some number of concurrent requests.

A single update is taking 90ms including session overhead( ~60ms using neo4j driver). Running 50 of those concurrently is taking ~3.5 seconds. That means that they are basically happening sequentially and the last person to get a request in may have to wait 3.5 seconds. In our larger scale (production) system we have more going on in those queries and other validation before hand and have seen much more dramatic slowdowns.

In the test setup, I can increase the number possible skills so that choosing ten random skill nodes to connect for each of the 50 users leads to less chance of users connecting to the same skill nodes. I did this with the hypothesis that this slowdown is write lock-related. If I increase that pool from 12 to 1000 skill nodes, all 50 updates complete in 270ms (vs ~3500ms before) , which means I know that the concurrent requests in my test setup are working and it seems like it might be a matter of write-locks slowing things down. It isn't possible to solve this problem in production in the same way (by creating sparsity in user selections) since we want users to be generating multi-hop connections to each other through common skills/interests/etc.

Here is the query for the benchmark times mentioned above, in our simplified test setup. data.add is a list of uuids that can be used to find the skill nodes we are linking to:

    WITH $props as data
    UNWIND data.add AS dst_uuid
    MATCH (a:Node {uuid: data.userRecord.uuid}) 
    MATCH (b:Node {uuid: dst_uuid}) 
    CREATE (a)-[r:test]->(b)

I have an index on :Node(uuid)

The data being passed in looks like:

  userRecord: { 
    properties: { 
      name: 'Jeremy Turner', 
      email: '' 
    city: 'b8adfcf0-ecd6-4b05-8daf-e3b65179aa6c',
    concepts: [ 'b8adfcf0-ecd6-4b05-8daf-e3b65179aa6c-person' ],
    uuid: '08d83849-63be-4699-960b-47927128e513',
    connections: [ 
  remove: [ 'b540056c-a18d-4fa6-b87c-9c09f172e45e' ],
  add: [ 

^^^ that isn't real data, it was dummy data generated with chance.js

Does it seem like this might be a write-lock issue and that the concurrent query performance issue should then be expected?

If so, is there a standard way of dealing with this issue?

If not, any other suggestions?