All Products
Search
Document Center

Elasticsearch:Configure a garbage collector

Last Updated:Nov 27, 2024

Some Alibaba Cloud Elasticsearch clusters allow you to configure garbage collectors. If the heap memory size of your Alibaba Cloud Elasticsearch cluster is large, we recommend that you switch the garbage collector for the cluster to the G1 garbage collector to improve garbage collection performance. This topic describes how to configure a garbage collector.

Background information

By default, the CMS garbage collector is used for Alibaba Cloud Elasticsearch clusters of a version earlier than V8.X. 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 Primer.

Note

For clusters of V8.X or later, the G1 garbage collector is used by default and cannot be modified.

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: 6.7.0 to 7.16

  • Memory size of each data node: 32 GiB or larger

    Note

    If the memory size of your cluster does not meet the preceding requirements, upgrade the cluster configuration. For more information, see Upgrade the configuration of a cluster.

Procedure

  1. Log on to the Alibaba Cloud 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. 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 Collector.

    Important
    • 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, 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 perform the operation 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 to the cluster may time out 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 Modify Configuration panel, select G1 and click OK.

    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