Adapting Memory Settings

This page will explain the different memory settings and how these settings affect system performance. Please note that no general memory settings can be given because each system is different. Factors such as user count and implementation complexity should be considered when changing the memory and performance settings.

1 Minimal Requirements

The system should provide at least 4GB of memory and it is mandatory to use a 64Bit Kernel/System.

Overview over memory distribution for the basic Gentics CMS package.

Programm Memory Usage
MySQL 500 MB
Apache + APC 600 MB
JVM + JCS-Cache 1024 MB
Total 2124 MB

2 CMS Tomcat Memory

Additionally the JVM memory settings can be set in the /Node/etc/env.sh file. The -Xmx and -Xms values need to be changed.

/Node/etc/env.sh

export JAVA_OPTS="-Dcom.gentics.contentnode.config.url=http://localhost/.Node/?do=24 -Xmx2560m -Xms2560m -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true"

Please make sure that the string “JAVA_OPTS=”.." also contains the argument “-Djava.awt.headless=true”.

Additional configuration files for the tomcat can be found at the following locations:

  • /Node/etc/tomcat/*.xml
  • /Node/etc/tomcat/*.properties

Please note that 32-bit systems cannot allocate more than 1500MB. On 64-bit systems this limit does not apply.

2.1 JVM Garbage Collector Settings

When using JDK 8, we advise to enable the concurrent mark sweep garbage collector to avoid long duration full garbage collections.


-XX:+UseConcMarkSweepGC

See Virtual Machine Garbage Collection Tuning for more information.

When using JDK 11, we advise to use the default G1 garbage collector.

3 Native File Utils

By default the Gentics CMS NativeFileUtils are enabled. Those utils do support symlinks but require more memory than the JavaFileUtils. Using the NativeFileUtils can also enhance the publish performance because writing files in the filesystem can be achived by creating symlinks or hardlinks.

The fileutils can be set using the fileutils.class setting in the node conf:

/Node/etc/conf.d/node.admin.conf

// @FEATURE hardlink_files: Write files during publishing as hard links instead
// of copying the dbfiles. (This has the same characteristics of copying
// files, but with the performance benefit of symlink_files.)
$FEATURE["hardlink_files"] = true;

$JCONFIG['fileutils.class'] = 'com.gentics.contentnode.publish.NativeFileUtils';
// or
$JCONFIG['fileutils.class'] = 'com.gentics.contentnode.publish.JavaFileUtils';

If you have a 64 bit system, you should also use the 64 bit fileutils:


  # Create a new symlink for libgtx_fileutils_64.so.1.0
  cd /Node/lib
  unlink libgtx_fileutils.so.1.0
  ln -s /Node/.node/modules/content/files/libgtx_fileutils_64.so.1.0 libgtx_fileutils.so.1.0

Possible error messages that are caused by insufficient memory are:


  finalizing filewrite: could not delete pub_old!
  Caused by: java.io.IOException: java.io.IOException: error=12, Cannot allocate memory

4 JCS Cache Size

The node object cache is a Java cache inside of the CMS Tomcat. This cache is used to cache node objects like pages, templates and files. Increasing this memory can help speed up the loading times of pages in preview mode and the publishing process.

/Node/etc/tomcat/gentics/cache.ccf

  jcs.region.gentics-nodeobjects.cacheattributes.MaxObjects=100000

By default the largest cache region is configured to hold 100k objects. An object size of 1kB is assumed for this cache setting. The memory requirements depend upon the existing content. The profiler webapp can be used to create a differential measurement (Full GC, Check Used Memory, Cache Clear). An OutOfMemoryException or stalling garbage collection can occur when the cache region is too large for the heap memory.

4.1 Rule of thumb

Assume 50 kB to 300 kB per object and apply the following formula:

Cache memory usage = 50 kB * object count (Page, Folder, Image, File…) to 300 kB * object count (Page, Folder, Image, File…).

4.2 Individual caches for object types

It is possible to configure individual caches for specific object types. This can be useful to enforce caching of some objects (e.g. folders) for performance reasons. Since folders are frequently used (to display the folder tree and also for checking object permissions), it is recommended to configure a separate cache for folders and make it big enough so that it can hold all existing folders.

/Node/etc/conf.d/node.admin.conf

$NODE_CACHE[10002] = "gentics-nodeobjects-folders";
/Node/etc/tomcat/gentics/cache.ccf

jcs.region.gentics-nodeobjects-folders=
jcs.region.gentics-nodeobjects-folders.cacheattributes.MaxObjects=50000
jcs.region.gentics-nodeobjects-folders.elementattributes.MaxLifeSeconds=86400
jcs.region.gentics-nodeobjects-folders.elementattributes.MaxMemoryIdleTimeSeconds=86400

5 Import Export

The memory usage for the Import/Export feature during transports involving large amounts of data can vary greatly and depends upon the complexity of the implementation of the existing content.

6 Connection Pool

The default max_connections limits for MySQL 5.5/5.6 is 151. We suggest to use 80% of the server connection limit for the Gentics CMS connection pool.

Generally it is a good idea to increase this limit to a value of > 250. This is especially important for production systems with multiple concurrent users.

You can check the connection limit by logging in your MySQL server and execute the following command:


  show variables like 'max_connections';

The pool_whenExhaustedAction setting can have the following values:

  • BLOCK: The connection pool will no longer hand out connections when the limit was reached (Suggested action)
  • GROW: The connection pool will continue growing even if the limit has been reached. (Current default action)
  • FAIL: The connection pool will throw exceptions when the limit was reached.
/Node/etc/conf.d/node.db.conf

  // pool_size_max = 0.8 * max_connections (151)
  $SETTINGS["pool_size_max"] = 120;
  $SETTINGS["pool_whenExhaustedAction"] = "BLOCK";
  // set the maximum wait time to 30 seconds
  $SETTINGS["pool_maxWait"] = 30000;

If the pool_whenExhaustedAction is set to BLOCK, it is important to also set a positive pool_maxWait timeout in order to avoid deadlocks in the CMS.

7 MySQL Memory

The main MySQL settings are innodb_buffer_pool_size and innodb_log_file_size.

gentics_custom.cnf

  // This option will change the way the mysql synchonizes the written data
  // with the disk. Value 2 means that the sync action for the mysql data
  // logfile is invoked once per second.
  innodb_flush_log_at_trx_commit=2
  // Should be 50-80% of main mysql memory
  innodb_buffer_pool_size=2048M
  // Should be 25% of innodb_buffer_pool_size
  innodb_log_file_size=512M
  // Be careful not to set the size of the cache too large. Due to the need
  // for threads to lock the cache during updates, you may see lock contention
  // issues with a very large cache.
  query_cache_size=64M

Please note that changes to innodb_log_file_size require the deletion of the MySQL logfile and a restart of the MySQL server.


  cd /Node/var/mysql
  rm ib_logfile*
  /Node/bin/nodectl restart mysql

Currently the only a 32bit version of the MySQL server is provided in the Gentics CMS package. This version only allows up to 3GB of MySQL memory usage. It is highly encouraged to install a compatible 64bit MySQL server version. Please refer to your linux distribution on how to obtain the MySQL server installation.

8 Apache

The memory usage is defined by the amount of started child processes. On average a child process uses about 5MB of memory.

The settings used are MinSpareServers and MaxClients. The Apache configuration settings are located in /Node/etc/httpd.custom.conf

The location of the configuration files is dependent on what Apache you use

8.1 Debian distribution Apache

All settings can be found in /etc/apache2/apache.conf or other configuration files in /etc/apache2/.

8.2 APC PHP Cache

You can also tune the APC PHP Cache settings. Normally these settings can be left unchanged.

gtx_gcn_custom.ini

[APC]
extension=apc.so
apc.enabled=1
apc.shm_size=128M
apc.ttl=7200
apc.user_ttl=7200
apc.max_file_size=16M

9 Example Configuration

Please note that the following values should only be considered as a guideline for planned memory setups.

9.1 8 GB


  # /Node/etc/tomcat/gentics/cache.ccf - 380k (10k per object)
  jcs.region.gentics-nodeobjects.cacheattributes.MaxObjects=280000

  # /Node/etc/env.sh
  export JAVA_OPTS="-Dcom.gentics.contentnode.config.url=http://localhost/.Node/?do=24 -Xmx3686m -Xms3686m -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseConcMarkSweepGC -XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true"

  # gentics_custom.cnf
  innodb_flush_log_at_trx_commit=2
  innodb_buffer_pool_size=3276M
  innodb_log_file_size=819M
  query_cache_size=64M
  max_connections=200

  # gtx_gcn_custom.ini
  apc.shm_size=128M

9.2 16 GB


  # /Node/etc/tomcat/gentics/cache.ccf - 780k (10kb per object)
  jcs.region.gentics-nodeobjects.cacheattributes.MaxObjects=590000

  # /Node/etc/env.sh
  export JAVA_OPTS="-Dcom.gentics.contentnode.config.url=http://localhost/.Node/?do=24 -Xmx7680m -Xms7680m -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseConcMarkSweepGC -XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true"

  # gentics_custom.cnf
  innodb_flush_log_at_trx_commit=2
  innodb_buffer_pool_size=6656M
  innodb_log_file_size=1664M
  query_cache_size=128M
  max_connections=250

  # gtx_gcn_custom.ini
  apc.shm_size=256M

9.3 32 GB


  # /Node/etc/tomcat/gentics/cache.ccf - 1.5 million (10kb per object)
  jcs.region.gentics-nodeobjects.cacheattributes.MaxObjects=1100000

  # /Node/etc/env.sh
  export JAVA_OPTS="-Dcom.gentics.contentnode.config.url=http://localhost/.Node/?do=24 -Xmx14336m -Xms14336m -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseConcMarkSweepGC -XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true"

  # gentics_custom.cnf
  innodb_flush_log_at_trx_commit=2
  innodb_buffer_pool_size=13312M
  innodb_log_file_size=3328M
  query_cache_size=128M
  max_connections=300

  # gtx_gcn_custom.ini
  apc.shm_size=512M

10 Memory Formula

Memory Value Formula/Value
Average Object Size (Pages, Files, Folders, Images..) 10 kB
MySQL Memory Total Memory * 0.4
Java Heap Memory Total Memory * 0.45
JCS Node Object Cache Count (JavaMemory * 0.75) / Average Object Size
Apache + APC Memory 0.5 GB
System Memory 0.5 GB