# Is it safe to clear filesystem cache

**URL:** <https://discuss.elastic.co/t/is-it-safe-to-clear-filesystem-cache/97754>\
**Category:** Elasticsearch\
**Created:** [August 21, 2017, 11:13am UTC](https://discuss.elastic.co/t/is-it-safe-to-clear-filesystem-cache/97754 "2017-08-21T11:13:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![596375269](https://avatars.discourse-cdn.com/v4/letter/5/e495f1/32.png) [@596375269](https://discuss.elastic.co/u/596375269)\
**Post date:** [August 21, 2017, 11:13am UTC](https://discuss.elastic.co/t/is-it-safe-to-clear-filesystem-cache/97754/1 "2017-08-21T11:13:54Z")

</div>

hello everyone

When I import millions of data in bulk, I encountered a problem.  
The memory usage of the cluster servers increased rapidly, from 50% to about 90%, and after finished importing ,the occupied memories come down very slowly

I analyzed the memory usage and found that the swap cache took up a lot of memory  
for example .This is the output of the top command in a common situations. (through it is not the 90% situation)

Mem:, 198233800k, total, 87175692k, used, 111058108k, free, 408804k, buffers  
Swap:, 0k, total, 0k, used, 0k, free, 10801060k, cached

You can see that swap cache takes up about 10G of memory, it's a little high

since it is filesystem cache, i found that i can use "echo 1 \> /proc/sys/vm/drop\_caches" to empty the cache to free the memory

* * *

There are four questions

1. When the memory use is relatively high, for example 80%,90% , because of filesystem cache usage ,does the server need to be optimized?

2. what do you recommend if you need to optimize? Is it safe to use the "echo 1 \> /proc/sys/vm/drop\_caches" method for elasticsearch app or the os?  
Can I use it regularly after importing data in bulk?

3. when I use /\_nodes/stats api to view the cluster state, i found the os/swap information is 0, is this right? for example  
mem: {  
total\_in\_bytes: 135207735296,  
free\_in\_bytes: 38961053696,  
used\_in\_bytes: 96246681600,  
free\_percent: 29,  
used\_percent: 71  
},  
swap: {  
total\_in\_bytes: 0,  
free\_in\_bytes: 0,  
used\_in\_bytes: 0  
}

Because I think the value should be ,for example, the "10801060k" above.

4.es-process already lock the memory by config "bootstrap.mlockall: true", why there is still swap memory?

I use the version of 5.4.0

---

<div class="post-metadata">

**Author:** ![596375269](https://avatars.discourse-cdn.com/v4/letter/5/e495f1/32.png) [@596375269](https://discuss.elastic.co/u/596375269)\
**Post date:** [August 27, 2017, 10:22am UTC](https://discuss.elastic.co/t/is-it-safe-to-clear-filesystem-cache/97754/2 "2017-08-27T10:22:18Z")

</div>

hello everybody.  
any clues ?  
😄😄😄

---

<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:** [September 24, 2017, 10:22am UTC](https://discuss.elastic.co/t/is-it-safe-to-clear-filesystem-cache/97754/3 "2017-09-24T10:22:25Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
