Configure the garbage collector for Message Processors

In Edge for Private Cloud 4.54.00 (which runs on Java 21), the Message Processor uses the Garbage-First Garbage Collector (G1GC) by default. This document describes how to configure and verify garbage collection settings on the Message Processor.

Customize the garbage collector on the Message Processors

This section outlines the procedure for configuring alternative Garbage Collection (GC) settings on the Edge Message Processor. You manage GC parameters by updating the GC properties on the Message Processor. To adjust any configuration property, use the token syntax defined in How to configure Edge.

To modify GC settings on the Message Processors, perform the following steps:

  1. Check the GC property
  2. Modify GC on the Message Processors

Check the GC property

The following steps describe how to check the configured GC properties:

  1. Search for the GC properties in the Message Processor source directory /opt/apigee/edge-message-processor/source using the following command:
    grep -riE "useG1GC|useZGC|useStringDeduplication" /opt/apigee/edge-message-processor/source
    
  2. Confirm that the output of this command shows the configuration of the GC properties for the Message Processor:
    /opt/apigee/edge-message-processor/source/conf/system.properties:useG1GC={T}conf_system_useG1GC{/T}
    /opt/apigee/edge-message-processor/source/conf/system.properties:useZGC={T}conf_system_useZGC{/T}
    /opt/apigee/edge-message-processor/source/conf/system.properties:useStringDeduplication={T}conf_system_useStringDeduplication{/T}

    The string between the {T}{/T} tags is the name of the property that you can set in the Message Processor's .properties file.

Modify GC on the Message Processors

The following steps describe how to modify GC settings on the Apigee Message Processors:

  1. Open the /opt/apigee/customer/application/message-processor.properties file on the Message Processor machine in an editor. If the file doesn't already exist, create it. For example:
    vi /opt/apigee/customer/application/message-processor.properties
    
  2. Add the desired GC configuration lines based on your target profile:
    • Option A: Use G1GC as the default garbage collector along with some modifications:
      conf_system_useG1GC=true
      conf_system_useStringDeduplication=true
      conf_system_g1gc.g1ReservePercent=15
    • Option B: Enable Generational ZGC (Optional for ultra-low-latency deployments):
      conf_system_useG1GC=false
      conf_system_useZGC=true
      bin_setenv_max_meta_space_size=1024m
    • Option C: Enable a generic GC setting:

      Set bin_setenv_ext_jvm_opts in the component's .properties override file (/opt/apigee/customer/application/message-processor.properties) to configure any generic GC properties, and then restart the component. For example:

      conf_system_useG1GC=false
      conf_system_useZGC=false
      bin_setenv_ext_jvm_opts="-XX:+UseParallelGC"
  3. Save your changes.
  4. Ensure that this properties file is owned by the apigee user. For example:
    chown apigee:apigee /opt/apigee/customer/application/message-processor.properties
    
  5. Restart the Message Processor using the following command:
    /opt/apigee/apigee-service/bin/apigee-service edge-message-processor restart
    
  6. If you have more than one Message Processor, repeat these steps on all the Message Processors.

Update string deduplication

By default, the G1GC configuration sets UseStringDeduplication to true, which optimizes Java heap memory allocation by allowing identical String values to share a single character array. To disable string deduplication, set conf_system_useStringDeduplication=false in /opt/apigee/customer/application/message-processor.properties and restart the Message Processor, as described in Modify GC on the Message Processors.

Verifying GC configuration on the Message Processors

To verify that your GC configuration changes have been applied on the Message Processor:

  1. Search for the GC property in the /opt/apigee/edge-message-processor/conf directory and check that it has been set with the new value. For example:
    grep -riE "useG1GC|useZGC|g1gc\.|useStringDeduplication" /opt/apigee/edge-message-processor/conf
    
  2. Verify that /opt/apigee/edge-message-processor/conf/system.properties reflects your newly configured values. For example, the Apigee Default GC settings are displayed as follows:
    /opt/apigee/edge-message-processor/conf/system.properties:useG1GC=true
    /opt/apigee/edge-message-processor/conf/system.properties:useZGC=false
    /opt/apigee/edge-message-processor/conf/system.properties:g1gc.maxGCPauseMillis=200
    /opt/apigee/edge-message-processor/conf/system.properties:g1gc.initiatingHeapOccupancyPercent=45
    /opt/apigee/edge-message-processor/conf/system.properties:g1gc.g1ReservePercent=15
    /opt/apigee/edge-message-processor/conf/system.properties:useStringDeduplication=true
  3. Verify that the running Message Processor JVM process was started with the expected -XX: flags:
    ps -ef | grep edge-message-processor | grep -E "UseG1GC|UseZGC"
    
    • For Apigee Default G1GC, confirm that the command line includes: -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:InitiatingHeapOccupancyPercent=45 -XX:G1ReservePercent=15 -XX:+UseStringDeduplication -XX:MaxMetaspaceSize=1024m
    • For Generational ZGC, confirm that the command line includes: -XX:+UseZGC -XX:+ZGenerational -XX:MaxMetaspaceSize=1024m
  4. If you still aren't able to configure the GC settings, contact Apigee Edge Support.

What's next?