When does ElasticSearch performs a flush

Viewed 441

What are the conditions that trigger a flush in ElasticSearch node/index/shard?

There are good explanations about the flow of ElasticSearch refreshing every second and flushing in a less frequent manner to avoid intensive CPU usage, but which component is responsible to perform the flush?

I tried to look over the source code but didn't manage to find the right place.

1 Answers

There is no fixed interval, Elasticsearch uses some heuristic to determine when to call flush as mentioned in the official doc

Elasticsearch automatically triggers flushes as needed, using heuristics that trade off the size of the unflushed transaction log against the cost of performing each flush.

Also as explained in at the end of this SO answer from Elastic team member, this heuristic depends on

depending on how many operations get added to the transaction log, how big they are, and when the last flush happened.

Note: You can also tweak the setting of flush operation but not recommended.

Edit: https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java#L48 is the source code which processes the flush operation.

Related