Optimizing OrientDB Database Memory

Understanding Embedded OrientDB Database Memory

Nexus Repository Manager 3 embeds several OrientDB databases. These databases utilize what is known as direct memory.

Direct memory is not the same as the more commonly adjusted JVM max heap memory; direct memory is allocated outside of heap. The total memory used by the JVM process will equal the amount allocated for heap plus the amount allocated for direct memory.

The most important thing on tuning is assuring the memory settings are correct. What can make a difference is the right balancing between the heap and the virtual memory used by Memory Mapping, especially on large datasets (GBs, TBs and more) where the in memory cache structures count less than raw IO.

Symptoms that Direct Memory Needs Adjustment

The embedded databases have a built in profiler that actively monitors the used heap and direct memory. When the profiler detects a potential memory optimization log messages will be printed to the nexus.log similar to these:

2017-05-05 22:57:18,268-0400 INFO  [Timer-1] *SYSTEM com.orientechnologies.common.profiler.OAbstractProfiler$MemoryChecker - Database 'analytics' uses 1,726MB/2,048MB of DISKCACHE memory, while Heap is not completely used (usedHeap=2210MB maxHeap=3641MB). To improve performance set maxHeap to 2652MB and DISKCACHE to 3036MB
2017-05-05 22:57:18,268-0400 INFO  [Timer-1] *SYSTEM com.orientechnologies.common.profiler.OAbstractProfiler$MemoryChecker - -> Open server.sh (or server.bat on Windows) and change the following variables: 1) MAXHEAP=-Xmx2652M 2) MAXDISKCACHE=3036
2017-05-05 22:57:18,268-0400 INFO  [Timer-1] *SYSTEM com.orientechnologies.common.profiler.OAbstractProfiler$MemoryChecker - Database 'security' uses 1,726MB/2,048MB of DISKCACHE memory, while Heap is not completely used (usedHeap=2210MB maxHeap=3641MB). To improve performance set maxHeap to 2652MB and DISKCACHE to 3036MB
2017-05-05 22:57:18,268-0400 INFO  [Timer-1] *SYSTEM com.orientechnologies.common.profiler.OAbstractProfiler$MemoryChecker - -> Open server.sh (or server.bat on Windows) and change the following variables: 1) MAXHEAP=-Xmx2652M 2) MAXDISKCACHE=3036
2017-05-05 22:57:18,268-0400 INFO  [Timer-1] *SYSTEM com.orientechnologies.common.profiler.OAbstractProfiler$MemoryChecker - Database 'component' uses 1,726MB/2,048MB of DISKCACHE memory, while Heap is not completely used (usedHeap=2210MB maxHeap=3641MB). To improve performance set maxHeap to 2652MB and DISKCACHE to 3036MB
2017-05-05 22:57:18,268-0400 INFO  [Timer-1] *SYSTEM com.orientechnologies.common.profiler.OAbstractProfiler$MemoryChecker - -> Open server.sh (or server.bat on Windows) and change the following variables: 1) MAXHEAP=-Xmx2652M 2) MAXDISKCACHE=3036
2017-05-05 22:57:18,268-0400 INFO  [Timer-1] *SYSTEM com.orientechnologies.common.profiler.OAbstractProfiler$MemoryChecker - Database 'audit' uses 1,726MB/2,048MB of DISKCACHE memory, while Heap is not completely used (usedHeap=2210MB maxHeap=3641MB). To improve performance set maxHeap to 2652MB and DISKCACHE to 3036MB
2017-05-05 22:57:18,268-0400 INFO  [Timer-1] *SYSTEM com.orientechnologies.common.profiler.OAbstractProfiler$MemoryChecker - -> Open server.sh (or server.bat on Windows) and change the following variables: 1) MAXHEAP=-Xmx2652M 2) MAXDISKCACHE=3036
2017-05-05 22:57:18,268-0400 INFO  [Timer-1] *SYSTEM com.orientechnologies.common.profiler.OAbstractProfiler$MemoryChecker - Database 'config' uses 1,726MB/2,048MB of DISKCACHE memory, while Heap is not completely used (usedHeap=2210MB maxHeap=3641MB). To improve performance set maxHeap to 2652MB and DISKCACHE to 3036MB
2017-05-05 22:57:18,268-0400 INFO  [Timer-1] *SYSTEM com.orientechnologies.common.profiler.OAbstractProfiler$MemoryChecker - -> Open server.sh (or server.bat on Windows) and change the following variables: 1) MAXHEAP=-Xmx2652M 2) MAXDISKCACHE=3036
2017-05-05 22:57:18,268-0400 INFO  [Timer-1] *SYSTEM com.orientechnologies.common.profiler.OAbstractProfiler$MemoryChecker - Database 'accesslog' uses 1,726MB/2,048MB of DISKCACHE memory, while Heap is not completely used (usedHeap=2210MB maxHeap=3641MB). To improve performance set maxHeap to 2652MB and DISKCACHE to 3036MB
2017-05-05 22:57:18,268-0400 INFO  [Timer-1] *SYSTEM com.orientechnologies.common.profiler.OAbstractProfiler$MemoryChecker - -> Open server.sh (or server.bat on Windows) and change the following variables: 1) MAXHEAP=-Xmx2652M 2) MAXDISKCACHE=3036

If you see these types of messages an application memory configuration change may be warranted

CAUTION: The files server.sh / server.bat and variables MAXHEAP / MAXDISKCACHE are not present in Nexus due to the embedded nature of OrientDB - these specific files and variables can be ignored.

Adjusting Database Memory

CAUTION: If the sum of maximum heap and max direct memory is set too high, these settings could cause the OS to swap with significant slow down. Ensure there is plenty of remaining RAM free on the operating system above and beyond the sum of these two values.

In general, follow this procedure if you detect any nexus.log messages similar to the above:

  1. Adjust the maximum direct memory size. Find the log message mentioning the highest recommended DISKCACHE to value. In the example log messages above this would be 3036MB

  2. Set the JVM option -XX:MaxDirectMemorySize equal to the size recommended by the found log message in step 1.
    A. Edit <app-dir>/bin/nexus.vmoptions
    B. Replace the existing line of the format -XX:MaxDirectMemorySize=size[g|G|m|M|k|K]
    C. Using the example value above, the new line would look like
    -XX:MaxDirectMemorySize=3036M
  3. Adjust the JVM heap size. Find the log message mentioning the highest recommended maxHeap to value. In the example log messages above this would be 2652M

  4. Set the JVM options -Xms and -Xmx equal to the value recommended by the found log message in step 3.
    A. Edit <app-dir>/bin/nexus.vmoptions
    B. Replace the existing lines of the format -Xmssize[g|G|m|M|k|K] and -Xmxsize[g|G|m|M|k|K]
    C. Using the example value above, the new line would look like
    -Xms2652M
    -Xmx2652M
  5. Restart repository manager for the changes to take effect.

  6. If the log messages re-appear, repeat steps 1-5.
Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk