All Products
Search
Document Center

Elasticsearch:Configure a garbage collector

Last Updated:Mar 10, 2026

Some Alibaba Cloud Elasticsearch (ES) instances support garbage collector configuration. If your ES instance uses a large heap memory, switch to the G1 garbage collector to improve garbage collection performance. This topic describes how to configure a garbage collector.

Background information

Alibaba Cloud ES versions earlier than 8.x use the CMS garbage collector by default. It triggers when heap memory usage reaches 75%. If an instance has a large heap memory, switch to the G1 garbage collector to optimize performance. ES versions 8.x and later use the G1 garbage collector by default, and its configuration cannot be modified.

Prerequisites

Your instance must meet the following requirements:

  • Version: 6.7.0 to 8.x (earlier than 8.x)

  • Data node memory: 32 GB or more

    How to view instance memory:

    1. Go to the Basic Information page of the target instance.

    2. In the Node Visualization section, view the data node specifications.

    3. Total memory = Single node memory × Number of data nodes

    If the memory requirements are not met, you can upgrade the instance specifications. For more information, see Upgrade a cluster.

Procedure

  1. Log on to the Alibaba Cloud Elasticsearch console.

  2. In the left navigation pane, click Elasticsearch Clusters.

  3. Access the target instance.

    1. In the top menu bar, select the resource group and region.

    2. In the Elasticsearch Clusters list, click the target instance ID.

  4. In the left navigation pane, choose Configuration and Management > Cluster Configuration.

  5. In the Basic Configuration section, click Modify to the right of Garbage Collector.

    • If the Modify button is grayed out, possible reasons include the following:

      • The instance data node memory is less than 32 GB.

      • The instance version is outside the supported range: 6.7.0 to 8.x (earlier than 8.x).

        In this case, upgrade the instance or confirm version compatibility.

    Important
    • Ensure the cluster is in a normal state before changing the garbage collector. This operation triggers a rolling restart of the cluster. The restart duration depends on the cluster size, data volume, and load. Perform this operation during off-peak hours.

    • If cluster indexes have replica shards and the cluster load is normal (CPU usage around 60%, heap memory usage around 50%, and load_1m below the number of CPU cores), the cluster can generally continue to provide services during the change.

    • If the cluster load is too high, indexes have no replicas, and there are many write or query operations, occasional access timeouts may occur during the change. Configure a retry mechanism in the client access to minimize business impact.

  6. On the Modify Configuration page, select G1, and click OK.

    • After confirmation, the cluster automatically restarts. After a successful restart, the garbage collector switch is complete.

    • Expected restart duration: approximately 10–30 minutes for small clusters and 30–60 minutes for large clusters, depending on cluster size and data volume.

    • During the rolling restart, the cluster remains available but may experience brief response delays.

References

API reference for switching garbage collectors: UpdateAdvancedSetting