# How many open files/handles should ES have?

**URL:** <https://discuss.elastic.co/t/how-many-open-files-handles-should-es-have/110245>\
**Category:** Elasticsearch\
**Created:** [December 5, 2017, 3:53am UTC](https://discuss.elastic.co/t/how-many-open-files-handles-should-es-have/110245 "2017-12-05T03:53:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jose\_Ramierez](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@Jose\_Ramierez](https://discuss.elastic.co/u/Jose_Ramierez)\
**Post date:** [December 5, 2017, 3:53am UTC](https://discuss.elastic.co/t/how-many-open-files-handles-should-es-have/110245/1 "2017-12-05T03:53:04Z")

</div>

5.6.4 on CentOS 7

```
[root@localhost ~]# lsof |grep elasticsearch|wc -l
6780

```

is that a normal number?

This ES instance is behind logstash, fwiw. The same command against logstash shows 170-200 open files.

---

<div class="post-metadata">

**Author:** ![mujtabahussain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mujtabahussain/32/17514_2.png) [@mujtabahussain](https://discuss.elastic.co/u/mujtabahussain)\
**Post date:** [December 5, 2017, 4:45am UTC](https://discuss.elastic.co/t/how-many-open-files-handles-should-es-have/110245/2 "2017-12-05T04:45:10Z")

</div>

Hmmm. I have a simple three node setup(ES 5.3.0) running on my home server(Darwin OS X) and it has

```bash
$> lsof | grep elasticsearch | wc -l
    4670

```

Whether it should have this many or not, I don't know ☹

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [December 5, 2017, 5:16am UTC](https://discuss.elastic.co/t/how-many-open-files-handles-should-es-have/110245/3 "2017-12-05T05:16:26Z")

</div>

Using `lsof` is not an accurate way to count file descriptors (memory-mapped portions of a file, duplicate file descriptors because of counting per thread, etc.). Instead, please check: `ls -al /proc/<PID>/fd`.

---

<div class="post-metadata">

**Author:** ![Jose\_Ramierez](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@Jose\_Ramierez](https://discuss.elastic.co/u/Jose_Ramierez)\
**Post date:** [December 5, 2017, 5:36am UTC](https://discuss.elastic.co/t/how-many-open-files-handles-should-es-have/110245/4 "2017-12-05T05:36:08Z")

</div>

How do I dynamically derive the pid so I can run the command in one step?

---

<div class="post-metadata">

**Author:** ![Jose\_Ramierez](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@Jose\_Ramierez](https://discuss.elastic.co/u/Jose_Ramierez)\
**Post date:** [December 5, 2017, 7:00pm UTC](https://discuss.elastic.co/t/how-many-open-files-handles-should-es-have/110245/5 "2017-12-05T19:00:10Z")

</div>

OK, now here is the story:

ls -al /proc/1109/fd -- logstash  
203

ls -al /proc/1802/fd -- elasticsearch  
548

better, yes?

---

<div class="post-metadata">

**Author:** ![Jose\_Ramierez](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@Jose\_Ramierez](https://discuss.elastic.co/u/Jose_Ramierez)\
**Post date:** [December 22, 2017, 3:37pm UTC](https://discuss.elastic.co/t/how-many-open-files-handles-should-es-have/110245/6 "2017-12-22T15:37:27Z")

</div>

The answer is is this command:

```auto
ls -al /proc/`pgrep -f logstash`/fd |wc -l

```

To see it unmangled, here is where I found it:

> <https://unix.stackexchange.com/questions/407830/how-to-pipe-pid-of-java-app-into-a-command/412534#412534>

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 22, 2017, 3:57pm UTC](https://discuss.elastic.co/t/how-many-open-files-handles-should-es-have/110245/7 "2017-12-22T15:57:32Z")

</div>

I edited your post.

---

<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:** [January 19, 2018, 3:57pm UTC](https://discuss.elastic.co/t/how-many-open-files-handles-should-es-have/110245/8 "2018-01-19T15:57:45Z")

</div>

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