High write availability is a feature from the Alibaba Cloud Elasticsearch team that improves cluster write stability. It uses an asynchronous high-availability architecture to implement read/write splitting, which ensures cluster stability during high-concurrency writes. The feature also includes components such as service proxies and message queues. This topic describes the principles of the high write availability feature and explains how to use it.
Background information
The high write availability feature provides the following functions:- High data availability: If your cluster becomes unavailable, data is written to a message queue. After the cluster recovers, the system retrieves the data from the message queue to prevent data loss.
- Data buffering: During traffic peaks, data is written to a message queue for buffering. This prevents heavy traffic from overwhelming the cluster. The buffered data is then sent in batches. This process avoids frequent writes of small batches to the cluster, which improves CPU utilization and write performance.
- Data playback: If data in your cluster is lost, you can use this feature to restore the data.
- Throttling: This feature limits data traffic to prevent service unavailability caused by excessive traffic during abnormal situations.
Prerequisites
- The instance version must be 6.7.0.
- The data node specification must be 2 vCPUs and 4 GB of memory or higher.
Limits
The high write availability feature is available only for instances created before November 2021 in the China (Beijing), China (Shanghai), China (Hangzhou), and China (Shenzhen) regions. If your instance does not meet these requirements, use the Indexing Service feature instead. For more information, see Manage data streams using Indexing Service.
Asynchronous and synchronous write modes
- Asynchronous write mode
An Elasticsearch cluster works in asynchronous write mode when the high write availability feature is enabled. In this mode, client requests are distributed by proxy services. For query requests, the proxy services forward the requests to the Elasticsearch cluster and then receive and return the query results. For write requests, the proxy services forward the requests to asynchronous data processing components, which include message queues. These components then write data to the Elasticsearch cluster in real time. This process improves the stability and write performance of the cluster.
- Synchronous write mode
By default, an Elasticsearch cluster works in synchronous write mode when the high write availability feature is disabled. In this mode, proxy services forward both query and write requests to the Elasticsearch cluster. If an error occurs in asynchronous mode, you can temporarily switch to synchronous mode. After you switch modes, write requests are forwarded directly to the Elasticsearch cluster by the proxy service instead of being stored in the message queue. This ensures that data write operations can recover quickly.
Enable the high write availability feature
Log on to the Alibaba Cloud Elasticsearch console.
In the left navigation menu, choose Elasticsearch Clusters.
Navigate to the target cluster.
In the top navigation bar, select the resource group to which the cluster belongs and the region where the cluster resides.
On the Elasticsearch Clusters page, find the cluster and click its ID.
- On the Basic Information page, find the High Write Availability section and click Enable Now.
- On the High Write Availability page, click Enable to enable the high write availability feature.
Automatically generate a primary key based on the document hash value when no primary key exists: Select this option to generate a primary key for documents that do not have one. The primary key is generated based on the hash value of the document content. This ensures that documents with identical content are overwritten when written to Elasticsearch, which prevents duplicate data.
Note Enabling or disabling the high write availability feature is a seamless change to the cluster architecture. This operation typically does not affect access to your Alibaba Cloud Elasticsearch cluster. However, we recommend that you perform this operation during off-peak hours. - Click Confirm.
View asynchronous write logs
After you enable the high write availability feature, click View Asynchronous Write Logs in the High Write Availability section to view the logs generated in asynchronous mode.
Temporarily enable synchronous write mode
After asynchronous mode is restored, turn off the Enable Synchronous Write Temporarily switch to resume asynchronous write mode.
Disable the high write availability feature
- In the High Write Availability section, click Settings to the right of High Write Availability.
- On the High Write Availability page, click Disable to disable the high write availability feature.
- Click Confirm.