Neo4J Write: CPU at 100% when there is a lot of write

931 Views Asked by At

I ran around 3k write queries in around 1 minutes, the CPU hits 100%. Here is the jstack log: jstack when CPU at 100%.

Can anyone tell me what is going on from the jstack logs,so that I can optimize my writes?

I am using Node.js Neo4J client(runs on m3.xlarge AWS instance) to write my changes.

Thank you.

1

There are 1 best solutions below

6
On BEST ANSWER

Your trace looks ok, it is just a few threads busy reading things.

It could be garbage collection induced CPU spikes or something else that's not visible in the stacks.

Can you share the (type of) statements you run?

For your queries:

  1. only merge on one label
  2. make sure to have an index / constraint for each :Label(property) that you merge or match on
  3. if you match on a property always have a :Label and an index for it:

you might also want to add a generic :Node label if you are working with generic guids all the time

create index on :Node(guid);
create index on :Book(id); 


'MERGE (u:Node{guid:{guid}})',
            'SET u.name={name}, u:Book'

'MERGE (u:Node {guid:{guid}})',
'SET u.name={name}, u.sub_type={sub_type}, u:Home:Area'

// are you sure you mean :Book(id) not :Book(guid) ?
'MATCH ( e:Node {guid:{guid}} ), (m:Book{id:{id}})',
'MERGE (e)<-[r:MEMBER]-(m)',
'return r'