# How to deal with large number of files in a single directory

**URL:** <https://discuss.elastic.co/t/how-to-deal-with-large-number-of-files-in-a-single-directory/154008>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [October 25, 2018, 1:18pm UTC](https://discuss.elastic.co/t/how-to-deal-with-large-number-of-files-in-a-single-directory/154008 "2018-10-25T13:18:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lihang\_Gong](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@Lihang\_Gong](https://discuss.elastic.co/u/Lihang_Gong)\
**Post date:** [October 25, 2018, 1:18pm UTC](https://discuss.elastic.co/t/how-to-deal-with-large-number-of-files-in-a-single-directory/154008/1 "2018-10-25T13:18:07Z")

</div>

Filebeat scans the whole directory to get files which needs to be collected. But when there is a large number of files in the directory, filebeat creates multiple goroutines to collect files causing high I/O wait. Can anyone help me?

---

<div class="post-metadata">

**Author:** ![pierhugues](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pierhugues/32/48383_2.png) [@pierhugues](https://discuss.elastic.co/u/pierhugues)\
**Post date:** [October 25, 2018, 1:30pm UTC](https://discuss.elastic.co/t/how-to-deal-with-large-number-of-files-in-a-single-directory/154008/2 "2018-10-25T13:30:30Z")

</div>

@Lihang_Gong Yes by default Filebeat creates one goroutine for each discovered files, in your case it could cause a lot of goroutines. But its possible to set a hard limit on the number of concurrent files been read, see the `harvester_limit` options in our [documentation](https://www.elastic.co/guide/en/beats/filebeat/6.4/filebeat-input-log.html#filebeat-input-log-harvester-limit).

---

<div class="post-metadata">

**Author:** ![Lihang\_Gong](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@Lihang\_Gong](https://discuss.elastic.co/u/Lihang_Gong)\
**Post date:** [October 25, 2018, 1:45pm UTC](https://discuss.elastic.co/t/how-to-deal-with-large-number-of-files-in-a-single-directory/154008/3 "2018-10-25T13:45:36Z")

</div>

Thanks. I'm gonna try it.😁

---

<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:** [November 22, 2018, 1:45pm UTC](https://discuss.elastic.co/t/how-to-deal-with-large-number-of-files-in-a-single-directory/154008/4 "2018-11-22T13:45:37Z")

</div>

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