22.1.1 Configuring On-Heap Limits

The on-heap memory limits for the graph server (PGX) can be configured by updating the systemd configuration file for the PGX service. However, there is a risk of losing the updates to the configuration file, the next time you upgrade the graph server (PGX). Therefore, it is recommended that you provide the on-heap memory configuration in a drop-in file. All directives in the drop-in file are dynamically merged with the directives in the main configuration file (/etc/systemd/system/pgx.service) during the graph server (PGX) startup.

You can perform the following steps to create a drop-in file and configure the on-heap memory size:

  1. Navigate to the /etc/systemd/system/pgx.service.d directory. If the pgx.service.d directory does not exist in the file path, then create one.
  2. Create a drop-in file (.conf file) with any name in /etc/systemd/system/pgx.service.d. Skip this step, if one already exists.
  3. Edit the drop-in file as a root user or with sudo command and add the on-heap memory option in the [Service] section as shown:
    sudo vi /etc/systemd/system/pgx.service.d/setup.conf

    The following example displays the added on-heap memory setting in the setup.conf file:

    [Service]
    # Java on-heap memory setting
    Environment="JAVA_TOOL_OPTIONS=-Xms1G -Xmx2G"

    This option sets the initial heap space to 1GB and allows it to grow up to 2GB.

    The supported options for configuring the on-heap memory are:

    • -Xmx: to set the maximum on-heap size of the JVM.
    • -Xms: to set the initial on-heap size of the JVM.
    • -XX:NewSize: to set the initial size of the young generation
    • -XX:MaxNewSize: to set the maximum size of the young generation

    See the java command documentation for more information on these options.

  4. Add the JAVA_HOME environment variable to ensure that the graph server (PGX) is using the appropriate JDK.
    [Service]
    # JAVA_HOME variable
    Environment=JAVA_HOME=/usr/java/jdk-15.0.1/
    # Java on-heap memory setting
    Environment="JAVA_TOOL_OPTIONS=-Xms1G -Xmx2G"

    Note that the comments begin with # and you can optionally comment any specific option in order to test your configuration.

  5. Reload the PGX service to use the updated settings by running the following command:

    sudo systemctl daemon-reload

  6. Restart the graph server (PGX):

    sudo systemctl restart pgx

  7. Verify that the service restarted with the new memory settings:

    systemctl status pgx

    You may see a similar output:

    ● pgx.service - Oracle Graph In-Memory Server
       Loaded: loaded (/etc/systemd/system/pgx.service; enabled; vendor preset: disabled)
      Drop-In: /etc/systemd/system/pgx.service.d
               └─setup.conf
       Active: active (running) since Wed 2023-04-12 14:50:49 CEST; 5 days ago
     Main PID: 1209 (bash)
       CGroup: /system.slice/pgx.service
               ├─1209 /bin/bash start-server
               └─1469 /usr/java/jdk-11.0.6/bin/java -Dlogback.configurationFile=/etc/oracle/graph/logback-server.xml 
                        -Doracle.jdbc.fanEnabled=false -cp /opt/oracle/graph/pgx/bin/../../pgx/server/lib/activatio...

    Review the Drop-In unit file as shown highlighted in the preceding output. This confirms that systemd found the drop-in file and applied the required customizations.

  8. Finally, use the server-state REST endpoint to confirm the new memory usage. For example:
    BASE_URL=https://localhost:7007
    USERNAME=graph
    PASSWORD=graph
    PGX_RESPONSE=`curl -s -k -X POST -H 'Content-Type: application/json' -d '{"username": "'"${USERNAME}"'", "password": "'"${PASSWORD}"'"}' ${BASE_URL}/auth/token`
    PGX_ACCESS_TOKEN=`echo $PGX_RESPONSE | jq -r '.access_token'`
    curl -s -k -H 'Authorization: Bearer '"${PGX_ACCESS_TOKEN}" $BASE_URL/control/v1/serverState|jq '.entity.memory'

    Note that the preceding example uses the jq tool to fetch and format the output.