Merges are scheduled to operate in the background because they can take a long time to finish, especially large segments. Segment merging is computationally expensive, and can eat up a lot of disk I/O. However, if we are a write-heavy Elasticsearch user, we should use a tool like iostat to keep an eye on disk IO metrics over time, and consider upgrading our disks if needed. This setting determines how large the translog size can get before a flush is triggered. We can experiment with lowering the _threshold_size in the index's flush settings. If we see this metric increasing steadily, it could indicate a problem with slow disks this problem may escalate and eventually prevent us from being able to add new information to our index. We can then revert back to the default value of "1s" once we are done indexing.īecause data is not persisted to disk until a flush is successfully completed, it can be useful to track flush latency and take action if performance begins to take a dive. The index settings API enables us to temporarily disable the refresh interval: If we don't need the new information to be immediately available for search, we can optimize for indexing performance over search performance by decreasing refresh frequency until we are done indexing. If any increase of the latency, we may be trying to index too many documents at one time (Elasticsearch's documentation recommends starting with a bulk indexing size of 5 to 15 MB and increasing slowly from there). Elasticsearch does not directly expose this particular metric, but monitoring tools can help us calculate the average indexing latency from the available index_total and index_time_in_millis metrics.