# Relationship between refresh & flush

**URL:** <https://discuss.elastic.co/t/relationship-between-refresh-flush/51260>\
**Category:** Elasticsearch\
**Created:** [May 30, 2016, 2:52am UTC](https://discuss.elastic.co/t/relationship-between-refresh-flush/51260 "2016-05-30T02:52:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![itplayer](https://avatars.discourse-cdn.com/v4/letter/i/d26b3c/32.png) [@itplayer](https://discuss.elastic.co/u/itplayer)\
**Post date:** [May 30, 2016, 2:52am UTC](https://discuss.elastic.co/t/relationship-between-refresh-flush/51260/1 "2016-05-30T02:52:10Z")

</div>

Hi, I observed a situation but I don't know is this normal or not.  
I use Elasticsearch 1.7.2 and my observation as below.

I set a index with refresh 6s and when I start to add a document to this index, every 6s I see filesystem change, that is a \*.cfe,\*cfs file were created.

If I keep adding document to index(every 2s), every 6s, file were created.  
If this normal?

Is refresh will trigger flush action if there is a change occurred? That measn if there is any pending document in buffer(or translog change), refresh will flush to disk and generate a small segment file?

PS: If I stop to add document to index. There is no file created every 6s.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 30, 2016, 3:02am UTC](https://discuss.elastic.co/t/relationship-between-refresh-flush/51260/2 "2016-05-30T03:02:06Z")

</div>

Yes that is expected, a refresh calls a flush and writes files to the filesystem.  
Take a look at [https://www.elastic.co/guide/en/elasticsearch/guide/2.x/near-real-time.html](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/near-real-time.html)

---

<div class="post-metadata">

**Author:** ![itplayer](https://avatars.discourse-cdn.com/v4/letter/i/d26b3c/32.png) [@itplayer](https://discuss.elastic.co/u/itplayer)\
**Post date:** [May 30, 2016, 5:59am UTC](https://discuss.elastic.co/t/relationship-between-refresh-flush/51260/3 "2016-05-30T05:59:13Z")

</div>

@warkolm thanks.  
But if refresh calls a flush and write files to the filesystem periodically by setting (says 6s). Does it means no matter index buffer /translog full or not(512MB by default) every time interval reach, flush to real segment files happened?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 30, 2016, 6:07am UTC](https://discuss.elastic.co/t/relationship-between-refresh-flush/51260/4 "2016-05-30T06:07:07Z")

</div>

That is correct.

---

<div class="post-metadata">

**Author:** ![itplayer](https://avatars.discourse-cdn.com/v4/letter/i/d26b3c/32.png) [@itplayer](https://discuss.elastic.co/u/itplayer)\
**Post date:** [May 30, 2016, 6:31am UTC](https://discuss.elastic.co/t/relationship-between-refresh-flush/51260/5 "2016-05-30T06:31:24Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)\
**Post date:** [June 1, 2016, 2:43am UTC](https://discuss.elastic.co/t/relationship-between-refresh-flush/51260/6 "2016-06-01T02:43:28Z")

</div>

I suppose the "flush" you are talking is NOT "fsync", right?

From that guide, it says:  
"...Once every second, the shard is refreshed:  
The docs in the in-memory buffer are written to a new segment, **without an fsync**. ..."

That means the flush just move the docs from memory buffer to **file system cache** , and they will be fully committed to disk after "flush" operation.

---

<div class="post-metadata">

**Author:** ![itplayer](https://avatars.discourse-cdn.com/v4/letter/i/d26b3c/32.png) [@itplayer](https://discuss.elastic.co/u/itplayer)\
**Post date:** [June 2, 2016, 3:48am UTC](https://discuss.elastic.co/t/relationship-between-refresh-flush/51260/7 "2016-06-02T03:48:56Z")

</div>

@Youxu, From that guide, it says:  
"...Once every second, the shard is refreshed:  
The docs in the in-memory buffer are written to a new segment, without an fsync. ..."

I'm not clear understanding this paragraph. Where did the new segment go without fsync? I mean is the segment move to HEAP or VirtualMemory somewhere and wating for fsync() called by whom?

What I really want to know is "doing frequent refresh will hurt disk I/O performance or not?"

I assume that frequent refresh will generate more segment files(and they really flush into disk.) during indexing.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:47pm UTC](https://discuss.elastic.co/t/relationship-between-refresh-flush/51260/8 "2017-07-05T22:47:02Z")

</div>


