Question: we are having problem with Kafka. sometimes Suddenly, without warning we go out of Synchronization and start to get exceptions when emitting events.

the exception we are getting is 

```
java.io.IOException: Too many open files

```

it seems this is a generic exception thrown by Kafka in many cases. We investigated it a little and we think the root cause is when trying to emit events to some topic, it fails because kafka dosen't have a leader partition for this topic

can someone help ?

Answer: 
One of the case this happens is that when you have big partition number, because each partition maps to a directory in file system in broker that consist of two files. one of them is for the index and another is for data. broker opens both files. so more partition numbers there is more open files. as Doomy said you can increase the open files in linux but this config is not permanent and when you close the session this config will disappear. and in next loggin if you check with this command 

```
ulimit -a | grep "open files"

```

you can see the older number. but with this config you can make it permanent:

open this file:

```
sudo nano /etc/pam.d/common-session

```

and add this line:

```
session required pam_limits.so

```

after that you can set the limit in limits.config as this:

```
sudo nano /etc/security/limits.conf

```

and then you can set limit in this file forexample

```
* soft nofile 80000

```

or any hard config. after that close your session and check again the limit of open files
I had similar "java.io.IOException: Too many open files" issue on Linux/CentOS.
In my case, after checking open fd's with *isof*, it was kafka-web-console which was opening too many connections. Stopping that solved my problem.