If the memory size of each data node in your Alibaba Cloud Elasticsearch cluster of V6.7.0 or later is 32 GiB or larger, you can configure a garbage collector for the cluster. You can also change the garbage collector type for the cluster. The following types of garbage collectors are supported: CMS and G1. This topic describes how to configure a garbage collector.

Background information

By default, the CMS garbage collector is used for Alibaba Cloud Elasticsearch clusters. If the heap memory usage of a cluster reaches 75%, the CMS garbage collector triggers garbage collection. If the heap memory size of your cluster is large, we recommend that you switch the garbage collector for the cluster to the G1 garbage collector to improve garbage collection performance. For more information, see Garbage collection in open source Elasticsearch.

Prerequisites

An Alibaba Cloud Elasticsearch cluster is created. For more information, see Create an Alibaba Cloud Elasticsearch cluster. The cluster must meet the following requirements:
  • Version: V6.7.0 or later
  • Memory size of each data node: 32 GiB or larger

If the specifications of your cluster do not meet the preceding requirements, upgrade the cluster configuration. For more information, see Upgrade the configuration of a cluster.

Note Elasticsearch clusters that do not meet the preceding requirements can use only the CMS garbage collector. In addition, you cannot switch the garbage collector to the G1 garbage collector for the clusters.

Procedure

  1. Log on to the Elasticsearch console.
  2. In the left-side navigation pane, click Elasticsearch Clusters.
  3. Navigate to the desired cluster.
    1. In the top navigation bar, select the resource group to which the cluster belongs and the region where the cluster resides.
    2. In the left-side navigation pane, click Elasticsearch Clusters. On the Elasticsearch Clusters page, find the cluster and click its ID.
  4. In the left-side navigation pane of the page that appears, choose Configuration and Management > Cluster Configuration.
  5. In the Basic Configuration section, click Modify on the right side of Garbage Collectors.
    You can modify the configuration of the garbage collector for a cluster only if the cluster meets the following requirements:
    • Version: V6.7.0 or later
    • Memory size of each data node: 32 GiB or larger
    Notice
    • Before you modify the configuration of the garbage collector for a cluster, you must make sure that the cluster is in a normal state. After you modify the configuration of the garbage collector for a cluster, the system restarts the cluster. The time required for the restart depends on the size, data volume, and load of the cluster. We recommend that you make the modification during off-peak hours.
    • In most cases, if the indexes of your cluster have replica shards and the load of your cluster is normal, your cluster can still provide services during a cluster configuration change. The following items indicate that the load of a cluster is normal: The CPU utilization of each node in the cluster is about 60%, the heap memory usage of each node in the cluster is about 50%, and the value of NodeLoad_1m for each node is less than the number of vCPUs for the node.
    • If the indexes of your cluster do not have replica shards, the load of the cluster is excessively high, and large amounts of data are written to or queried in your cluster, access timeouts may occur during a cluster configuration change. We recommend that you configure an access retry mechanism for your client before you perform a cluster configuration change. This reduces the impact on your business.
  6. In the Edit Configuration panel, select G1 and click OK.
    Change the garbage collector type

    After you confirm the operation, the system restarts the cluster. After the cluster is restarted, the garbage collector is switched to G1.

References

API operation for switching the garbage collector for a cluster: UpdateAdvancedSetting