24.1. Introduction

To gain good performance, these are the things to look into first:

  • Make sure the JVM is not spending too much time performing garbage collection. The goal is to have a large enough heap to make sure that heavy/peak load will not result in so called GC-trashing. Performance can drop as much as two orders of magnitude when GC-trashing happens.
  • Start the JVM with the -server flag and a good sized heap. Having too large heap may also hurt performance so you may have to try some different heap sizes.
  • Use a concurrent garbage collector. We find that -XX:+UseG1GC works well in most use-cases.
  • Give the Neo4j page cache generous amounts of memory. On a dedicated server, there are four big memory allocations you need to balance: the operating system, the Neo4j JVM, the Neo4j page cache and the paging memory for the Lucene indexes.

    • The operating system on a dedicated server can usually make do with 1 to 2 GBs of memory, but the more physical memory the machine has, the more memory the operating system will need.
    • The Neo4j JVM needs enough heap memory for the transaction state and query processing, plus some head-room for the garbage collector. Because the heap memory needs are so workload dependent, it is common to see configurations from 1 GB, up to 32 GBs of heap memory.
    • The Neo4j page cache should preferably have enough memory to keep the entire data set in memory, which is to say, the page cache should be big enough to fit all of the neostore.* files that are not neostore.transaction.db.* files.
    • Lastly, leave enough memory for the operating system page cache, to fit the contents of the index and schema directories, since it will impact index lookup performance if the indexes cannot fit in memory.

See the Section 24.3, “Performance Guide” chapter for more information on how to tune Neo4j.

Configuring Neo4j

When the database is given no configuration, it will try to use reasonable defaults. This is seldom optimal, however, because the database and the JVM have no knowledge about your workload or your performance requirements.

The way you configure Neo4j depend on your mode of deployment; whether you are using the database as an embedded library, or as a server.

See Section 24.7, “Configuration Settings Reference” for further details.