user2580874
user2580874

Reputation: 139

Neo4j Speed when invoked for the first time

I have a simple jquery which calls a servlet via get and then Neo4j is used to return data in JSON format.

The system is workable after the FIRST query but the very first time it is used the system ins unbelievably slow. This is some kind of initialisation issue. I am using Heroku web hosting.

The code is fairly long so I am not posting now, but are there any known issues regarding the first invocation of Neo4j?

I have done limited testing so far for performance as I had a lot of JSON problems anyway and they only just got resolved.

Summary:

JQuery(LINUX)<--> get (JSON) <---> Neo4j

  1. First Query - response is 10-20 secs
  2. Second Query - time is 2-3 secs
  3. More queries - 2/3 secs.

This is not a one-off; I tested this a few times and always the same pattern comes up.

Upvotes: 2

Views: 92

Answers (1)

Mattias Finn&#233;
Mattias Finn&#233;

Reputation: 3054

This is a normal behaviour of Neo4j where store files are mapped into memory lazily for parts of the files that become hot, and becoming hot requires perhaps thousands of requests to such a part. This is a behaviour that has big stores in mind, whereas for smaller stores it merely gets in the way (why not map the whole thing if it fits in memory?).

Then on top of that is an "object" cache that further optimizes access, that get populated lazily for requested entities.

Using an SSD instead of spinning media will usually speed up the initial non-memory-mapped random access quite a bit, but in your scenario I recognize that's not viable.

There are thoughts on beeing more sensitive to hot parts of the store (i.e. memory map even if not as hot) at the start of a database lifecycle, or more precisely have the heat sensitivity be a function of how much is currently memory mapped versus how much can be mapped at maximum. This has shown to make initial requests much more responsive.

Upvotes: 1

Related Questions